diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index 058b983..b5e4741 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -164,7 +164,11 @@ export class OseActorSheet extends ActorSheet { let actorObject = this.actor; let element = event.currentTarget; let attack = element.parentElement.parentElement.dataset.attack; - actorObject.rollAttack({roll: {}}, { type: attack, skipDialog: ev.ctrlKey }); + const rollData = { + actor: this.data, + roll: {} + } + actorObject.targetAttack(rollData, attack, {type: attack, skipDialog: ev.ctrlKey}); }); html.find(".spells .item-reset").click((ev) => { diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index c7552bf..cd86506 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -105,6 +105,7 @@ export class OseActor extends Actor { let roll = new Roll(this.data.data.hp.hd).roll(); return this.update({ data: { + actor: this.data, hp: { max: roll.total, value: roll.total, @@ -144,6 +145,7 @@ export class OseActor extends Actor { const rollParts = ["2d6"]; const data = { + actor: this.data, roll: { type: "below", target: this.data.data.details.morale, @@ -167,6 +169,7 @@ export class OseActor extends Actor { const rollParts = ["2d6"]; const data = { + actor: this.data, roll: { type: "below", target: this.data.data.retainer.loyalty, @@ -189,6 +192,7 @@ export class OseActor extends Actor { const rollParts = ["2d6"]; const data = { + actor: this.data, roll: { type: "table", table: { @@ -230,6 +234,7 @@ export class OseActor extends Actor { const rollParts = ["1d20"]; const data = { + actor: this.data, roll: { type: "check", target: this.data.data.scores[score].value, @@ -262,6 +267,7 @@ export class OseActor extends Actor { } const data = { + actor: this.data, roll: { type: "hitdice", }, @@ -290,6 +296,7 @@ export class OseActor extends Actor { label = "(1)"; } const data = { + actor: this.data, roll: { type: { type: "appearing", @@ -314,6 +321,7 @@ export class OseActor extends Actor { const rollParts = ["1d6"]; const data = { + actor: this.data, roll: { type: "below", target: this.data.data.exploration[expl], @@ -372,6 +380,17 @@ export class OseActor extends Actor { }); } + async targetAttack(data, type, options) { + if (game.user.targets.size > 0) { + for (let t of game.user.targets.values()) { + data.roll.target = t; + await this.rollAttack(data, { type: type, skipDialog: options.skipDialog }); + } + } else { + this.rollAttack(data, { type: type, skipDialog: options.skipDialog }); + } + } + rollAttack(attData, options = {}) { const data = this.data.data; const rollParts = ["1d20"]; diff --git a/src/module/item/entity.js b/src/module/item/entity.js index d386749..0ec4657 100644 --- a/src/module/item/entity.js +++ b/src/module/item/entity.js @@ -79,18 +79,6 @@ export class OseItem extends Item { } }; - // rollAttack to target helper - const rollAttack = async (type) => { - if (game.user.targets.size > 0) { - for (let t of game.user.targets.values()) { - rollData.roll.target = t; - await this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog }); - } - } else { - this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog }); - } - }; - if (data.missile && data.melee && !isNPC) { // Dialog new Dialog({ @@ -101,14 +89,14 @@ export class OseItem extends Item { icon: '', label: "Melee", callback: () => { - rollAttack("melee"); + this.targetAttack(rollData, "melee", options); }, }, missile: { icon: '', label: "Missile", callback: () => { - rollAttack("missile"); + this.targetAttack(rollData, "missile", options); }, }, }, @@ -118,7 +106,7 @@ export class OseItem extends Item { } else if (data.missile && !isNPC) { type = "missile"; } - rollAttack(type); + this.targetAttack(rollData, type, options); return true; } diff --git a/src/templates/chat/roll-attack.html b/src/templates/chat/roll-attack.html index ac74c29..f493b66 100644 --- a/src/templates/chat/roll-attack.html +++ b/src/templates/chat/roll-attack.html @@ -5,7 +5,11 @@

{{title}}

-
+ {{#if data.item}} +
+ {{else}} +
+ {{/if}} {{#if result.victim}}
diff --git a/src/templates/chat/roll-creation.html b/src/templates/chat/roll-creation.html index 1f6b565..a8bdadf 100644 --- a/src/templates/chat/roll-creation.html +++ b/src/templates/chat/roll-creation.html @@ -2,7 +2,7 @@

{{title}}

-
+
    diff --git a/src/templates/chat/roll-result.html b/src/templates/chat/roll-result.html index b6daef3..d31c4dc 100644 --- a/src/templates/chat/roll-result.html +++ b/src/templates/chat/roll-result.html @@ -2,7 +2,11 @@

    {{title}}

    -
    + {{#if data.item}} +
    + {{else}} +
    + {{/if}}
    {{#if result.details}}
    {{{result.details}}}
    {{/if}} {{#if result.isFailure}}
    {{localize 'OSE.Failure'}} ({{result.target}})