diff --git a/src/apps/components/pages/ActionsDescriptionTab.svelte b/src/apps/components/pages/ActionsDescriptionTab.svelte index 57f112a694..2560da0714 100644 --- a/src/apps/components/pages/ActionsDescriptionTab.svelte +++ b/src/apps/components/pages/ActionsDescriptionTab.svelte @@ -14,8 +14,6 @@ ["item", "A5E.Item"], ]; - console.log($item.system.actions[actionId]); - $: content = $item.system.actions[actionId]?.description; $: descriptionOutputs = $item.system.actions[actionId]?.descriptionOutputs ?? []; diff --git a/src/apps/components/pages/BackgroundEquipmentTab.svelte b/src/apps/components/pages/BackgroundEquipmentTab.svelte index 832b0b8252..cd9c534eff 100644 --- a/src/apps/components/pages/BackgroundEquipmentTab.svelte +++ b/src/apps/components/pages/BackgroundEquipmentTab.svelte @@ -19,7 +19,6 @@ const { uuid } = JSON.parse( dragEvent.dataTransfer.getData("text/plain") ); - console.log(uuid); linkedEquipment.add({ uuid }); } catch (err) { diff --git a/src/apps/dialogs/ActionActivationDialog.svelte b/src/apps/dialogs/ActionActivationDialog.svelte index 7374c0453e..82d1ae7d2b 100644 --- a/src/apps/dialogs/ActionActivationDialog.svelte +++ b/src/apps/dialogs/ActionActivationDialog.svelte @@ -26,7 +26,7 @@ ["generic", "healing", "damage"].includes(value.type) && !value.formula ) { - acc.push(key); + return acc; } if (value.default ?? true) acc.push(key); @@ -124,8 +124,6 @@ let selectedPrompts = getDefaultSelections(prompts); let situationalMods = ""; - console.log(selectedPrompts); - $: rollFormula = constructD20RollFormula({ actor: $actor, rollMode, diff --git a/src/documents/actor.js b/src/documents/actor.js index 8bb57611c8..aab4a10b29 100644 --- a/src/documents/actor.js +++ b/src/documents/actor.js @@ -697,7 +697,7 @@ export default class ActorA5e extends Actor { async rollAbilityCheck(abilityKey, options = {}) { let dialogData; - if (options.skipRollDialog) dialogData = this.#getDefaultAbilityCheckData(abilityKey, options); + if (options.skipRollDialog) dialogData = this.getDefaultAbilityCheckData(abilityKey, options); else dialogData = await this.#showAbilityCheckPrompt(abilityKey, options); if (!dialogData) return; @@ -730,12 +730,12 @@ export default class ActorA5e extends Actor { ChatMessage.create(chatData); } - #getDefaultAbilityCheckData(abilityKey, options) { + getDefaultAbilityCheckData(abilityKey, options = {}) { const ability = this.system.abilities[abilityKey]; const rollFormula = constructD20RollFormula({ actor: this, - rollMode: options.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, + rollMode: options?.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, modifiers: [ { label: `${game.i18n.localize(CONFIG.A5E.abilities[abilityKey])} Mod`, @@ -753,10 +753,10 @@ export default class ActorA5e extends Actor { }, { label: 'Expertise Die', - value: getExpertiseDieSize(options.expertiseDice ?? ability.expertiseDice) + value: getExpertiseDieSize(options?.expertiseDice ?? ability.expertiseDice) }, { - value: options.situationalMods + value: options?.situationalMods } ] }); @@ -828,7 +828,7 @@ export default class ActorA5e extends Actor { async rollSavingThrow(abilityKey, options = {}) { let dialogData; - if (options.skipRollDialog) dialogData = this.#getDefaultSavingThrowData(abilityKey, options); + if (options.skipRollDialog) dialogData = this.getDefaultSavingThrowData(abilityKey, options); else dialogData = await this.#showSavingThrowPrompt(abilityKey, options); if (dialogData === null) return; @@ -866,12 +866,12 @@ export default class ActorA5e extends Actor { ChatMessage.create(chatData); } - #getDefaultSavingThrowData(abilityKey, options) { + getDefaultSavingThrowData(abilityKey, options = {}) { const ability = this.system.abilities[abilityKey]; const rollFormula = constructD20RollFormula({ actor: this, - rollMode: options.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, + rollMode: options?.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, modifiers: [ { label: `${game.i18n.localize(CONFIG.A5E.abilities[abilityKey])} Mod`, @@ -896,10 +896,10 @@ export default class ActorA5e extends Actor { }, { label: 'Expertise Die', - value: getExpertiseDieSize(options.expertiseDice ?? ability?.expertiseDice) + value: getExpertiseDieSize(options?.expertiseDice ?? ability?.expertiseDice) }, { - value: options.situationalMods + value: options?.situationalMods } ] }); @@ -929,7 +929,7 @@ export default class ActorA5e extends Actor { async rollSkillCheck(skillKey, options = {}) { let rollData; - if (options.skipRollDialog) rollData = this.#getDefaultSkillRollData(skillKey, options); + if (options.skipRollDialog) rollData = this.getDefaultSkillCheckData(skillKey, options); else rollData = await this.#showSkillCheckPrompt(skillKey, options); if (!rollData) return; @@ -964,17 +964,17 @@ export default class ActorA5e extends Actor { ChatMessage.create(chatData); } - #getDefaultSkillRollData(skillKey, options) { + getDefaultSkillCheckData(skillKey, options = {}) { const skill = this.system.skills[skillKey]; - const abilityKey = options.abilityKey ?? skill.ability; + const abilityKey = options?.abilityKey ?? skill.ability; const ability = this.system.abilities[abilityKey]; // TODO: Update the keys below to use format and proper localisations. const rollFormula = constructD20RollFormula({ actor: this, - rollMode: options.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, - minRoll: options.minRoll ?? skill.minRoll, + rollMode: options?.rollMode ?? CONFIG.A5E.ROLL_MODE.NORMAL, + minRoll: options?.minRoll ?? skill.minRoll, modifiers: [ { label: `${game.i18n.localize(CONFIG.A5E.skills[skillKey])} Mod`, @@ -1002,10 +1002,10 @@ export default class ActorA5e extends Actor { }, { label: 'Expertise Die', - value: getExpertiseDieSize(options.expertiseDice ?? skill.expertiseDice) + value: getExpertiseDieSize(options?.expertiseDice ?? skill.expertiseDice) }, { - value: options.situationalMods + value: options?.situationalMods } ] }); diff --git a/src/documents/item.js b/src/documents/item.js index f36918f19c..d991f5659b 100644 --- a/src/documents/item.js +++ b/src/documents/item.js @@ -122,6 +122,8 @@ export default class ItemA5e extends Item { if (!promise) return; + const rolls = promise?.rolls?.map(([_, roll]) => this.#prepareItemRoll(roll)).filter(Boolean); + // TODO: Add template validation and extract template placement to its own function if (promise.placeTemplate) { // const templateDocument = createTemplateDocument(this); @@ -155,6 +157,18 @@ export default class ItemA5e extends Item { ChatMessage.create(chatData); } + #prepareItemRoll(roll) { + switch (roll.type) { + case 'abilityCheck': + return this.actor.getDefaultAbilityCheckData(roll.ability); + case 'savingThrow': + return this.actor.getDefaultSavingThrowData(roll.ability); + case 'skillCheck': + return this.actor.getDefaultSkillCheckData(roll.skill, roll.ability); + default: return null; + } + } + async shareItemDescription() { const chatData = { user: game.user?.id,