From a18cc53a6b0c112fa804be7d9860c8196a8388c0 Mon Sep 17 00:00:00 2001 From: Noel da Costa Date: Mon, 1 Mar 2021 14:54:57 +0000 Subject: [PATCH] Added a tab for setting scores manually - Added tab - Added fields for that tab - Added display for Roll tab --- GammaWorld3e/sheet.html | 2 +- GammaWorld3e/src/scss/partials/sheet.scss | 9 +- GammaWorld3e/src/sheet.html | 2945 +++++++++++++++++++++ GammaWorld3e/src/sheet.pug | 202 +- GammaWorld3e/src/sheetworkers.js | 909 ++++--- GammaWorld3e/styles.css | 7 +- 6 files changed, 3650 insertions(+), 424 deletions(-) create mode 100644 GammaWorld3e/src/sheet.html diff --git a/GammaWorld3e/sheet.html b/GammaWorld3e/sheet.html index cda4d0449c..38a94a3f2b 100644 --- a/GammaWorld3e/sheet.html +++ b/GammaWorld3e/sheet.html @@ -2580,4 +2580,4 @@ on("change:hpRollSwitch", function(args) { setAttrs(update, {silent: true}); } }); - \ No newline at end of file + diff --git a/GammaWorld3e/src/scss/partials/sheet.scss b/GammaWorld3e/src/scss/partials/sheet.scss index 9ff30128fa..de3a03cc30 100644 --- a/GammaWorld3e/src/scss/partials/sheet.scss +++ b/GammaWorld3e/src/scss/partials/sheet.scss @@ -72,14 +72,19 @@ input.sheet-pageToggle:not([value="3"]) ~ .sheet-tab3 { /********************** Roll-up ***********************/ -input.sheet-rollSwitch:not([value="0"]) ~ .sheet-pre-rolled { +input.sheet-rollSwitch[value="0"] ~ .sheet-tab-score-roll, input.sheet-rollSwitch[value="0"] ~ .sheet-tab-score-input { display:none } -input.sheet-rollSwitch:not([value="1"]) ~ .sheet-post-rolled { +input.sheet-rollSwitch[value="1"] ~ .sheet-tab-score-input { display:none } +input.sheet-rollSwitch[value="2"] ~ .sheet-tab-score-roll { + display: none; +} + + /********************** diff --git a/GammaWorld3e/src/sheet.html b/GammaWorld3e/src/sheet.html new file mode 100644 index 0000000000..c4b70c48bc --- /dev/null +++ b/GammaWorld3e/src/sheet.html @@ -0,0 +1,2945 @@ + +
+

Gamma World 3e

+ + + +
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+

Physical Abilities

+
+
+
Cur.
+
Orig.
+
Adv.
+
Tmp.
+
Mod.
+
Roll
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+

Mental Abilities

+
+
+
Cur.
+
Orig.
+
Adv.
+
Tmp.
+
Mod.
+
Roll
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+
+
+
+
+

Mutations

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+
+ y +
+
+
+ +
+
+ + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
Critical
+
+ +
+
+ +
+
+ +
+
Show description on roll + +
+
+
+
+
+
+
+
+

Attacks

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ y +
+
+
+
Type
+
+ +
+
Skill
+
+ +
+
+
+
+
+
Effect
+
+ +
+
Critical
+
+ +
+
+
+
+
+
Tech Lvl.
+
+ + +
+
Tech Rank
+
+ +
+
+
+
Add attack rank to damage + +
+
Notes
+
+ +
+
+
+
+
+
+
+

Armour

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ y +
+
+
Notes
+
+ +
+
Tech Lvl.
+
+ +
+
Tech Rank
+
+ +
+
+
+
Powered + +
+
+ + + + + + + +
+
+
+
+
Air Supply (hrs)
+
+ +
+
+
+
+
+
Sensors
+
+ +
+
+
+
+
+
+
+
No. Cells
+
+ +
+
+
+
+
+
Cells Type
+
+ +
+
+
+
+
+
Power Duration (hours)
+
+ +
+
+
+
+
+
+
+
Strength x
+
+ +
+
+
+
+
+
Speed x
+
+ +
+
+
+
+
+
Enc. x
+
+ +
+
+
+
+
+
+
Shield + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
Helmet + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+

Gear

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+

Movement

+
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
kg.
+
+
+
+

Combat Stats

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
Physical
+
+
+
+
+
+
+
+
+
+
Energy
+
+
+
+
+
+
+
+
+
+
Mental
+
+
+
+
+
+
+
+
+
+
+

Notes

+
+
+
+ +
+
+ y +
+
+
Description
+
+ +
+
+
+
+
+
+
+
+

Skills

+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ y +
+
+
Description
+
+ +
+
+
+
+
+
+
+
+

Talents

+
+
+ +
+
+
+
+
+ + +
+
+ +
+
+ y +
+
+
Description
+
+ +
+
+
+
+
+
+
+
+

Coins

+
+
+ +
+
+ +
+
+
+
Nickels
+
+ +
+
+
+
Silver Coins
+
+ +
+
+
+
Gold Coins
+
+ +
+
+
+
Domars
+
+ +
+
+
+
Dahlers
+
+ +
+
+
+
Daublers
+
+ +
+
+
+
+
+
+

Cells

+
+
+ +
+
+ +
+
+
+
Atomic
+
+ +
+
+
+
Chemical
+
+ +
+
+
+
Hydrogen
+
+ +
+
+
+
Solar
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+

+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+

Combat Stats

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
Physical
+
+
+
+
+
+
+
+
Energy
+
+
+
+
+
+
+
+
Mental
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+

Physical Abilities

+
+
+
Cur.
+
Orig.
+
Adv.
+
Tmp.
+
Mod.
+
Roll
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+

Mental Abilities

+
+
+
Cur.
+
Orig.
+
Adv.
+
Tmp.
+
Mod.
+
Roll
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+
+
+

Mutations

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ y +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+

Attacks

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ y +
+
+
+
Type
+
+ +
+
Skill
+
+ +
+
+
+
+
+
Effect
+
+ +
+
Critical
+
+ +
+
+
+
+
+
Tech Lvl.
+
+ +
+
Tech Rank
+
+ +
+
+
+
Add attack rank to damage + +
+
Notes
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+

Ability Scores

+
+ + + + +
+
+
+

Physical Abilities

+
+
+
Score
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+

Mental Abilities

+
+
+
Score
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+

Physical Abilities

+
+
+
Score
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+

Mental Abilities

+
+
+
Score
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+

Hit Points

+
+ + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GammaWorld3e/src/sheet.pug b/GammaWorld3e/src/sheet.pug index ccf3e9e237..c857f20165 100644 --- a/GammaWorld3e/src/sheet.pug +++ b/GammaWorld3e/src/sheet.pug @@ -273,19 +273,108 @@ option(value="MS") MS option(value="CH") CH .col-xs-2 - label Effort + label Targets .col-xs-2 + input(type="text" name="attr_number") + .col-xs-2 + label Effort + .col-xs-3 select(name="attr_effort") option(value="passive") Subconscious option(value="active") Conscious + .row.middle-xs .col-xs-1 - label No. - .col-xs-1 - input(type="text" name="attr_number") + label Save + .col-xs-2 + select(name="attr_save") + option(value="PS") PS + option(value="DX") DX + option(value="CN") CN + option(value="IN") IN + option(value="MS") MS + option(value="CH") CH .col-xs-2 label Duration .col-xs-2 input(type="text" name="attr_duration") + .row.middle-xs + .col-xs-1 + label Effect + .col-xs-2 + select(name="attr_effect" value=0) + option(value=0) None + option(value="accrit") AC Critical + option(value="burn") Burn + option(value="cold") Cold + option(value="compa") Comp. A + option(value="compc") Comp. C + option(value="critical") Critical + option(value="delirium") Delirium + option(value="disintegrate") Disintegrate + option(value="domination") Domination + option(value="electrical") Electrical + option(value="fatal") Fatal + option(value="fieldnegate") Field Negate + option(value="fumes") Fumes + option(value="heat") Heat + option(value="extrarf") Hits +1RF + option(value="ignites") Ignites + option(value="ignoresac") Ignores AC + option(value="intercept") Intercept + option(value="irritant") Irritant + option(value="knockdown") Knock Down + option(value="ko") Knock Out + option(value="mutate") Mutate + option(value="paralysis") Paralysis + option(value="poison") Poison + option(value="powerdrain") Power Drain + option(value="radiation") Radiation + option(value="scatter") Scatter + option(value="seeker") Seeker + option(value="shortout") Short Out + option(value="slam") Slam + option(value="sonic") Sonic + option(value="stun") Stun + option(value="subsonics") Subsonics + option(value="tangle") Tangle + .col-xs-2 Critical + .col-xs-2 + select(name="attr_effect_crit" value=0) + option(value=0) None + option(value="accrit") AC Critical + option(value="burn") Burn + option(value="cold") Cold + option(value="compa") Comp. A + option(value="compc") Comp. C + option(value="critical") Critical + option(value="delirium") Delirium + option(value="disintegrate") Disintegrate + option(value="domination") Domination + option(value="electrical") Electrical + option(value="fatal") Fatal + option(value="fieldnegate") Field Negate + option(value="fumes") Fumes + option(value="heat") Heat + option(value="extrarf") Hits +1 RF + option(value="ignites") Ignites + option(value="ignoresac") Ignores AC + option(value="intercept") Intercept + option(value="irritant") Irritant + option(value="knockdown") Knock Down + option(value="ko") Knock Out + option(value="mutate") Mutate + option(value="paralysis") Paralysis + option(value="poison") Poison + option(value="powerdrain") Power Drain + option(value="radiation") Radiation + option(value="scatter") Scatter + option(value="seeker") Seeker + option(value="shortout") Short Out + option(value="slam") Slam + option(value="sonic") Sonic + option(value="stun") Stun + option(value="subsonics") Subsonics + option(value="tangle") Tangle .col-xs-12 label Description .col-xs-12 @@ -1354,18 +1443,119 @@ label Description .col-xs-12 textarea(name="attr_description") - .tab3 .sheet-container h2 Ability Scores div.panel - input.short.rollSwitch(type="hidden" value="0") label.tab input.short.rollSwitch(type="radio" value="0" name="attr_rollSwitch") span Reset label.tab input.short.rollSwitch(type="radio" value="1" name="attr_rollSwitch") span Roll + label.tab + input.short.rollSwitch(type="radio" value="2" name="attr_rollSwitch") + span Input + input.rollSwitch(type="hidden" name="attr_rollSwitch" value="2") + .tab-score-roll + .row + .col-xs-6 + h2 Physical Abilities + .row + .col-xs-1 + .col-xs-2(title="Initially Rolled Score") Score + .row.middle-xs + .col-xs-1 + label.ability PS + .col-xs-1 + span(name="attr_PS_rolled") + .row.middle-xs + .col-xs-1 + label.ability DX + .col-xs-1 + span(name="attr_DX_rolled") + .row.middle-xs + .col-xs-1 + label.ability CN + .col-xs-1 + span(name="attr_CN_rolled") + + .col-xs-6.post + h2 Mental Abilities + .row + .col-xs-1 + .col-xs-2(title="Initially Rolled Score") Score + .row.middle-xs + .col-xs-1 + label.ability IN + .col-xs-1 + span(name="attr_IN_rolled") + .row.middle-xs + .col-xs-1 + label.ability MS + .col-xs-1 + span(name="attr_MS_rolled") + .row.middle-xs + .col-xs-1 + label.ability CH + .col-xs-1 + span(name="attr_CH_rolled") + .tab-score-input + .row + .col-xs-6 + h2 Physical Abilities + .row + .col-xs-1 + .col-xs-2(title="Initially Rolled Score") Score + .row.middle-xs + .col-xs-1 + label.ability PS + .col-xs-1 + input.tab4(type="text" name="attr_PS_rolled" title="@{PS_rolled}") + .col-xs-1 + span(name="attr_PS_rolled") + .row.middle-xs + .col-xs-1 + label.ability DX + .col-xs-2 + input.tab4(type="text" name="attr_DX_rolled" title="@{DX_rolled}") + .col-xs-1 + span(name="attr_DX_rolled") + .row.middle-xs + .col-xs-1 + label.ability CN + .col-xs-2 + input.tab4(type="text" name="attr_CN_rolled" title="@{CN_rolled}") + .col-xs-1 + span(name="attr_CN_rolled") + + .col-xs-6.post + h2 Mental Abilities + .row + .col-xs-1 + .col-xs-2(title="Initially Rolled Score") Score + .row.middle-xs + .col-xs-1 + label.ability IN + .col-xs-2 + input.tab4(type="text" name="attr_IN_rolled" title="@{IN_rolled}") + .col-xs-1 + span(name="attr_IN_rolled") + .row.middle-xs + .col-xs-1 + label.ability MS + .col-xs-2 + input.tab4(type="text" name="attr_MS_rolled" title="@{MS_rolled}") + .col-xs-1 + span(name="attr_MS_rolled") + .row.middle-xs + .col-xs-1 + label.ability CH + .col-xs-2 + input.tab4(type="text" name="attr_CH_rolled" title="@{CH_rolled}") + .col-xs-1 + span(name="attr_CH_rolled") + h2 Hit Points div.panel input.short.hpRollSwitch(type="hidden" value="0") diff --git a/GammaWorld3e/src/sheetworkers.js b/GammaWorld3e/src/sheetworkers.js index de717db54f..de9043be1f 100644 --- a/GammaWorld3e/src/sheetworkers.js +++ b/GammaWorld3e/src/sheetworkers.js @@ -1,496 +1,579 @@ - //------ Functions --------- -const update_ability = function(name) { - console.log('update_ability: '+name); - let update = {}; - getAttrs([name+'_rolled', name+'_advanced', name+'_tmp'], (v) => { - console.log(v); - update[name] = (parseInt(v[name+'_rolled']) || 0 ) + (parseInt(v[name+'_advanced']) || 0 ) + (parseInt(v[name+'_tmp']) || 0 ); - console.log(update); - setAttrs(update, {silent: false}); - }); +const update_ability = function (name) { + console.log("update_ability: " + name); + let update = {}; + getAttrs([name + "_rolled", name + "_advanced", name + "_tmp"], (v) => { + console.log(v); + update[name] = + (parseInt(v[name + "_rolled"]) || 0) + + (parseInt(v[name + "_advanced"]) || 0) + + (parseInt(v[name + "_tmp"]) || 0); + console.log(update); + setAttrs(update, { silent: false }); + }); }; // @todo: this should probably just pick up equipped shields, rather than having a specific shield setting. -const getShieldCS = function(shield_size, shield_material) { - console.log('getShieldCS'); - console.log(shield_size); - console.log(shield_material); - let CS_physical = 0, CS_energy = 0, CS_mental = 0; - - CS_physical = - parseInt(shield_size) > 2 ? -2 : - parseInt(shield_size) > 1 ? -1 : - 0; - - CS_physical = - parseInt(shield_material) === 1 ? CS_physical : - parseInt(shield_material) === 2 ? CS_physical : - parseInt(shield_material) === 3 ? CS_physical-1 : - parseInt(shield_material) === 4 ? CS_physical-1 : - parseInt(shield_material) === 5 ? CS_physical-2 : - parseInt(shield_material) === 6 ? CS_physical : - CS_physical; - CS_energy = parseInt(shield_material) === 6 ? CS_physical -3 : CS_physical; - return {CS_physical, CS_energy, CS_mental}; +const getShieldCS = function (shield_size, shield_material) { + console.log("getShieldCS"); + console.log(shield_size); + console.log(shield_material); + let CS_physical = 0, + CS_energy = 0, + CS_mental = 0; + + CS_physical = + parseInt(shield_size) > 2 ? -2 : parseInt(shield_size) > 1 ? -1 : 0; + + CS_physical = + parseInt(shield_material) === 1 + ? CS_physical + : parseInt(shield_material) === 2 + ? CS_physical + : parseInt(shield_material) === 3 + ? CS_physical - 1 + : parseInt(shield_material) === 4 + ? CS_physical - 1 + : parseInt(shield_material) === 5 + ? CS_physical - 2 + : parseInt(shield_material) === 6 + ? CS_physical + : CS_physical; + CS_energy = parseInt(shield_material) === 6 ? CS_physical - 3 : CS_physical; + return { CS_physical, CS_energy, CS_mental }; }; -const update_ac = function() { - console.log('update_ac'); - let update = {}; - let dr_total = 0; - let ac_total = 0; - let count = 0; - let enc_attrs = ['shield_CS']; +const update_ac = function () { + console.log("update_ac"); + let update = {}; + let dr_total = 0; + let ac_total = 0; + let count = 0; + let enc_attrs = ["shield_CS"]; + getSectionIDs("repeating_armour", (armourIds) => { + _.each(armourIds, (currentID, i) => { + enc_attrs.push(`repeating_armour_${currentID}_weight`); + enc_attrs.push(`repeating_armour_${currentID}_count`); + enc_attrs.push(`repeating_armour_${currentID}_equipped`); + }); + getAttrs(enc_attrs, (v) => {}); + }); +}; + +const update_enc = function () { + console.log("update_enc"); + let update = {}; + let wtotal = 0; + let DR_physical = 0; + let DR_energy = 0; + let CS = {}; + let RFtotal = 0; + let CS_physical = 0; + let CS_mental = 0; + let CS_energy = 0; + let count = 0; + let PSfactor = 1; + let spdfactor = 1; + let enc_attrs = [ + "DR_physical", + "DR_energy", + "coin_gp", + "coin_nk", + "coin_sp", + "coin_dm", + "PS", + "PS_rolled", + "PS_advanced", + "PS_tmp", + "encumbrance", + "encumbrance_max", + "speed", + "speed_max", + "burden", + "burden_max", + ]; + getSectionIDs("repeating_gear", (gearIds) => { + _.each(gearIds, (currentID, i) => { + enc_attrs.push(`repeating_gear_${currentID}_weight`); + enc_attrs.push(`repeating_gear_${currentID}_count`); + enc_attrs.push(`repeating_gear_${currentID}_equipped`); + }); + getSectionIDs("repeating_armour", (armourIds) => { - _.each(armourIds, (currentID, i) => { - enc_attrs.push(`repeating_armour_${currentID}_weight`); - enc_attrs.push(`repeating_armour_${currentID}_count`); - enc_attrs.push(`repeating_armour_${currentID}_equipped`); - }); - getAttrs(enc_attrs, (v) => { - - }) - }); -}; - -const update_enc = function() { - console.log('update_enc'); - let update = {}; - let wtotal = 0; - let DR_physical = 0; - let DR_energy = 0; - let CS = {}; - let RFtotal = 0; - let CS_physical = 0; - let CS_mental = 0; - let CS_energy = 0; - let count = 0; - let PSfactor = 1; - let spdfactor = 1; - let enc_attrs = ['DR_physical', 'DR_energy', 'coin_gp', 'coin_nk', 'coin_sp', 'coin_dm', 'PS', 'PS_rolled', 'PS_advanced', 'PS_tmp', 'encumbrance', 'encumbrance_max', 'speed', 'speed_max', 'burden', 'burden_max']; - getSectionIDs("repeating_gear", (gearIds) => { - _.each(gearIds, (currentID, i) => { - enc_attrs.push(`repeating_gear_${currentID}_weight`); - enc_attrs.push(`repeating_gear_${currentID}_count`); - enc_attrs.push(`repeating_gear_${currentID}_equipped`); - }); - - getSectionIDs("repeating_armour", (armourIds) => { - _.each(armourIds, (currentID, i) => { - enc_attrs.push(`repeating_armour_${currentID}_weight`); - enc_attrs.push(`repeating_armour_${currentID}_count`); - enc_attrs.push(`repeating_armour_${currentID}_equipped`); - enc_attrs.push(`repeating_armour_${currentID}_powered`); - enc_attrs.push(`repeating_armour_${currentID}_enc_factor`); - enc_attrs.push(`repeating_armour_${currentID}_spd_factor`); - enc_attrs.push(`repeating_armour_${currentID}_PS_factor`); - enc_attrs.push(`repeating_armour_${currentID}_shield_size`); - enc_attrs.push(`repeating_armour_${currentID}_shield_material`); - enc_attrs.push(`repeating_armour_${currentID}_CS_mental`); - enc_attrs.push(`repeating_armour_${currentID}_DR_energy`); - enc_attrs.push(`repeating_armour_${currentID}_DR_physical`); - enc_attrs.push(`repeating_armour_${currentID}_RF_physical`); - }); - getAttrs(enc_attrs, (v) => { - - console.log(v); - if (v["speed_max"] === undefined) { - v["speed_max"] = v['speed']; - update["speed_max"] = v['speed']; - } - ["coin_gp", "coin_sp", "coin_nk", "coin_dm"].forEach((type)=> { - let coinweight = (isNaN(parseInt(v[`${type}`], 10)) === false) ? parseInt(v[`${type}`], 10) : 0; - // use roughly correct weights for different materials as per g/cm3 - if(type === 'coin_gp') { - wtotal += coinweight / 100 - } - if(type === 'coin_sp') { - wtotal += coinweight / 200 - } - if(type === 'coin_nk') { - wtotal += coinweight / 250 - } - if(type === 'coin_dm') { - wtotal += coinweight / 1000 - } - if(type === 'coin_dl') { - wtotal += coinweight / 1000 - } - if(type === 'coin_db') { - wtotal += coinweight / 1000 - } - }); - - _.each(gearIds, (currentID, i) => { - if ( - v[`repeating_gear_${currentID}_weight`] - && v[`repeating_gear_${currentID}_equipped`] === '1' - && isNaN(parseInt(v[`repeating_gear_${currentID}_weight`], 10)) === false) - { - count = v[`repeating_gear_${currentID}_count`] && isNaN(parseFloat(v[`repeating_gear_${currentID}_count`])) === false ? parseFloat(v[`repeating_gear_${currentID}_count`]) : 1; - wtotal = wtotal + (parseFloat(v[`repeating_gear_${currentID}_weight`]) * count); - } - }); - - _.each(armourIds, (currentID, i) => { - if ( - v[`repeating_armour_${currentID}_weight`] - && v[`repeating_armour_${currentID}_equipped`] === '1' - && isNaN(parseInt(v[`repeating_armour_${currentID}_weight`], 10)) === false) - { - count = v[`repeating_armour_${currentID}_count`] && isNaN(parseFloat(v[`repeating_armour_${currentID}_count`])) === false ? parseFloat(v[`repeating_armour_${currentID}_count`]) : 1; - wtotal = wtotal + (parseFloat(v[`repeating_armour_${currentID}_weight`]) * count * (isNaN(parseFloat(v[`repeating_armour_${currentID}_enc_factor`])) === false ? parseFloat(v[`repeating_armour_${currentID}_enc_factor`]) : 0.5)); - PSfactor - = isNaN(parseFloat(v[`repeating_armour_${currentID}_PS_factor`])) === false - ? (v[`repeating_armour_${currentID}_PS_factor`] > PSfactor ? v[`repeating_armour_${currentID}_PS_factor`] : PSfactor) - : PSfactor; - spdfactor - = isNaN(parseFloat(v[`repeating_armour_${currentID}_spd_factor`])) === false - ? (v[`repeating_armour_${currentID}_spd_factor`] > spdfactor ? v[`repeating_armour_${currentID}_spd_factor`] : spdfactor) - : spdfactor; - } - // update DR_physical - if ( - v[`repeating_armour_${currentID}_DR_physical`] - && v[`repeating_armour_${currentID}_equipped`] === '1' - && isNaN(parseInt(v[`repeating_armour_${currentID}_DR_physical`], 10)) === false - ) { - DR_physical += parseInt(v[`repeating_armour_${currentID}_DR_physical`]); - } - // update DR_energy - console.log('DR_energy: ', v[`repeating_armour_${currentID}_DR_energy`]); - if ( - v[`repeating_armour_${currentID}_DR_energy`] !== undefined - && v[`repeating_armour_${currentID}_equipped`] === '1' - && isNaN(parseInt(v[`repeating_armour_${currentID}_DR_energy`], 10)) === false - ) { - DR_energy += parseInt(v[`repeating_armour_${currentID}_DR_energy`]); - } else { - DR_energy += DR_physical; - } - - // update CS - if ( - v[`repeating_armour_${currentID}_shield_size`] - && v[`repeating_armour_${currentID}_shield_material`] - && v[`repeating_armour_${currentID}_equipped`] === '1' - ) { - CS = getShieldCS(v[`repeating_armour_${currentID}_shield_size`], v[`repeating_armour_${currentID}_shield_material`] ); - CS_physical += CS.CS_physical; - CS_mental += CS.CS_mental; - CS_energy += CS.CS_energy; - } - if ( - v[`repeating_armour_${currentID}_CS_mental`] - && v[`repeating_armour_${currentID}_equipped`] === '1' - ) { - console.log('HELMET: '+v[`repeating_armour_${currentID}_CS_mental`] ) - CS_mental += parseInt(v[`repeating_armour_${currentID}_CS_mental`]) ; - } - - // update RF - if ( - v[`repeating_armour_${currentID}_RF_physical`] - && v[`repeating_armour_${currentID}_equipped`] === '1' - && isNaN(parseInt(v[`repeating_armour_${currentID}_RF_physical`], 10)) === false - ) { - RFtotal += parseInt(v[`repeating_armour_${currentID}_RF_physical`]); - console.log(CS_physical); - } - }); - // console.log(CS_physical); - update["RF_physical"] = RFtotal; - update["RF_energy"] = RFtotal; - update["CS_physical"] = CS_physical; - update["CS_energy"] = CS_energy; - update["CS_mental"] = CS_mental; - update["DR_physical"] = DR_physical; - update["DR_energy"] = DR_energy; - update["encumbrance"] = Math.round(wtotal * 10) / 10; - let PS = (parseInt(v["PS_rolled"]) - + parseInt(v["PS_advanced"]) - + parseInt(v["PS_tmp"])) * PSfactor; - update['PS'] = PS; - update["burden"] = - (wtotal > PS*5) ? "Crushing Weight" : - (wtotal > PS*3) ? "Immobile" : - (wtotal > PS*2) ? "Heavily Burdened" : - (wtotal > PS*1) ? "Burdened" : - "Normal"; - update["speed"] = - (wtotal > PS*3) ? 0 : - (wtotal > PS*2) ? Math.floor((parseInt(v["speed_max"]) / 3)) : - (wtotal > PS*1) ? Math.floor((parseInt(v["speed_max"]) /3)*2) : - parseInt(v["speed_max"]) * spdfactor; - console.log(update); - setAttrs(update, {silent: true}); - update_mod('PS'); - }); - }); - }); -}; - -const update_mod = function(ability) { - console.log('update_mod: '+ability); - let update = {}; - let mod = 6; - let total = 0; - let ps_attrs = [ability]; - getAttrs(ps_attrs, (v) => { + _.each(armourIds, (currentID, i) => { + enc_attrs.push(`repeating_armour_${currentID}_weight`); + enc_attrs.push(`repeating_armour_${currentID}_count`); + enc_attrs.push(`repeating_armour_${currentID}_equipped`); + enc_attrs.push(`repeating_armour_${currentID}_powered`); + enc_attrs.push(`repeating_armour_${currentID}_enc_factor`); + enc_attrs.push(`repeating_armour_${currentID}_spd_factor`); + enc_attrs.push(`repeating_armour_${currentID}_PS_factor`); + enc_attrs.push(`repeating_armour_${currentID}_shield_size`); + enc_attrs.push(`repeating_armour_${currentID}_shield_material`); + enc_attrs.push(`repeating_armour_${currentID}_CS_mental`); + enc_attrs.push(`repeating_armour_${currentID}_DR_energy`); + enc_attrs.push(`repeating_armour_${currentID}_DR_physical`); + enc_attrs.push(`repeating_armour_${currentID}_RF_physical`); + }); + getAttrs(enc_attrs, (v) => { console.log(v); - console.log(v[ability]); - total += parseInt(v[ability]); - if(total < 601) { - mod = 5; + if (v["speed_max"] === undefined) { + v["speed_max"] = v["speed"]; + update["speed_max"] = v["speed"]; } - if(total < 121) { - mod = 4; - } - if(total < 22) { - mod = 3; - } - if(total < 19) { - mod = 2; - } - if(total < 16) { - mod = 1; - } - if(total < 12) { - mod = 0; - } - if(total < 10) { - mod = -1; - } - if(total < 7) { - mod = -2; - } - if(total < 4) { - mod = -3; - } - if(total < 0) { - mod = -4; - } - if(total < -6) { - mod = -5; - } - if(total < -26) { - mod = -6; - } - update[ability+'_modifier'] = mod; - setAttrs(update, {silent: true}); + ["coin_gp", "coin_sp", "coin_nk", "coin_dm"].forEach((type) => { + let coinweight = + isNaN(parseInt(v[`${type}`], 10)) === false + ? parseInt(v[`${type}`], 10) + : 0; + // use roughly correct weights for different materials as per g/cm3 + if (type === "coin_gp") { + wtotal += coinweight / 100; + } + if (type === "coin_sp") { + wtotal += coinweight / 200; + } + if (type === "coin_nk") { + wtotal += coinweight / 250; + } + if (type === "coin_dm") { + wtotal += coinweight / 1000; + } + if (type === "coin_dl") { + wtotal += coinweight / 1000; + } + if (type === "coin_db") { + wtotal += coinweight / 1000; + } + }); + + _.each(gearIds, (currentID, i) => { + if ( + v[`repeating_gear_${currentID}_weight`] && + v[`repeating_gear_${currentID}_equipped`] === "1" && + isNaN(parseInt(v[`repeating_gear_${currentID}_weight`], 10)) === + false + ) { + count = + v[`repeating_gear_${currentID}_count`] && + isNaN(parseFloat(v[`repeating_gear_${currentID}_count`])) === + false + ? parseFloat(v[`repeating_gear_${currentID}_count`]) + : 1; + wtotal = + wtotal + + parseFloat(v[`repeating_gear_${currentID}_weight`]) * count; + } + }); + + _.each(armourIds, (currentID, i) => { + if ( + v[`repeating_armour_${currentID}_weight`] && + v[`repeating_armour_${currentID}_equipped`] === "1" && + isNaN(parseInt(v[`repeating_armour_${currentID}_weight`], 10)) === + false + ) { + count = + v[`repeating_armour_${currentID}_count`] && + isNaN(parseFloat(v[`repeating_armour_${currentID}_count`])) === + false + ? parseFloat(v[`repeating_armour_${currentID}_count`]) + : 1; + wtotal = + wtotal + + parseFloat(v[`repeating_armour_${currentID}_weight`]) * + count * + (isNaN( + parseFloat(v[`repeating_armour_${currentID}_enc_factor`]) + ) === false + ? parseFloat(v[`repeating_armour_${currentID}_enc_factor`]) + : 0.5); + PSfactor = + isNaN( + parseFloat(v[`repeating_armour_${currentID}_PS_factor`]) + ) === false + ? v[`repeating_armour_${currentID}_PS_factor`] > PSfactor + ? v[`repeating_armour_${currentID}_PS_factor`] + : PSfactor + : PSfactor; + spdfactor = + isNaN( + parseFloat(v[`repeating_armour_${currentID}_spd_factor`]) + ) === false + ? v[`repeating_armour_${currentID}_spd_factor`] > spdfactor + ? v[`repeating_armour_${currentID}_spd_factor`] + : spdfactor + : spdfactor; + } + // update DR_physical + if ( + v[`repeating_armour_${currentID}_DR_physical`] && + v[`repeating_armour_${currentID}_equipped`] === "1" && + isNaN( + parseInt(v[`repeating_armour_${currentID}_DR_physical`], 10) + ) === false + ) { + DR_physical += parseInt( + v[`repeating_armour_${currentID}_DR_physical`] + ); + } + // update DR_energy + console.log( + "DR_energy: ", + v[`repeating_armour_${currentID}_DR_energy`] + ); + if ( + v[`repeating_armour_${currentID}_DR_energy`] !== undefined && + v[`repeating_armour_${currentID}_equipped`] === "1" && + isNaN( + parseInt(v[`repeating_armour_${currentID}_DR_energy`], 10) + ) === false + ) { + DR_energy += parseInt(v[`repeating_armour_${currentID}_DR_energy`]); + } else { + DR_energy += DR_physical; + } + + // update CS + if ( + v[`repeating_armour_${currentID}_shield_size`] && + v[`repeating_armour_${currentID}_shield_material`] && + v[`repeating_armour_${currentID}_equipped`] === "1" + ) { + CS = getShieldCS( + v[`repeating_armour_${currentID}_shield_size`], + v[`repeating_armour_${currentID}_shield_material`] + ); + CS_physical += CS.CS_physical; + CS_mental += CS.CS_mental; + CS_energy += CS.CS_energy; + } + if ( + v[`repeating_armour_${currentID}_CS_mental`] && + v[`repeating_armour_${currentID}_equipped`] === "1" + ) { + console.log( + "HELMET: " + v[`repeating_armour_${currentID}_CS_mental`] + ); + CS_mental += parseInt(v[`repeating_armour_${currentID}_CS_mental`]); + } + + // update RF + if ( + v[`repeating_armour_${currentID}_RF_physical`] && + v[`repeating_armour_${currentID}_equipped`] === "1" && + isNaN( + parseInt(v[`repeating_armour_${currentID}_RF_physical`], 10) + ) === false + ) { + RFtotal += parseInt(v[`repeating_armour_${currentID}_RF_physical`]); + console.log(CS_physical); + } + }); + // console.log(CS_physical); + update["RF_physical"] = RFtotal; + update["RF_energy"] = RFtotal; + update["CS_physical"] = CS_physical; + update["CS_energy"] = CS_energy; + update["CS_mental"] = CS_mental; + update["DR_physical"] = DR_physical; + update["DR_energy"] = DR_energy; + update["encumbrance"] = Math.round(wtotal * 10) / 10; + let PS = + (parseInt(v["PS_rolled"]) + + parseInt(v["PS_advanced"]) + + parseInt(v["PS_tmp"])) * + PSfactor; + update["PS"] = PS; + update["burden"] = + wtotal > PS * 5 + ? "Crushing Weight" + : wtotal > PS * 3 + ? "Immobile" + : wtotal > PS * 2 + ? "Heavily Burdened" + : wtotal > PS * 1 + ? "Burdened" + : "Normal"; + update["speed"] = + wtotal > PS * 3 + ? 0 + : wtotal > PS * 2 + ? Math.floor(parseInt(v["speed_max"]) / 3) + : wtotal > PS * 1 + ? Math.floor((parseInt(v["speed_max"]) / 3) * 2) + : parseInt(v["speed_max"]) * spdfactor; + console.log(update); + setAttrs(update, { silent: true }); + update_mod("PS"); + }); }); + }); }; - +const update_mod = function (ability) { + console.log("update_mod: " + ability); + let update = {}; + let mod = 6; + let total = 0; + let ps_attrs = [ability]; + getAttrs(ps_attrs, (v) => { + console.log(v); + console.log(v[ability]); + total += parseInt(v[ability]); + if (total < 601) { + mod = 5; + } + if (total < 121) { + mod = 4; + } + if (total < 22) { + mod = 3; + } + if (total < 19) { + mod = 2; + } + if (total < 16) { + mod = 1; + } + if (total < 12) { + mod = 0; + } + if (total < 10) { + mod = -1; + } + if (total < 7) { + mod = -2; + } + if (total < 4) { + mod = -3; + } + if (total < 0) { + mod = -4; + } + if (total < -6) { + mod = -5; + } + if (total < -26) { + mod = -6; + } + update[ability + "_modifier"] = mod; + setAttrs(update, { silent: true }); + }); +}; //------ Events --------- -on("sheet:opened", function(eventinfo) { - console.log('sheet:opened'); +on("sheet:opened", function (eventinfo) { + console.log("sheet:opened"); }); -on("change:import", function(args) { - console.log('sheet:import',args); - +on("change:import", function (args) { + console.log("sheet:import", args); }); -on("change:PS_rolled", function(args) { - console.log('change:PS_rolled') - update_ability('PS'); +on("change:PS_rolled", function (args) { + console.log("change:PS_rolled"); + update_ability("PS"); }); -on("change:PS_advanced", function(args) { - console.log('change:PS_advanced') - update_ability('PS'); +on("change:PS_advanced", function (args) { + console.log("change:PS_advanced"); + update_ability("PS"); }); -on("change:PS_tmp", function(args) { - console.log('change:PS_tmp') - update_ability('PS'); +on("change:PS_tmp", function (args) { + console.log("change:PS_tmp"); + update_ability("PS"); }); -on("change:PS", function(args) { - console.log('PS changed'); - update_mod('PS'); - update_enc(); +on("change:PS", function (args) { + console.log("PS changed"); + update_mod("PS"); + update_enc(); }); -on("change:DX_rolled", function(args) { - console.log('change:DX_rolled') - update_ability('DX'); +on("change:DX_rolled", function (args) { + console.log("change:DX_rolled"); + update_ability("DX"); }); -on("change:DX_advanced", function(args) { - console.log('change:DX_advanced') - update_ability('DX'); +on("change:DX_advanced", function (args) { + console.log("change:DX_advanced"); + update_ability("DX"); }); -on("change:DX_tmp", function(args) { - console.log('change:DX_tmp') - update_ability('DX'); +on("change:DX_tmp", function (args) { + console.log("change:DX_tmp"); + update_ability("DX"); }); -on("change:DX", function(args) { - console.log('DX changed'); - update_mod('DX'); +on("change:DX", function (args) { + console.log("DX changed"); + update_mod("DX"); }); -on("change:CN_rolled", function(args) { - console.log('change:CN_rolled') - update_ability('CN'); +on("change:CN_rolled", function (args) { + console.log("change:CN_rolled"); + update_ability("CN"); }); -on("change:CN_advanced", function(args) { - console.log('change:CN_advanced') - update_ability('CN'); +on("change:CN_advanced", function (args) { + console.log("change:CN_advanced"); + update_ability("CN"); }); -on("change:CN_tmp", function(args) { - console.log('change:CN_tmp') - update_ability('CN'); +on("change:CN_tmp", function (args) { + console.log("change:CN_tmp"); + update_ability("CN"); }); -on("change:CN", function(args) { - console.log('CN changed'); - update_mod('CN'); +on("change:CN", function (args) { + console.log("CN changed"); + update_mod("CN"); }); -on("change:IN_rolled", function(args) { - console.log('change:IN_rolled') - update_ability('IN'); +on("change:IN_rolled", function (args) { + console.log("change:IN_rolled"); + update_ability("IN"); }); -on("change:IN_advanced", function(args) { - console.log('change:IN_advanced') - update_ability('IN'); +on("change:IN_advanced", function (args) { + console.log("change:IN_advanced"); + update_ability("IN"); }); -on("change:IN_tmp", function(args) { - console.log('change:IN_tmp') - update_ability('IN'); +on("change:IN_tmp", function (args) { + console.log("change:IN_tmp"); + update_ability("IN"); }); -on("change:IN", function(args) { - console.log('IN changed'); - update_mod('IN'); +on("change:IN", function (args) { + console.log("IN changed"); + update_mod("IN"); }); -on("change:MS_rolled", function(args) { - console.log('change:MS_rolled') - update_ability('MS'); +on("change:MS_rolled", function (args) { + console.log("change:MS_rolled"); + update_ability("MS"); }); -on("change:MS_advanced", function(args) { - console.log('change:MS_advanced') - update_ability('MS'); +on("change:MS_advanced", function (args) { + console.log("change:MS_advanced"); + update_ability("MS"); }); -on("change:MS_tmp", function(args) { - console.log('change:MS_tmp') - update_ability('MS'); +on("change:MS_tmp", function (args) { + console.log("change:MS_tmp"); + update_ability("MS"); }); -on("change:MS", function(args) { - console.log('MS changed'); - update_mod('MS'); +on("change:MS", function (args) { + console.log("MS changed"); + update_mod("MS"); }); -on("change:CH_rolled", function(args) { - console.log('change:CH_rolled') - update_ability('CH'); +on("change:CH_rolled", function (args) { + console.log("change:CH_rolled"); + update_ability("CH"); }); -on("change:CH_advanced", function(args) { - console.log('change:CH_advanced') - update_ability('CH'); +on("change:CH_advanced", function (args) { + console.log("change:CH_advanced"); + update_ability("CH"); }); -on("change:CH_tmp", function(args) { - console.log('change:CH_tmp') - update_ability('CH'); +on("change:CH_tmp", function (args) { + console.log("change:CH_tmp"); + update_ability("CH"); }); -on("change:CH", function(args) { - console.log('CH changed'); - update_mod('CH'); +on("change:CH", function (args) { + console.log("CH changed"); + update_mod("CH"); }); -on("change:repeating_gear", function(args) { - update_enc(); +on("change:repeating_gear", function (args) { + update_enc(); }); -on("change:repeating_armour", function(args) { - console.log('change:repeating_armour'); - update_enc(); - // update_ac(); +on("change:repeating_armour", function (args) { + console.log("change:repeating_armour"); + update_enc(); + // update_ac(); }); -on("change:coin_gp", function(args) { - update_enc(); +on("change:coin_gp", function (args) { + update_enc(); }); -on("change:coin_nk", function(args) { - update_enc(); +on("change:coin_nk", function (args) { + update_enc(); }); -on("change:coin_dm", function(args) { - update_enc(); +on("change:coin_dm", function (args) { + update_enc(); }); -on("change:coin_sp", function(args) { - update_enc(); +on("change:coin_sp", function (args) { + update_enc(); }); -on("change:rollSwitch", function(args) { - console.log(args); - let update = {}; - if(args.newValue == "0") { - update['PS_rolled'] = 0; - update['IN_rolled'] = 0; - update['CN_rolled'] = 0; - update['IN_rolled'] = 0; - update['MS_rolled'] = 0; - update['CH_rolled'] = 0; - } else { - update['PS_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - update['DX_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - update['CN_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - update['IN_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - update['MS_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - update['CH_rolled'] = dices.roll('4d6', {dropLowest: 1}).total; - } - setAttrs(update, {silent: true}); - - update_ability('PS'); - update_ability('DX'); - update_ability('CN'); - update_ability('IN'); - update_ability('MS'); - update_ability('CH'); +on("change:rollSwitch", function (args) { + console.log(args); + let update = {}; + if (args.newValue == "2") { return } + if (args.newValue == "1") { + update["PS_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + update["DX_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + update["CN_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + update["IN_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + update["MS_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + update["CH_rolled"] = dices.roll("4d6", { dropLowest: 1 }).total; + } + + if (args.newValue == "0") { + update["PS_rolled"] = 0; + update["DX_rolled"] = 0; + update["IN_rolled"] = 0; + update["CN_rolled"] = 0; + update["IN_rolled"] = 0; + update["MS_rolled"] = 0; + update["CH_rolled"] = 0; + } + setAttrs(update, { silent: true }); - update_mod('PS'); - update_mod('DX'); - update_mod('CN'); - update_mod('IN'); - update_mod('MS'); - update_mod('CH'); + update_ability("PS"); + update_ability("DX"); + update_ability("CN"); + update_ability("IN"); + update_ability("MS"); + update_ability("CH"); + update_mod("PS"); + update_mod("DX"); + update_mod("CN"); + update_mod("IN"); + update_mod("MS"); + update_mod("CH"); }); - -on("change:hpRollSwitch", function(args) { - let update = {}; - if(args.newValue == "0") { - update['hp_max'] = 0; - } else { - let rank, CN; - getAttrs(['character_rank', 'CN'], (v) => { - rank = v['character_rank']; - CN = v['CN']; - }); - - update['hp_max'] = dices.roll(`${CN}d6+${CN}`).total; - setAttrs(update, {silent: true}); - } -}); \ No newline at end of file +on("change:hpRollSwitch", function (args) { + console.log("change:hpRollSwitch"); + console.log(args); + let update = {}; + if (args.newValue == "0") { + console.log("set hp_max to zero"); + update["hp_max"] = 0; + setAttrs(update, { silent: true }); + } else { + let rank, CN; + getAttrs(["character_rank", "CN"], (v) => { + console.log("v", v); + rank = v["character_rank"]; + CN = v["CN"]; + update["hp_max"] = dices.roll(`${CN}d6+${CN}`).total; + setAttrs(update, { silent: true }); + }); + } +}); diff --git a/GammaWorld3e/styles.css b/GammaWorld3e/styles.css index 0751fa864e..43560f4379 100644 --- a/GammaWorld3e/styles.css +++ b/GammaWorld3e/styles.css @@ -314,10 +314,13 @@ input.sheet-pageToggle:not([value="3"]) ~ .sheet-tab3 { /********************** Roll-up ***********************/ -input.sheet-rollSwitch:not([value="0"]) ~ .sheet-pre-rolled { +input.sheet-rollSwitch[value="0"] ~ .sheet-tab-score-roll, input.sheet-rollSwitch[value="0"] ~ .sheet-tab-score-input { display: none; } -input.sheet-rollSwitch:not([value="1"]) ~ .sheet-post-rolled { +input.sheet-rollSwitch[value="1"] ~ .sheet-tab-score-input { + display: none; } + +input.sheet-rollSwitch[value="2"] ~ .sheet-tab-score-roll { display: none; } /**********************