diff --git a/src/main.mjs b/src/main.mjs index be09043c..fbe1361d 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -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" } diff --git a/src/module/sheets/character/equipment.mjs b/src/module/sheets/character/equipment.mjs index 7e5d9d96..d38ac604 100644 --- a/src/module/sheets/character/equipment.mjs +++ b/src/module/sheets/character/equipment.mjs @@ -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"] diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index de050dd2..ac9be466 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -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 (document.parent && document.parent !== this.actor) { - document.parent.items.get(document._id).delete() - } - await this._onDropDocument(event, document); + if ((targetDocument?.name ?? false) === document.name && targetDocument._id !== document._id && await foundry.applications.api.DialogV2.confirm({ + content: `Gegenstände der Art ${document.name} (Neue Anzahl: ${targetDocument.system.quantity + document.system.quantity}) zusammenlegen?`, + 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) + } } } } diff --git a/src/module/sheets/creatureSheet.mjs b/src/module/sheets/creatureSheet.mjs index f726e00d..6e754e2a 100644 --- a/src/module/sheets/creatureSheet.mjs +++ b/src/module/sheets/creatureSheet.mjs @@ -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) { diff --git a/src/module/sheets/merchantSheet.mjs b/src/module/sheets/merchantSheet.mjs index e37ba245..22bc492a 100644 --- a/src/module/sheets/merchantSheet.mjs +++ b/src/module/sheets/merchantSheet.mjs @@ -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 } diff --git a/src/module/xml-import/xml-import.mjs b/src/module/xml-import/xml-import.mjs index 07d97f4e..c0875d70 100644 --- a/src/module/xml-import/xml-import.mjs +++ b/src/module/xml-import/xml-import.mjs @@ -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, } - })]) + }) + ]) } }) } diff --git a/src/system.json b/src/system.json index 6e09363e..e2bef581 100644 --- a/src/system.json +++ b/src/system.json @@ -92,7 +92,7 @@ "label": "Rüstzeug", "system": "DSA_4-1", "type": "Item", - "path": "packs/ruestzeug", + "path": "packs/Ruestzeug", "private": false }, {