From 573c9fe23c25aeae5084570490bbaf70661409c5 Mon Sep 17 00:00:00 2001 From: U~man Date: Sat, 4 Jul 2020 22:17:23 +0200 Subject: [PATCH] FIX: Monster rolls --- src/lang/en.json | 1 + src/module/actor/actor-sheet.js | 11 ++ src/module/actor/character-sheet.js | 7 - src/module/actor/entity.js | 128 +++++++++++------- src/module/config.js | 18 ++- src/scss/actor-base.scss | 9 +- src/scss/item.scss | 80 ++++++----- src/template.json | 6 +- .../partials/character-attributes-tab.html | 2 +- .../actors/partials/character-header.html | 10 +- .../partials/monster-attributes-tab.html | 19 ++- .../actors/partials/monster-header.html | 36 ++--- src/templates/chat/item-card.html | 6 +- src/templates/items/spell-sheet.html | 15 +- 14 files changed, 205 insertions(+), 143 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 2c36ccc..e947c39 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -148,6 +148,7 @@ "OSE.spells.Class": "Class", "OSE.spells.Duration": "Duration", "OSE.spells.Level": "Level", + "OSE.spells.Save": "Save", "OSE.abilities.Requirements": "Requirements", diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index 1f5f33b..b5d81ae 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -117,6 +117,14 @@ export class OseActorSheet extends ActorSheet { item.roll(); }); + + html.find(".attack a").click(ev => { + let actorObject = this.actor; + let element = event.currentTarget; + let attack = element.parentElement.parentElement.dataset.attack; + actorObject.rollAttack(attack, { event: event }); + }); + super.activateListeners(html); } @@ -141,6 +149,9 @@ export class OseActorSheet extends ActorSheet { super._onResize(event); let html = $(event.path); let resizable = html.find(".resizable"); + if (resizable.length == 0) { + return; + } resizable.each((_, el) => { let heightDelta = this.position.height - this.options.height; el.style.height = `${heightDelta + parseInt(el.dataset.baseSize)}px`; diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 89d584a..2865fa2 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -159,13 +159,6 @@ export class OseActorSheetCharacter extends OseActorSheet { actorObject.rollExploration(expl, { event: event }); }); - html.find(".attack a").click(ev => { - let actorObject = this.actor; - let element = event.currentTarget; - let attack = element.parentElement.parentElement.dataset.attack; - actorObject.rollAttack(attack, { event: event }); - }); - html.find(".ability-score .attribute-mod a").click(ev => { let box = $(event.currentTarget.parentElement.parentElement.parentElement); box.children('.attribute-bonuses').slideDown(200); diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 3381c08..7c88118 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -1,4 +1,4 @@ -import { OseDice } from '../dice.js'; +import { OseDice } from "../dice.js"; export class OseActor extends Actor { /** @@ -8,11 +8,11 @@ export class OseActor extends Actor { prepareData() { super.prepareData(); const data = this.data.data; - + // Determine Initiative - if (game.settings.get('ose', 'individualInit')) { - data.initiative.value = data.initiative.mod ; - if (this.data.type == 'character') { + if (game.settings.get("ose", "individualInit")) { + data.initiative.value = data.initiative.mod; + if (this.data.type == "character") { const mods = this.computeModifiers(); data.initiative.value += mods.dex; } @@ -20,7 +20,7 @@ export class OseActor extends Actor { data.initiative.value = 0; } } - /* -------------------------------------------- */ + /* -------------------------------------------- */ /* Socket Listeners and Handlers /* -------------------------------------------- */ @@ -29,14 +29,17 @@ export class OseActor extends Actor { /* -------------------------------------------- */ rollSave(save, options = {}) { const label = game.i18n.localize(`OSE.saves.${save}.long`); - const rollParts = ['1d20']; + const rollParts = ["1d20"]; - const data = {...this.data, ...{ - rollData : { - type: 'Save', - stat: save - } - }}; + const data = { + ...this.data, + ...{ + rollData: { + type: "Save", + stat: save, + }, + }, + }; // Roll and return return OseDice.Roll({ @@ -44,21 +47,24 @@ export class OseActor extends Actor { parts: rollParts, data: data, speaker: ChatMessage.getSpeaker({ actor: this }), - flavor: `${label} ${game.i18n.localize('OSE.SavingThrow')}`, - title: `${label} ${game.i18n.localize('OSE.SavingThrow')}`, + flavor: `${label} ${game.i18n.localize("OSE.SavingThrow")}`, + title: `${label} ${game.i18n.localize("OSE.SavingThrow")}`, }); } rollCheck(score, options = {}) { const label = game.i18n.localize(`OSE.scores.${score}.long`); - const rollParts = ['1d20']; + const rollParts = ["1d20"]; - const data = {...this.data, ...{ - rollData : { - type: 'Check', - stat: score - } - }}; + const data = { + ...this.data, + ...{ + rollData: { + type: "Check", + stat: score, + }, + }, + }; // Roll and return return OseDice.Roll({ @@ -66,21 +72,24 @@ export class OseActor extends Actor { parts: rollParts, data: data, speaker: ChatMessage.getSpeaker({ actor: this }), - flavor: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`, - title: `${label} ${game.i18n.localize('OSE.AbilityCheck')}`, + flavor: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`, + title: `${label} ${game.i18n.localize("OSE.AbilityCheck")}`, }); } rollExploration(expl, options = {}) { const label = game.i18n.localize(`OSE.exploration.${expl}.long`); - const rollParts = ['1d6']; + const rollParts = ["1d6"]; - const data = {...this.data, ...{ - rollData : { - type: 'Exploration', - stat: expl - } - }}; + const data = { + ...this.data, + ...{ + rollData: { + type: "Exploration", + stat: expl, + }, + }, + }; // Roll and return return OseDice.Roll({ @@ -88,42 +97,45 @@ export class OseActor extends Actor { parts: rollParts, data: data, speaker: ChatMessage.getSpeaker({ actor: this }), - flavor: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`, - title: `${label} ${game.i18n.localize('OSE.ExplorationCheck')}`, + flavor: `${label} ${game.i18n.localize("OSE.ExplorationCheck")}`, + title: `${label} ${game.i18n.localize("OSE.ExplorationCheck")}`, }); } - rollAttack(attack, options={}) { + rollAttack(attack, options = {}) { const label = game.i18n.localize(`OSE.${attack}`); - const rollParts = ['1d20',]; + const rollParts = ["1d20"]; const mods = this.computeModifiers(); - if (attack == 'Missile') { + if (attack == "Missile") { rollParts.push( - '+', + "+", mods.dex.toString(), - '+', + "+", this.data.data.thac0.mod.missile.toString() ); - } else if (attack == 'Melee') { + } else if (attack == "Melee") { rollParts.push( - '+', + "+", mods.str.toString(), - '+', + "+", this.data.data.thac0.mod.melee.toString() ); } - if (game.settings.get('ose', 'ascendingAC')) { - rollParts.push('+', this.data.data.thac0.bba.toString()); + if (game.settings.get("ose", "ascendingAC")) { + rollParts.push("+", this.data.data.thac0.bba.toString()); } - const data = {...this.data, ...{ - rollData : { - type: 'Attack', - stat: attack, - mods: mods - } - }}; + const data = { + ...this.data, + ...{ + rollData: { + type: "Attack", + stat: attack, + mods: mods, + }, + }, + }; // Roll and return return OseDice.Roll({ @@ -131,12 +143,24 @@ export class OseActor extends Actor { parts: rollParts, data: data, speaker: ChatMessage.getSpeaker({ actor: this }), - flavor: `${label} ${game.i18n.localize('OSE.Attack')}`, - title: `${label} ${game.i18n.localize('OSE.Attack')}`, + flavor: `${label} ${game.i18n.localize("OSE.Attack")}`, + title: `${label} ${game.i18n.localize("OSE.Attack")}`, }); } computeModifiers() { + if (this.data.type != "character") { + return { + str: 0, + dex: 0, + int: 0, + con: 0, + wis: 0, + cha: 0, + npc: 0, + init: 0, + }; + } let _valueToMod = (val) => { switch (val) { case 3: diff --git a/src/module/config.js b/src/module/config.js index 6e37e6e..8313424 100644 --- a/src/module/config.js +++ b/src/module/config.js @@ -1 +1,17 @@ -export const OSE = {}; +export const OSE = { + scores: { + str: "OSE.scores.str.long", + int: "OSE.scores.int.long", + dex: "OSE.scores.dex.long", + wis: "OSE.scores.wis.long", + con: "OSE.scores.con.long", + cha: "OSE.scores.cha.long" + }, + saves: { + death: "OSE.saves.death.short", + wand: "OSE.saves.wand.short", + paralysis: "OSE.saves.paralysis.short", + breath: "OSE.saves.breath.short", + spell: "OSE.saves.spell.short" + } +}; \ No newline at end of file diff --git a/src/scss/actor-base.scss b/src/scss/actor-base.scss index 3c9990f..ecf4fb7 100644 --- a/src/scss/actor-base.scss +++ b/src/scss/actor-base.scss @@ -3,11 +3,6 @@ .ose.sheet.actor { $detailsHeight: 44px; - ul li { - list-style: none; - padding: 0; - } - .panel { border: 1px solid $colorDark; .panel-title { @@ -77,7 +72,8 @@ position: absolute; transform: rotate(90deg); top: 365px; - right: -169px; + right: -168px; + border-bottom: 1px solid black; width: 320px; z-index: -1; .item { @@ -103,6 +99,7 @@ padding: 5px 0; height: calc(100% - 140px); .attributes { + list-style: none; margin: 0; padding: 0; .attribute { diff --git a/src/scss/item.scss b/src/scss/item.scss index 9463920..786cb35 100644 --- a/src/scss/item.scss +++ b/src/scss/item.scss @@ -1,37 +1,47 @@ .ose.sheet.item { - .profile-img { - border: none; - flex: 0 0 84px; - height: 84px; + .profile-img { + border: none; + flex: 0 0 84px; + height: 84px; + } + .sheet-body { + .stats { + flex: 0 0 90px; + border-right: 1px groove rgba(0, 0, 0, 0.2); + padding-right: 2px; + font-size: 13px; + .form-group { + margin: 2px; + border: 1px solid rgba(0, 0, 0, 0.15); + label { + background: rgba(0, 0, 0, 0.1); + padding: 0 4px; + } + input { + border-bottom: none; + margin: auto 0; + } + } + .block-input { + display: flex; + flex-direction: column; + text-align: center; + } + &.narrow { + .form-group { + label { + } + input { + height: 18px; + } + } + } } - .sheet-body { - .stats { - flex: 0 0 90px; - border-right: 1px groove rgba(0, 0, 0, 0.2); - padding-right: 2px; - .form-group { - margin: 2px; - border: 1px solid rgba(0, 0, 0, 0.15); - label { - background: rgba(0, 0, 0, 0.1); - padding: 0 4px; - } - input { - border-bottom: none; - margin: auto 0; - } - } - .block-input { - display: flex; - flex-direction: column; - text-align: center; - } - } - .editor { - height: 240px; - } - .weapon-editor .editor { - height: 215px; - } - } -} \ No newline at end of file + .editor { + height: 240px; + } + .weapon-editor .editor { + height: 215px; + } + } +} diff --git a/src/template.json b/src/template.json index 706d0b3..778fcaa 100644 --- a/src/template.json +++ b/src/template.json @@ -38,7 +38,7 @@ "movement": { "base": 120 }, - "initative": { + "initiative": { "value": 0, "mod": 0 } @@ -132,7 +132,6 @@ "alignment": "", "xp": 0, "treasure": "", - "size": "", "appearing": "", "morale": 0 }, @@ -178,7 +177,8 @@ "roll": "", "description": "", "memorized": false, - "cast": false + "cast": false, + "save": "" }, "ability": { "requirements": "", diff --git a/src/templates/actors/partials/character-attributes-tab.html b/src/templates/actors/partials/character-attributes-tab.html index a5b1526..51bf2f6 100644 --- a/src/templates/actors/partials/character-attributes-tab.html +++ b/src/templates/actors/partials/character-attributes-tab.html @@ -131,7 +131,7 @@ {{ localize "OSE.HitDiceShort" }}
-
diff --git a/src/templates/actors/partials/character-header.html b/src/templates/actors/partials/character-header.html index b3dc32b..a522bb9 100644 --- a/src/templates/actors/partials/character-header.html +++ b/src/templates/actors/partials/character-header.html @@ -6,29 +6,29 @@