From f31bc3e790b2bc83d56f1794b68e7a4b2f112e6b Mon Sep 17 00:00:00 2001 From: U~man Date: Fri, 24 Jul 2020 20:04:18 +0200 Subject: [PATCH] WIP: Attack saves --- .gitignore | 3 +- src/module/actor/entity.js | 33 ++++++++++--------- src/module/dice.js | 1 + src/module/item/entity.js | 46 +++++++++++++++++++-------- src/templates/chat/roll-attack.html | 17 ++++++++-- src/templates/items/weapon-sheet.html | 4 +-- 6 files changed, 70 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 76add87..e5cebe8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +foundryconfig.json diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 0b7d1f0..fe5031b 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -53,15 +53,15 @@ export class OseActor extends Actor { isNew() { const data = this.data.data; - if (this.data.type == 'character') { + if (this.data.type == "character") { let ct = 0; Object.values(data.scores).forEach((el) => { ct += el.value; - }) + }); return ct == 0 ? true : false; - } else if (this.data.type == 'monster') { + } else if (this.data.type == "monster") { let ct = 0; - Object.values(data.saves).forEach(el => { + Object.values(data.saves).forEach((el) => { ct += el.value; }); return ct == 0 ? true : false; @@ -79,21 +79,21 @@ export class OseActor extends Actor { this.update({ "data.saves": { death: { - value: saves.d + value: saves.d, }, wand: { - value: saves.w + value: saves.w, }, paralysis: { - value: saves.p + value: saves.p, }, breath: { - value: saves.b + value: saves.b, }, spell: { - value: saves.s - } - } + value: saves.s, + }, + }, }); } @@ -270,7 +270,7 @@ export class OseActor extends Actor { rollHitDice(options = {}) { const label = game.i18n.localize(`OSE.roll.hd`); const rollParts = [this.data.data.hp.hd]; - if (this.data.type == 'character') { + if (this.data.type == "character") { rollParts.push(this.data.data.scores.con.mod); } @@ -436,6 +436,7 @@ export class OseActor extends Actor { rollData: { type: "attack", thac0: thac0, + save: attData.save, weapon: { parts: dmgParts, }, @@ -522,7 +523,7 @@ export class OseActor extends Actor { value: totalWeight, }; - if (data.config.movementAuto && option != 'disabled') { + if (data.config.movementAuto && option != "disabled") { this._calculateMovement(); } } @@ -545,7 +546,7 @@ export class OseActor extends Actor { data.movement.base = 120; } } else if (option == "basic") { - const armors = this.data.items.filter(i => i.type == "armor"); + const armors = this.data.items.filter((i) => i.type == "armor"); let heaviest = 0; armors.forEach((a) => { if (a.data.equipped) { @@ -580,7 +581,9 @@ export class OseActor extends Actor { const data = this.data.data; // Compute treasure let total = 0; - let treasure = this.data.items.filter(i => (i.type == "item" && i.data.treasure)) + let treasure = this.data.items.filter( + (i) => i.type == "item" && i.data.treasure + ); treasure.forEach((item) => { total += item.data.quantity.value * item.data.cost; }); diff --git a/src/module/dice.js b/src/module/dice.js index 8b003bf..008214f 100644 --- a/src/module/dice.js +++ b/src/module/dice.js @@ -165,6 +165,7 @@ export class OseDice { title: title, flavor: flavor, data: data, + config: CONFIG.OSE, }; // Optionally include a situational bonus diff --git a/src/module/item/entity.js b/src/module/item/entity.js index 1fb576b..2ccdf71 100644 --- a/src/module/item/entity.js +++ b/src/module/item/entity.js @@ -4,7 +4,6 @@ import { OseDice } from "../dice.js"; * Override and extend the basic :class:`Item` implementation */ export class OseItem extends Item { - /* -------------------------------------------- */ /* Data Preparation */ /* -------------------------------------------- */ @@ -82,6 +81,7 @@ export class OseItem extends Item { this.actor.rollAttack( { type: "melee", + save: this.data.data.save, label: this.name, dmg: this.data.data.damage, bonus: data.bonus, @@ -98,6 +98,7 @@ export class OseItem extends Item { { type: "missile", label: this.name, + save: this.data.data.save, dmg: this.data.data.damage, }, options @@ -114,7 +115,13 @@ export class OseItem extends Item { type = "melee"; } this.actor.rollAttack( - { type: type, label: this.name, dmg: data.damage, bonus: data.bonus }, + { + type: type, + label: this.name, + save: data.save, + dmg: data.damage, + bonus: data.bonus, + }, options ); @@ -166,29 +173,42 @@ export class OseItem extends Item { } getTags() { - let formatTag = (tag) => { + let formatTag = (tag, icon) => { if (!tag) return ""; - return `
  • ${tag}
  • `; + let fa = ""; + if (icon) { + fa = ` `; + } + return `
  • ${fa}${tag}
  • `; }; const data = this.data.data; switch (this.data.type) { case "weapon": - let wTags = formatTag(data.damage); - data.tags.forEach(t => { + let wTags = formatTag(data.damage, "fa-tint"); + data.tags.forEach((t) => { wTags += formatTag(t.value); - }) + }); + wTags += formatTag(CONFIG.OSE.saves_long[data.save], "fa-skull"); + if (data.missile) { + wTags += formatTag( + data.range.short + "/" + data.range.medium + "/" + data.range.long, + "fa-bullseye" + ); + } return wTags; case "armor": - return `${formatTag(CONFIG.OSE.armor[data.type])}`; + return `${formatTag(CONFIG.OSE.armor[data.type], "fa-tshirt")}`; case "item": return ""; case "spell": - return `${formatTag(data.class)}${formatTag(data.range)}${formatTag( - data.duration - )}${formatTag(CONFIG.OSE.saves_long[data.save])}${formatTag( - data.roll - )}`; + let sTags = `${formatTag(data.class)}${formatTag( + data.range + )}${formatTag(data.duration)}${formatTag(data.roll)}`; + if (data.save) { + sTags += formatTag(CONFIG.OSE.saves_long[data.save], "fa-skull"); + } + return sTags; case "ability": let roll = ""; roll += data.roll ? data.roll : ""; diff --git a/src/templates/chat/roll-attack.html b/src/templates/chat/roll-attack.html index f02d53b..37a90f3 100644 --- a/src/templates/chat/roll-attack.html +++ b/src/templates/chat/roll-attack.html @@ -1,7 +1,11 @@ -
    +{{log data}} +
    + {{#if tokenId}}data-token-id="{{tokenId}}"{{/if}}>
    -

    {{title}}

    +
    +

    {{title}}

    +
    @@ -13,6 +17,13 @@
    {{localize 'OSE.messages.InflictsDamage'}}
    {{{rollDamage}}}
    + {{#if data.rollData.save}} +
    + +
    + {{/if}} {{/if}}
    -
    \ No newline at end of file + diff --git a/src/templates/items/weapon-sheet.html b/src/templates/items/weapon-sheet.html index 47c699b..ba1d40a 100644 --- a/src/templates/items/weapon-sheet.html +++ b/src/templates/items/weapon-sheet.html @@ -101,8 +101,8 @@