From 765e06debe2d50a856e35f5ef974a09fde124b57 Mon Sep 17 00:00:00 2001 From: U~man Date: Sat, 11 Jul 2020 19:11:19 +0200 Subject: [PATCH] ENH: Roll Loyalty --- src/module/actor/character-sheet.js | 22 ++- src/module/actor/entity.js | 133 +++++++++++++----- .../partials/character-attributes-tab.html | 4 +- 3 files changed, 112 insertions(+), 47 deletions(-) diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index e861545..6d63a6c 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -202,7 +202,7 @@ export class OseActorSheetCharacter extends OseActorSheet { let update = data[table].value.filter((el) => el != lang); console.log(update); let newData = {}; - newData[table] = {value: update}; + newData[table] = { value: update }; return this.actor.update({ data: newData }).then(() => { this.render(true); }); @@ -298,7 +298,14 @@ export class OseActorSheetCharacter extends OseActorSheet { let actorObject = this.actor; let element = event.currentTarget; let score = element.parentElement.parentElement.dataset.score; - actorObject.rollCheck(score, { event: event }); + let stat = element.parentElement.parentElement.dataset.stat; + if (!score) { + if (stat == "lr") { + actorObject.rollLoyalty(score, { event: event }); + } + } else { + actorObject.rollCheck(score, { event: event }); + } }); html.find(".exploration .attribute-name a").click((ev) => { @@ -308,17 +315,6 @@ export class OseActorSheetCharacter extends OseActorSheet { actorObject.rollExploration(expl, { event: event }); }); - html.find(".ability-score .attribute-mod a").click((ev) => { - let box = $( - event.currentTarget.parentElement.parentElement.parentElement - ); - box.children(".attribute-bonuses").slideDown(200); - }); - - html.find(".ability-score .attribute-bonuses a").click((ev) => { - $(event.currentTarget.parentElement.parentElement).slideUp(200); - }); - html.find(".inventory .item-titles .item-caret").click((ev) => { let items = $(event.currentTarget.parentElement.parentElement).children( ".item-list" diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 7c7f519..46a097a 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -118,6 +118,32 @@ export class OseActor extends Actor { }); } + rollLoyalty(options = {}) { + const label = game.i18n.localize(`OSE.Loyalty`); + const rollParts = ["2d6"]; + + const data = { + ...this.data, + ...{ + rollData: { + type: "Below", + target: this.data.data.retainer.loyalty, + }, + }, + }; + + // Roll and return + return OseDice.Roll({ + event: options.event, + parts: rollParts, + data: data, + skipDialog: true, + speaker: ChatMessage.getSpeaker({ actor: this }), + flavor: `${label} ${game.i18n.localize("OSE.Roll")}`, + title: `${label} ${game.i18n.localize("OSE.Roll")}`, + }); + } + rollReaction(options = {}) { const label = game.i18n.localize(`OSE.Reaction`); const rollParts = ["2d6"]; @@ -128,12 +154,22 @@ export class OseActor extends Actor { rollData: { type: "Table", table: { - 2: game.i18n.format("OSE.reaction.Hostile", {name: this.data.name}), - 3: game.i18n.format("OSE.reaction.Unfriendly", {name: this.data.name}), - 6: game.i18n.format("OSE.reaction.Neutral", {name: this.data.name}), - 9: game.i18n.format("OSE.reaction.Indifferent", {name: this.data.name}), - 12: game.i18n.format("OSE.reaction.Friendly", {name: this.data.name}) - } + 2: game.i18n.format("OSE.reaction.Hostile", { + name: this.data.name, + }), + 3: game.i18n.format("OSE.reaction.Unfriendly", { + name: this.data.name, + }), + 6: game.i18n.format("OSE.reaction.Neutral", { + name: this.data.name, + }), + 9: game.i18n.format("OSE.reaction.Indifferent", { + name: this.data.name, + }), + 12: game.i18n.format("OSE.reaction.Friendly", { + name: this.data.name, + }), + }, }, }, }; @@ -369,15 +405,15 @@ export class OseActor extends Actor { _isSlow() { this.data.data.isSlow = false; - if (this.data.type != 'character') { + if (this.data.type != "character") { return; } - this.data.items.forEach(item => { - if (item.type == 'weapon' && item.data.slow && item.data.equipped) { + this.data.items.forEach((item) => { + if (item.type == "weapon" && item.data.slow && item.data.equipped) { this.data.data.isSlow = true; return; } - }) + }); } computeModifiers() { @@ -393,14 +429,32 @@ export class OseActor extends Actor { 9: 0, 13: 1, 16: 2, - 18: 3 - } - data.scores.str.mod = OseActor._valueFromTable(standard, data.scores.str.value); - data.scores.int.mod = OseActor._valueFromTable(standard, data.scores.int.value); - data.scores.dex.mod = OseActor._valueFromTable(standard, data.scores.dex.value); - data.scores.cha.mod = OseActor._valueFromTable(standard, data.scores.cha.value); - data.scores.wis.mod = OseActor._valueFromTable(standard, data.scores.wis.value); - data.scores.con.mod = OseActor._valueFromTable(standard, data.scores.con.value); + 18: 3, + }; + data.scores.str.mod = OseActor._valueFromTable( + standard, + data.scores.str.value + ); + data.scores.int.mod = OseActor._valueFromTable( + standard, + data.scores.int.value + ); + data.scores.dex.mod = OseActor._valueFromTable( + standard, + data.scores.dex.value + ); + data.scores.cha.mod = OseActor._valueFromTable( + standard, + data.scores.cha.value + ); + data.scores.wis.mod = OseActor._valueFromTable( + standard, + data.scores.wis.value + ); + data.scores.con.mod = OseActor._valueFromTable( + standard, + data.scores.con.value + ); const capped = { 3: -2, @@ -409,10 +463,16 @@ export class OseActor extends Actor { 9: 0, 13: 1, 16: 1, - 18: 2 - } - data.scores.dex.init = OseActor._valueFromTable(capped, data.scores.dex.value); - data.scores.cha.npc = OseActor._valueFromTable(capped, data.scores.cha.value); + 18: 2, + }; + data.scores.dex.init = OseActor._valueFromTable( + capped, + data.scores.dex.value + ); + data.scores.cha.npc = OseActor._valueFromTable( + capped, + data.scores.cha.value + ); data.scores.cha.retain = data.scores.cha.mod + 4; data.scores.cha.loyalty = data.scores.cha.mod + 7; @@ -421,23 +481,32 @@ export class OseActor extends Actor { 9: 2, 13: 3, 16: 4, - 18: 5 - } - data.exploration.odMod = OseActor._valueFromTable(od, data.scores.str.value); - + 18: 5, + }; + data.exploration.odMod = OseActor._valueFromTable( + od, + data.scores.str.value + ); + const literacy = { 3: "OSE.Illiterate", 6: "OSE.LiteracyBasic", - 9: "OSE.Literate" - } - data.languages.literacy = OseActor._valueFromTable(literacy, data.scores.int.value) + 9: "OSE.Literate", + }; + data.languages.literacy = OseActor._valueFromTable( + literacy, + data.scores.int.value + ); const spoken = { 3: 0, 13: 2, 16: 3, - 18: 4 - } - data.languages.count = OseActor._valueFromTable(spoken, data.scores.int.value) + 18: 4, + }; + data.languages.count = OseActor._valueFromTable( + spoken, + data.scores.int.value + ); } } diff --git a/src/templates/actors/partials/character-attributes-tab.html b/src/templates/actors/partials/character-attributes-tab.html index a4fe8b3..54a6571 100644 --- a/src/templates/actors/partials/character-attributes-tab.html +++ b/src/templates/actors/partials/character-attributes-tab.html @@ -51,9 +51,9 @@ {{#if data.retainer.enabled}} -
  • +
  • - {{ localize "OSE.LoyaltyShort" }} + {{ localize "OSE.LoyaltyShort" }}