From 209f23b4ea0483c0b182154aee07b943ebc90709 Mon Sep 17 00:00:00 2001 From: agaringer Date: Sat, 7 Aug 2021 14:28:16 -0400 Subject: [PATCH 1/2] Fix faction sheet goal clocks --- module/blades-helpers.js | 31 +++++++++++++++++++++++++++++++ module/blades-item.js | 10 ++++++++++ module/blades-roll.js | 30 +++--------------------------- module/blades.js | 5 ++++- styles/blades.css | 7 +++++++ templates/items/faction.html | 25 +++++++++++++++++++++++-- 6 files changed, 78 insertions(+), 30 deletions(-) diff --git a/module/blades-helpers.js b/module/blades-helpers.js index 3873b3d..ebadb0e 100644 --- a/module/blades-helpers.js +++ b/module/blades-helpers.js @@ -223,4 +223,35 @@ export class BladesHelpers { /* -------------------------------------------- */ + /** + * Creates options for faction clocks. + * + * @param {int[]} sizes + * array of possible clock sizes + * @param {int} default_size + * default clock size + * @param {int} current_size + * current clock size + * @returns {string} + * html-formatted option string + */ + static createListOfClockSizes( sizes, default_size, current_size ) { + + let text = ``; + + sizes.forEach( size => { + text += ``; + }); + + return text; + + } + } diff --git a/module/blades-item.js b/module/blades-item.js index 4d1d1d7..e9ec920 100644 --- a/module/blades-item.js +++ b/module/blades-item.js @@ -65,6 +65,16 @@ export class BladesItem extends Item { this._prepareCohort(data); } + + if (item_data.type === "faction") { + if( !data.goal_1_clock_value ){ data.goal_1_clock_value = 0 } + if( data.goal_1_clock_max === 0 ){ data.goal_1_clock_max = 4 } + if( !data.goal_2_clock_value ){ data.goal_2_clock_value = 0 } + if( data.goal_2_clock_max === 0 ){ data.goal_2_clock_max = 4 } + data.size_list_1 = BladesHelpers.createListOfClockSizes( game.system.bobclocks.sizes, data.goal_1_clock_max, parseInt( data.goal_1_clock_max ) ); + data.size_list_2 = BladesHelpers.createListOfClockSizes( game.system.bobclocks.sizes, data.goal_2_clock_max, parseInt( data.goal_2_clock_max ) ); + } + } /** diff --git a/module/blades-roll.js b/module/blades-roll.js index 3eb57d3..50c0727 100644 --- a/module/blades-roll.js +++ b/module/blades-roll.js @@ -32,16 +32,8 @@ export async function bladesRoll(dice_amount, attribute_name = "", position = "r async function showChatRollMessage(r, zeromode, attribute_name = "", position = "", effect = "") { let speaker = ChatMessage.getSpeaker(); - let isBelow070 = isNewerVersion('0.7.0', game.data.version); - let rolls = []; + let rolls = (r.terms)[0].results; let attribute_label = BladesHelpers.getAttributeLabel(attribute_name); - - // Backward Compat for rolls. - if (isBelow070) { - rolls = (r.parts)[0].rolls; - } else { - rolls = (r.terms)[0].results; - } // Retrieve Roll status. let roll_status = getBladesRollStatus(rolls, zeromode); @@ -102,16 +94,8 @@ async function showChatRollMessage(r, zeromode, attribute_name = "", position = */ export function getBladesRollStatus(rolls, zeromode = false) { - // Dice API has changed in 0.7.0 so need to keep that in mind. - let isBelow070 = isNewerVersion('0.7.0', game.data.version); - - let sorted_rolls = []; // Sort roll values from lowest to highest. - if (isBelow070) { - sorted_rolls = rolls.map(i => i.roll).sort(); - } else { - sorted_rolls = rolls.map(i => i.result).sort(); - } + let sorted_rolls = rolls.map(i => i.result).sort(); let roll_status = "failure" @@ -167,16 +151,8 @@ export function getBladesRollStress(rolls, zeromode = false) { var stress = 6; - // Dice API has changed in 0.7.0 so need to keep that in mind. - let isBelow070 = isNewerVersion('0.7.0', game.data.version); - - let sorted_rolls = []; // Sort roll values from lowest to highest. - if (isBelow070) { - sorted_rolls = rolls.map(i => i.roll).sort(); - } else { - sorted_rolls = rolls.map(i => i.result).sort(); - } + let sorted_rolls = rolls.map(i => i.result).sort(); let roll_status = "failure" diff --git a/module/blades.js b/module/blades.js index 6e42653..a75114f 100644 --- a/module/blades.js +++ b/module/blades.js @@ -29,7 +29,10 @@ Hooks.once("init", async function() { game.blades = { dice: bladesRoll - } + }; + game.system.bobclocks = { + sizes: [ 4, 6, 8 ] + }; CONFIG.Item.documentClass = BladesItem; CONFIG.Actor.documentClass = BladesActor; diff --git a/styles/blades.css b/styles/blades.css index 0f91180..26e8806 100644 --- a/styles/blades.css +++ b/styles/blades.css @@ -1071,6 +1071,13 @@ * .clock-block .clocks.clocks-4 { position: relative; } +* .clock-block .clocks.clocks-4.small .blades-clock, +* .clock-block .clocks.clocks-6.small .blades-clock, +* .clock-block .clocks.clocks-8.small .blades-clock, +* .clock-block .clocks.clocks-12.small .blades-clock { + width: 100px; + height: 100px; +} * .clock-block .clocks.clocks-4 .blades-clock { position: relative; padding: 0; diff --git a/templates/items/faction.html b/templates/items/faction.html index 4240485..b0499b4 100644 --- a/templates/items/faction.html +++ b/templates/items/faction.html @@ -19,8 +19,29 @@ {{#if isGM }} - Clock {{data.goal_1_clock_max}}:
{{data.goal_1}}

- Clock {{data.goal_2_clock_max}}:
{{data.goal_2}}

+ +
+
+ {{{blades-clock "data.goal_1_clock_value" data.goal_1_clock_max data.goal_1_clock_value (concat item.id "-1")}}} +
+
+ +
+ + +
+ {{{blades-clock "data.goal_2_clock_value" data.goal_2_clock_max data.goal_2_clock_value (concat item.id "-2")}}} +
+
+ +
+ + +
From e0344b052fa0af69bc03bb9f4e5ac423460172d7 Mon Sep 17 00:00:00 2001 From: agaringer Date: Sat, 7 Aug 2021 14:37:44 -0400 Subject: [PATCH 2/2] Fix faction sheet goal clocks --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f1b7204..d0d49b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.idea/* +/blades-in-the-dark.lock