adds reverse inventory mechanic with "zusammenlegen"
parent
7849ba2a90
commit
6b64b0b6db
|
|
@ -97,7 +97,6 @@ Hooks.once("init", () => {
|
|||
|
||||
movementActions.climb.canSelect = (token) => {
|
||||
const actor = token.actor | null;
|
||||
console.log
|
||||
return (actor.type === "Character" && actor.system.itemTypes["Skill"].find(p => p.name === "Klettern")?.system.taw > 0) || actor.type === "Creature"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export default {
|
|||
|
||||
context.equipments = []
|
||||
context.carryingweight = 0
|
||||
actorData.itemTypes.Equipment.forEach((item, index) => {
|
||||
actorData.itemTypes["Equipment"].sort((a, b) => a.sort - b.sort).forEach((item, index) => {
|
||||
|
||||
// worn items are halved weight
|
||||
|
||||
|
|
@ -41,13 +41,10 @@ export default {
|
|||
context.wealth = 0
|
||||
|
||||
actorData.itemTypes["Equipment"].forEach(coin => {
|
||||
console.log(coin.name, coin.system.category)
|
||||
if (coin.system.category.indexOf("Währung") !== -1) {
|
||||
console.log(context.wealth, coin)
|
||||
context.wealth += (coin.system.quantity * coin.system.currencyDenominator)
|
||||
}
|
||||
})
|
||||
console.log(context.wealth)
|
||||
|
||||
const maxSets = 3
|
||||
const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
|
||||
|
|
|
|||
|
|
@ -491,15 +491,13 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
}
|
||||
|
||||
|
||||
// TODO needs to be fixed once Character Sheet is migrated to ActorSheetV2
|
||||
async _onDrop(event) {
|
||||
const data = TextEditor.implementation.getDragEventData(event);
|
||||
const actor = this.actor;
|
||||
const targetDocument = this.actor.itemTypes["Equipment"].find(p => p._id === event.target.dataset['itemId'])
|
||||
//const allowed = Hooks.call("dropActorSheetData", actor, this, data);
|
||||
//if (allowed === false) return;
|
||||
|
||||
console.log("looted or dropped", data)
|
||||
|
||||
// Dropped Documents
|
||||
const documentClass = foundry.utils.getDocumentClass(data.type);
|
||||
if (documentClass) {
|
||||
|
|
@ -507,11 +505,27 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
|
||||
if (document.type === "Equipment" || document.type === "Advantage" || document.type === "Spell" || document.type === "Liturgy" || document.type === "ActiveEffect" || document.type === "SpecialAbility") {
|
||||
// No duplication by moving items from one actor to another
|
||||
|
||||
if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({
|
||||
content: `<span>Gegenstände der Art <strong>${document.name}</strong> (Neue Anzahl: ${targetDocument.system.quantity + document.system.quantity}) zusammenlegen?</span>`,
|
||||
rejectClose: false,
|
||||
modal: true,
|
||||
window: {
|
||||
title: `Gegenstände zusammenlegen`
|
||||
}
|
||||
})) {
|
||||
// combine
|
||||
await targetDocument.update({"system.quantity": targetDocument.system.quantity + document.system.quantity})
|
||||
await this.actor.deleteEmbeddedDocuments('Item', [document._id])
|
||||
return false
|
||||
} else {
|
||||
|
||||
if (document.parent && document.parent !== this.actor) {
|
||||
document.parent.items.get(document._id).delete()
|
||||
}
|
||||
|
||||
await this._onDropDocument(event, document);
|
||||
await this._onDropDocument(event, document)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
handler: CreatureSheet.#onSubmitForm
|
||||
},
|
||||
actions: {
|
||||
openEmbeddedDocument: CreatureSheet.#openEmbeddedDocument,
|
||||
removeAttack: CreatureSheet.#removeAttack,
|
||||
addAttack: CreatureSheet.#addAttack,
|
||||
roll: CreatureSheet.#dieRoll,
|
||||
|
|
@ -82,6 +83,12 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
await this.document.update(formData.object) // Note: formData.object
|
||||
}
|
||||
|
||||
static #openEmbeddedDocument(event, target) {
|
||||
const dataset = target.dataset
|
||||
const id = dataset.itemId ?? dataset.id
|
||||
this.document.items.get(id).sheet.render(true)
|
||||
}
|
||||
|
||||
static async #removeAttack(evt) {
|
||||
const {index} = evt.srcElement.dataset;
|
||||
let sans = Array.from(this.document.system.attacks);
|
||||
|
|
@ -182,7 +189,6 @@ export class CreatureSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
const actor = this.actor;
|
||||
//const allowed = Hooks.call("dropActorSheetData", actor, this, data);
|
||||
// if (allowed === false) return;
|
||||
console.log("dropped")
|
||||
// Dropped Documents
|
||||
const documentClass = foundry.utils.getDocumentClass(data.type);
|
||||
if (documentClass) {
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ export class MerchantSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
*/
|
||||
static async #onSubmitForm(event, form, formData) {
|
||||
event.preventDefault()
|
||||
|
||||
console.log(formData.object)
|
||||
|
||||
await this.document.update(formData.object) // Note: formData.object
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ export class XmlImport {
|
|||
}
|
||||
|
||||
async #addSkillFromCompendiumByNameToActor(talentName, taw, actor, combatStatistics, attributes) {
|
||||
const compendiumOfSkills = game.packs.get('DSA_4-1.talente');
|
||||
const compendiumOfSkills = game.packs.get('DSA_4-1.Skills');
|
||||
const talentId = compendiumOfSkills.index.find(skill => skill.name === talentName)
|
||||
if (talentId) {
|
||||
|
||||
|
|
@ -383,7 +383,7 @@ export class XmlImport {
|
|||
}
|
||||
|
||||
async #addSpellsFromCompendiumByNameToActor(spellName, zfw, representation, hauszauber, actor) {
|
||||
const compendiumOfSpells = game.packs.get('DSA_4-1.spells');
|
||||
const compendiumOfSpells = game.packs.get('DSA_4-1.Spells');
|
||||
const SCREAMING_NAME = spellName.toUpperCase()
|
||||
const spellId = compendiumOfSpells.index.find(spell => spell.name === SCREAMING_NAME)
|
||||
if (spellId) {
|
||||
|
|
@ -400,7 +400,7 @@ export class XmlImport {
|
|||
}
|
||||
|
||||
async #addLiturgiesFromCompendiumByNameToActor(liturgyName, actor) {
|
||||
const compendiumOfLiturgies = game.packs.get('DSA_4-1.liturgien');
|
||||
const compendiumOfLiturgies = game.packs.get('DSA_4-1.Liturgies');
|
||||
const liturgyId = compendiumOfLiturgies.index.find(liturgy => {
|
||||
return liturgy.name === LiturgyData.lookupAlias(liturgyName.split(" (")[0])
|
||||
})
|
||||
|
|
@ -494,6 +494,7 @@ export class XmlImport {
|
|||
actor.items.get(e._id).delete()
|
||||
})
|
||||
}
|
||||
let i = 100
|
||||
held.gegenstände?.gegenstand?.forEach(e => {
|
||||
const compendiumOfArmor = game.packs.get('DSA_4-1.Armor');
|
||||
const compendiumOfWeapons = game.packs.get('DSA_4-1.Weapons');
|
||||
|
|
@ -525,13 +526,15 @@ export class XmlImport {
|
|||
{
|
||||
name: e.modallgemein?.name?.value ?? e.name,
|
||||
type: "Equipment",
|
||||
sort: (i++) * 100,
|
||||
system: {
|
||||
quantity: e.anzahl,
|
||||
price: e.modallgemein?.preis.value,
|
||||
weight: e.modallgemein?.gewicht.value,
|
||||
|
||||
}
|
||||
})])
|
||||
})
|
||||
])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
"label": "Rüstzeug",
|
||||
"system": "DSA_4-1",
|
||||
"type": "Item",
|
||||
"path": "packs/ruestzeug",
|
||||
"path": "packs/Ruestzeug",
|
||||
"private": false
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue