From feaaee3cbc90f1eca1882556813e86a2795d754c Mon Sep 17 00:00:00 2001 From: uriele Date: Thu, 12 Sep 2024 23:53:07 +0200 Subject: [PATCH 1/3] possible fix --- Delta Green 2/deltagreen.html | 90 +++++++++++++- Delta Green 2/deltagreen.pug | 13 ++- .../src/js/sheetworkers_versioning.dev.js | 110 ++++++++++++++++++ .../src/js/sheetworkers_versioning.js | 77 ++++++++++++ Delta Green 2/translation.json | 12 +- 5 files changed, 293 insertions(+), 9 deletions(-) diff --git a/Delta Green 2/deltagreen.html b/Delta Green 2/deltagreen.html index f3cf84ee8e8e..662a0c8eefbd 100644 --- a/Delta Green 2/deltagreen.html +++ b/Delta Green 2/deltagreen.html @@ -16,12 +16,14 @@ - + + - + + @@ -37,15 +39,18 @@ - + + + - + + @@ -5825,6 +5830,9 @@

{{#subheader}}({{subheader}}%){{/subheader}}

if (version<2.02) { version_201_202(); } + if (version<2.03) { + version_202_203(); + } }; // UPDATE TO VERSION 1.05 @@ -6110,6 +6118,80 @@

{{#subheader}}({{subheader}}%){{/subheader}}

}); } +const version_202_203 = () => { + const codeversion = 2.03 + const update ={} + update['version'] = codeversion + const old_named_skills=[`art`,`craft`,`pilot`,`military_science`,`science`] + const old_adaptation = [`violence_1`,`violence_2`,`violence_3`,`helplessness_1`,`helplessness_2`,`helplessness_3`] + const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),values =>{ + if (values.hasOwnProperty('art_name')){ + const art_value=setMinMax(values[`art`]); + const art_name = values[`art_name`]; + update[`art_1`]=art_value; + update[`art_1_name`]=art_name; + } + if (values.hasOwnProperty('craft_name')){ + const craft_value = setMinMax(values[`craft`]); + const craft_name = values[`craft_name`]; + update[`craft_1`]=craft_value; + update[`craft_1_name`]=craft_name; + } + // complete for pilot, military_science, science + if (values.hasOwnProperty('pilot')) { + const pilot_value= setMinMax(values[`pilot`]); + const pilot_name = values[`pilot_name`]; + update[`pilot_1`] = pilot_value; + update[`pilot_1_name`] = pilot_name; + } + + + if (values.hasOwnProperty('military_science')) { + const military_science_value = setMinMax(values[`military_science`]); + const military_science_name = values[`military_science_name`]; + update[`military_science_1`] = military_science_value; + update[`military_science_1_name`] = military_science_name; + } + + if (values.hasOwnProperty('science')) { + const science_value = setMinMax(values[`science`]); + const science_name = values[`science_name`]; + update[`science_1`] = science_value; + update[`science_1_name`] = science_name; + } + + if (values.hasOwnProperty('violence_1')) { + const violence_1 = values[`violence_1`]; + const violence_2 = values[`violence_2`]; + const violence_3 = values[`violence_3`]; + var violence = -1; + if (violence_1 ==1) {violence =0} + if (violence_2 ==2) {violence =1} + if (violence_3 ==3) {violence =2} + update[`violence`] = violence; + if (violence ==2) {update[`violence_adapted`]==1} + } + if (values.hasOwnProperty('helplessness_1')) { + const helplessness_1 = values[`helplessness_1`]; + const helplessness_2 = values[`helplessness_2`]; + const helplessness_3 = values[`helplessness_3`]; + var helplessness = -1; + if (helplessness_1 ==1) {helplessness =0} + if (helplessness_2 ==2) {helplessness =1} + if (helplessness_3 ==3) {helplessness =2} + update[`helplessness`] = helplessness; + if (helplessness ==2) {update[`helplessness_adapted`]==1} + } + setAttrs(update, {silent:true}, () => { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + + }); +} + const BondButtonColor= (bondvalue) => { const score = parseInt(bondvalue)||0; diff --git a/Delta Green 2/deltagreen.pug b/Delta Green 2/deltagreen.pug index f51f1e5e9af5..a77caa0437eb 100644 --- a/Delta Green 2/deltagreen.pug +++ b/Delta Green 2/deltagreen.pug @@ -34,12 +34,14 @@ button.none(type='action' name='act_nothing') input(data-i18n-value='alertness' name='attr_alertness_name' value='alertness') input(data-i18n-value='anthropology' name='attr_anthropology_name' value='anthropology') input(data-i18n-value='archeology' name='attr_archeology_name' value='archeology') - input(data-i18n-value='art' name='attr_art_name' value='art') + input(data-i18n-value='art 1' name='attr_art_1_name' value='art_1') + input(data-i18n-value='art 2' name='attr_art_2_name' value='art_2') input(data-i18n-value='artillery' name='attr_artillery_name' value='artillery') input(data-i18n-value='athletics' name='attr_athletics_name' value='athletics') input(data-i18n-value='bureaucracy' name='attr_bureaucracy_name' value='bureaucracy') input(data-i18n-value='computer science' name='attr_computer_science_name' value='computer science') - input(data-i18n-value='craft' name='attr_craft_name' value='craft') + input(data-i18n-value='craft 1' name='attr_craft_1_name' value='craft_1') + input(data-i18n-value='craft 2' name='attr_craft_2_name' value='craft_2') input(data-i18n-value='criminology' name='attr_criminology_name' value='criminology') input(data-i18n-value='demolitions' name='attr_demolitions_name' value='demolitions') input(data-i18n-value='disguise' name='attr_disguise_name' value='disguise') @@ -55,15 +57,18 @@ button.none(type='action' name='act_nothing') input(data-i18n-value='law' name='attr_law_name' value='law') input(data-i18n-value='medicine' name='attr_medicine_name' value='medicine') input(data-i18n-value='melee weapons' name='attr_melee_weapons_name' value='melee weapons') - input(data-i18n-value='military science' name='attr_military_science_name' value='military science') + input(data-i18n-value='military science 1' name='attr_military_science_1_name' value='military science 1') + input(data-i18n-value='military science 2' name='attr_military_science_2_name' value='military science 2') input(data-i18n-value='navigate' name='attr_navigate_name' value='navigate') input(data-i18n-value='occult' name='attr_occult_name' value='occult') input(data-i18n-value='persuade' name='attr_persuade_name' value='persuade') input(data-i18n-value='pharmacy' name='attr_pharmacy_name' value='pharmacy') input(data-i18n-value='pilot' name='attr_pilot_name' value='pilot') + input(data-i18n-value='pilot' name='attr_pilot_name' value='pilot') input(data-i18n-value='psychotherapy' name='attr_psychotherapy_name' value='psychotherapy') input(data-i18n-value='ride' name='attr_ride_name' value='ride') - input(data-i18n-value='science' name='attr_science_name' value='science') + input(data-i18n-value='science 1' name='attr_science_1_name' value='science 1') + input(data-i18n-value='science 2' name='attr_science_2_name' value='science 2') input(data-i18n-value='search' name='attr_search_name' value='search') input(data-i18n-value='sigint' name='attr_sigint_name' value='sigint') input(data-i18n-value='stealth' name='attr_stealth_name' value='stealth') diff --git a/Delta Green 2/src/js/sheetworkers_versioning.dev.js b/Delta Green 2/src/js/sheetworkers_versioning.dev.js index 5dc3d050ff21..22cafd1049d1 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.dev.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.dev.js @@ -26,6 +26,10 @@ var versioning = function versioning(version) { if (version < 2.02) { version_201_202(); } + + if (version < 2.03) { + version_202_203(); + } }; // UPDATE TO VERSION 1.05 @@ -329,4 +333,110 @@ var version_201_202 = function version_201_202() { }); }); }); +}; + +var version_202_203 = function version_202_203() { + var codeversion = 2.03; + var update = {}; + update['version'] = codeversion; + var old_named_skills = ["art", "craft", "pilot", "military_science", "science"]; + var old_adaptation = ["violence_1", "violence_2", "violence_3", "helplessness_1", "helplessness_2", "helplessness_3"]; + var old_named_skills_names = old_named_skills.map(function (x) { + return "".concat(x, "_name"); + }); + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills), function (values) { + if (values.hasOwnProperty('art_name')) { + var art_value = setMinMax(values["art"]); + var art_name = values["art_name"]; + update["art_1"] = art_value; + update["art_1_name"] = art_name; + } + + if (values.hasOwnProperty('craft_name')) { + var craft_value = setMinMax(values["craft"]); + var craft_name = values["craft_name"]; + update["craft_1"] = craft_value; + update["craft_1_name"] = craft_name; + } // complete for pilot, military_science, science + + + if (values.hasOwnProperty('pilot')) { + var pilot_value = setMinMax(values["pilot"]); + var pilot_name = values["pilot_name"]; + update["pilot_1"] = pilot_value; + update["pilot_1_name"] = pilot_name; + } + + if (values.hasOwnProperty('military_science')) { + var military_science_value = setMinMax(values["military_science"]); + var military_science_name = values["military_science_name"]; + update["military_science_1"] = military_science_value; + update["military_science_1_name"] = military_science_name; + } + + if (values.hasOwnProperty('science')) { + var science_value = setMinMax(values["science"]); + var science_name = values["science_name"]; + update["science_1"] = science_value; + update["science_1_name"] = science_name; + } + + if (values.hasOwnProperty('violence_1')) { + var violence_1 = values["violence_1"]; + var violence_2 = values["violence_2"]; + var violence_3 = values["violence_3"]; + var violence = -1; + + if (violence_1 == 1) { + violence = 0; + } + + if (violence_2 == 2) { + violence = 1; + } + + if (violence_3 == 3) { + violence = 2; + } + + update["violence"] = violence; + + if (violence == 2) { + update["violence_adapted"] == 1; + } + } + + if (values.hasOwnProperty('helplessness_1')) { + var helplessness_1 = values["helplessness_1"]; + var helplessness_2 = values["helplessness_2"]; + var helplessness_3 = values["helplessness_3"]; + var helplessness = -1; + + if (helplessness_1 == 1) { + helplessness = 0; + } + + if (helplessness_2 == 2) { + helplessness = 1; + } + + if (helplessness_3 == 3) { + helplessness = 2; + } + + update["helplessness"] = helplessness; + + if (helplessness == 2) { + update["helplessness_adapted"] == 1; + } + } + + setAttrs(update, { + silent: true + }, function () { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + }); }; \ No newline at end of file diff --git a/Delta Green 2/src/js/sheetworkers_versioning.js b/Delta Green 2/src/js/sheetworkers_versioning.js index 3cbbc78063c3..9bea8e4030c8 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.js @@ -18,6 +18,9 @@ const versioning = (version) => { if (version<2.02) { version_201_202(); } + if (version<2.03) { + version_202_203(); + } }; // UPDATE TO VERSION 1.05 @@ -301,4 +304,78 @@ const version_201_202 = () => { }); }); }); +} + +const version_202_203 = () => { + const codeversion = 2.03 + const update ={} + update['version'] = codeversion + const old_named_skills=[`art`,`craft`,`pilot`,`military_science`,`science`] + const old_adaptation = [`violence_1`,`violence_2`,`violence_3`,`helplessness_1`,`helplessness_2`,`helplessness_3`] + const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),values =>{ + if (values.hasOwnProperty('art_name')){ + const art_value=setMinMax(values[`art`]); + const art_name = values[`art_name`]; + update[`art_1`]=art_value; + update[`art_1_name`]=art_name; + } + if (values.hasOwnProperty('craft_name')){ + const craft_value = setMinMax(values[`craft`]); + const craft_name = values[`craft_name`]; + update[`craft_1`]=craft_value; + update[`craft_1_name`]=craft_name; + } + // complete for pilot, military_science, science + if (values.hasOwnProperty('pilot')) { + const pilot_value= setMinMax(values[`pilot`]); + const pilot_name = values[`pilot_name`]; + update[`pilot_1`] = pilot_value; + update[`pilot_1_name`] = pilot_name; + } + + + if (values.hasOwnProperty('military_science')) { + const military_science_value = setMinMax(values[`military_science`]); + const military_science_name = values[`military_science_name`]; + update[`military_science_1`] = military_science_value; + update[`military_science_1_name`] = military_science_name; + } + + if (values.hasOwnProperty('science')) { + const science_value = setMinMax(values[`science`]); + const science_name = values[`science_name`]; + update[`science_1`] = science_value; + update[`science_1_name`] = science_name; + } + + if (values.hasOwnProperty('violence_1')) { + const violence_1 = values[`violence_1`]; + const violence_2 = values[`violence_2`]; + const violence_3 = values[`violence_3`]; + var violence = -1; + if (violence_1 ==1) {violence =0} + if (violence_2 ==2) {violence =1} + if (violence_3 ==3) {violence =2} + update[`violence`] = violence; + if (violence ==2) {update[`violence_adapted`]==1} + } + if (values.hasOwnProperty('helplessness_1')) { + const helplessness_1 = values[`helplessness_1`]; + const helplessness_2 = values[`helplessness_2`]; + const helplessness_3 = values[`helplessness_3`]; + var helplessness = -1; + if (helplessness_1 ==1) {helplessness =0} + if (helplessness_2 ==2) {helplessness =1} + if (helplessness_3 ==3) {helplessness =2} + update[`helplessness`] = helplessness; + if (helplessness ==2) {update[`helplessness_adapted`]==1} + } + setAttrs(update, {silent:true}, () => { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + + }); } \ No newline at end of file diff --git a/Delta Green 2/translation.json b/Delta Green 2/translation.json index c7cc0ad2a2d6..0fe941a20c33 100644 --- a/Delta Green 2/translation.json +++ b/Delta Green 2/translation.json @@ -1,5 +1,15 @@ { "rituals": "rituals" + ,"art 1": "art 1" + ,"art 2": "art 2" + ,"craft 1":"craft 1" + ,"craft 2":"craft 2" + ,"pilot 1":"pilot 1" + ,"pilot 2":"pilot 2" + ,"military science 1":"military science 1" + ,"military science 2":"military science 2" + ,"science 1":"science 1" + ,"science 2":"science 2" ,"Agents rituals": "Agents rituals" ,"ammunitions:": "ammunitions:" ,"huge target:": "huge target:" @@ -250,7 +260,7 @@ ,"forensics rank": "forensics rank" ,"forensics roll":"forensics roll" ,"forensics": "forensics" - ,"foriegn languages and other skills:":"foriegn languages and other skills:" + ,"foriegn languages and other skills:":"foreign languages and other skills:" ,"fumble": "fumble" ,"gm whisper toggle": "gm whisper toggle" ,"GM Whisper": "GM Whisper" From 97d9b9cde58561d70e6c2c4e8861ba190241c5e4 Mon Sep 17 00:00:00 2001 From: uriele Date: Fri, 13 Sep 2024 10:50:16 +0200 Subject: [PATCH 2/3] 2.03 --- Delta Green 2/deltagreen.html | 13 +++++++------ Delta Green 2/src/js/sheetworkers_versioning.dev.js | 5 +++-- Delta Green 2/src/js/sheetworkers_versioning.js | 13 +++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Delta Green 2/deltagreen.html b/Delta Green 2/deltagreen.html index 662a0c8eefbd..4cebca19472d 100644 --- a/Delta Green 2/deltagreen.html +++ b/Delta Green 2/deltagreen.html @@ -6116,16 +6116,17 @@

{{#subheader}}({{subheader}}%){{/subheader}}

}); }); }); -} +}; const version_202_203 = () => { const codeversion = 2.03 const update ={} - update['version'] = codeversion - const old_named_skills=[`art`,`craft`,`pilot`,`military_science`,`science`] - const old_adaptation = [`violence_1`,`violence_2`,`violence_3`,`helplessness_1`,`helplessness_2`,`helplessness_3`] + console.log('verion:',codeversion); + update['version'] = codeversion; + const old_named_skills=['art','craft','pilot','military_science','science']; + const old_adaptation = ['violence_1','violence_2','violence_3','helplessness_1','helplessness_2','helplessness_3']; const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) - getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),values =>{ + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),(values) =>{ if (values.hasOwnProperty('art_name')){ const art_value=setMinMax(values[`art`]); const art_name = values[`art_name`]; @@ -6190,7 +6191,7 @@

{{#subheader}}({{subheader}}%){{/subheader}}

}); }); -} +}; const BondButtonColor= (bondvalue) => { diff --git a/Delta Green 2/src/js/sheetworkers_versioning.dev.js b/Delta Green 2/src/js/sheetworkers_versioning.dev.js index 22cafd1049d1..8283b18fa91e 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.dev.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.dev.js @@ -338,9 +338,10 @@ var version_201_202 = function version_201_202() { var version_202_203 = function version_202_203() { var codeversion = 2.03; var update = {}; + console.log('verion:', codeversion); update['version'] = codeversion; - var old_named_skills = ["art", "craft", "pilot", "military_science", "science"]; - var old_adaptation = ["violence_1", "violence_2", "violence_3", "helplessness_1", "helplessness_2", "helplessness_3"]; + var old_named_skills = ['art', 'craft', 'pilot', 'military_science', 'science']; + var old_adaptation = ['violence_1', 'violence_2', 'violence_3', 'helplessness_1', 'helplessness_2', 'helplessness_3']; var old_named_skills_names = old_named_skills.map(function (x) { return "".concat(x, "_name"); }); diff --git a/Delta Green 2/src/js/sheetworkers_versioning.js b/Delta Green 2/src/js/sheetworkers_versioning.js index 9bea8e4030c8..3119f29f5d72 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.js @@ -304,16 +304,17 @@ const version_201_202 = () => { }); }); }); -} +}; const version_202_203 = () => { const codeversion = 2.03 const update ={} - update['version'] = codeversion - const old_named_skills=[`art`,`craft`,`pilot`,`military_science`,`science`] - const old_adaptation = [`violence_1`,`violence_2`,`violence_3`,`helplessness_1`,`helplessness_2`,`helplessness_3`] + console.log('verion:',codeversion); + update['version'] = codeversion; + const old_named_skills=['art','craft','pilot','military_science','science']; + const old_adaptation = ['violence_1','violence_2','violence_3','helplessness_1','helplessness_2','helplessness_3']; const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) - getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),values =>{ + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),(values) =>{ if (values.hasOwnProperty('art_name')){ const art_value=setMinMax(values[`art`]); const art_name = values[`art_name`]; @@ -378,4 +379,4 @@ const version_202_203 = () => { }); }); -} \ No newline at end of file +}; \ No newline at end of file From 87089190fc57f25ea2b06e11a0360eaa5c9c13c0 Mon Sep 17 00:00:00 2001 From: uriele Date: Sat, 14 Sep 2024 23:59:12 +0200 Subject: [PATCH 3/3] fix versioning 2.04 bonds updated with CHA instead of WP also if value of bond is >CHA and previous value of bond>CHA, keeps it, otherwise set it to CHA --- Delta Green 2/deltagreen.html | 67 +++++++++++++++---- .../src/js/sheetworkers_constants.dev.js | 2 +- .../src/js/sheetworkers_constants.js | 1 + .../src/js/sheetworkers_helpers.dev.js | 14 ++-- Delta Green 2/src/js/sheetworkers_helpers.js | 15 +++-- .../src/js/sheetworkers_versioning.dev.js | 60 +++++++++++------ .../src/js/sheetworkers_versioning.js | 51 ++++++++++++-- 7 files changed, 155 insertions(+), 55 deletions(-) diff --git a/Delta Green 2/deltagreen.html b/Delta Green 2/deltagreen.html index 4cebca19472d..ff3518e039bc 100644 --- a/Delta Green 2/deltagreen.html +++ b/Delta Green 2/deltagreen.html @@ -4769,6 +4769,7 @@

{{#subheader}}({{subheader}}%){{/subheader}}

const _score_info = [ `willpower_points_max`, + `charisma_score`, `character_creation_bonds`, `repeating_bonds_setScore`, `repeating_bonds_score`, @@ -5361,24 +5362,25 @@

{{#subheader}}({{subheader}}%){{/subheader}}

const updatebondscore = (values,update,manualscore=true) => { const character_creation_bonds = values[`character_creation_bonds`] === 'active' ? true : false; - const willpower_points_max = parseInt(values.willpower_points_max) || 0; - const initial_willpower = (character_creation_bonds) ? willpower_points_max : Math.floor(willpower_points_max/2); + const charisma_score = parseInt(values[`charisma_score`]) || 0; + const bond_value = (character_creation_bonds) ? charisma_score : Math.floor(charisma_score/2); const flag = (manualscore) ? 1 : parseInt(values[`repeating_bonds_setScore`]) || 0; const bond_score_old = parseInt(values[`repeating_bonds_score_old`]) || 0; var bond_score = 0; if (flag === 0) { - bond_score = initial_willpower; + bond_score = bond_value; } else { bond_score = parseInt(values[`repeating_bonds_score`]) || 0; - if (bond_score > willpower_points_max) { - if (willpower_points_max > bond_score_old) { - bond_score = willpower_points_max; + if (bond_score > charisma_score) { + if (bond_score_old<= charisma_score) { + bond_score = charisma_score; } + } } update[`repeating_bonds_score`] = bond_score; - update[`repeating_bonds_score_old`] = bond_score_old; + update[`repeating_bonds_score_old`] = bond_score; update[`repeating_bonds_setScore`] = 1; update[`repeating_bonds_color`] = BondButtonColor(bond_score); } @@ -5815,24 +5817,27 @@

{{#subheader}}({{subheader}}%){{/subheader}}

if (version < 1.05) { version_0_105(); } - if (version <1.5) { + else if (version <1.5) { version_105_150(); } - if (version<1.7) { + else if (version<1.7) { version_150_170(); } - if (version<2.0) { + else if (version<2.0) { version_170_200(); } - if (version<2.01) { + else if (version<2.01) { version_200_201(); } - if (version<2.02) { + else if (version<2.02) { version_201_202(); } - if (version<2.03) { + else if (version<2.03) { version_202_203(); } + else if (version<2.04) { + version_203_204(); + } }; // UPDATE TO VERSION 1.05 @@ -6126,7 +6131,7 @@

{{#subheader}}({{subheader}}%){{/subheader}}

const old_named_skills=['art','craft','pilot','military_science','science']; const old_adaptation = ['violence_1','violence_2','violence_3','helplessness_1','helplessness_2','helplessness_3']; const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) - getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),(values) =>{ + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills).concat(['willpower_points_max','charisma_score']),(values) =>{ if (values.hasOwnProperty('art_name')){ const art_value=setMinMax(values[`art`]); const art_name = values[`art_name`]; @@ -6184,12 +6189,46 @@

{{#subheader}}({{subheader}}%){{/subheader}}

update[`helplessness`] = helplessness; if (helplessness ==2) {update[`helplessness_adapted`]==1} } + setAttrs(update, {silent:true}, () => { console.log('updated named skills and adaptations'); versioning(codeversion); console.info(update); }); + }); +}; + +const version_203_204= () => { + const codeversion = 2.04; + const update ={}; + console.log('verion:',codeversion); + update['version'] = codeversion; + + getAttrs(['willpower_points_max','charisma_score'],values => { + getSectionIDs('bonds',ids => { + const repfields=[]; + ids.forEach(id => { + repfields.push(`repeating_bonds_${id}_score`); + }); + getAttrs(repfields,bond_values => { + const willpower_points_max=values['willpower_points_max']; + const charisma_score = values['charisma_score']; + + repfields.forEach(field => { + if ((parseInt(bond_values[field])||0)>=willpower_points_max){ + update[field]=charisma_score; + update[`${field}_old`]=charisma_score; + } + }); + setAttrs(update, {silent:true}, () => { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + + }); + }); }); }; diff --git a/Delta Green 2/src/js/sheetworkers_constants.dev.js b/Delta Green 2/src/js/sheetworkers_constants.dev.js index b21471eb37c4..38d82d669830 100644 --- a/Delta Green 2/src/js/sheetworkers_constants.dev.js +++ b/Delta Green 2/src/js/sheetworkers_constants.dev.js @@ -95,7 +95,7 @@ var _repeating_sections = { 'weapons': 'weapons', 'ritual': 'rituals' }; -var _score_info = ["willpower_points_max", "character_creation_bonds", "repeating_bonds_setScore", "repeating_bonds_score", "repeating_bonds_score_old", "repeating_bonds_color"]; +var _score_info = ["willpower_points_max", "charisma_score", "character_creation_bonds", "repeating_bonds_setScore", "repeating_bonds_score", "repeating_bonds_score_old", "repeating_bonds_color"]; var _bond_attributes = ["name", "test", "score", "hurt"]; var _repeating_damages = ['damage', 'damage_critical', 'lethality_percent', 'lethality_percent_critical', 'double_barrel', 'double_barrel_critical', 'selective_fire', 'selective_fire_critical']; var _repeating_ammo = ['hasammo', 'ammo', 'ammo_total']; diff --git a/Delta Green 2/src/js/sheetworkers_constants.js b/Delta Green 2/src/js/sheetworkers_constants.js index ca9e3cdb8ec7..0f3cbec421cb 100644 --- a/Delta Green 2/src/js/sheetworkers_constants.js +++ b/Delta Green 2/src/js/sheetworkers_constants.js @@ -70,6 +70,7 @@ const _repeating_sections={ const _score_info = [ `willpower_points_max`, + `charisma_score`, `character_creation_bonds`, `repeating_bonds_setScore`, `repeating_bonds_score`, diff --git a/Delta Green 2/src/js/sheetworkers_helpers.dev.js b/Delta Green 2/src/js/sheetworkers_helpers.dev.js index d8a15740dedc..fbc4e72e89d6 100644 --- a/Delta Green 2/src/js/sheetworkers_helpers.dev.js +++ b/Delta Green 2/src/js/sheetworkers_helpers.dev.js @@ -699,26 +699,26 @@ var addTargetStat = function addTargetStat(values, names, attrName) { var updatebondscore = function updatebondscore(values, update) { var manualscore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var character_creation_bonds = values["character_creation_bonds"] === 'active' ? true : false; - var willpower_points_max = parseInt(values.willpower_points_max) || 0; - var initial_willpower = character_creation_bonds ? willpower_points_max : Math.floor(willpower_points_max / 2); + var charisma_score = parseInt(values["charisma_score"]) || 0; + var bond_value = character_creation_bonds ? charisma_score : Math.floor(charisma_score / 2); var flag = manualscore ? 1 : parseInt(values["repeating_bonds_setScore"]) || 0; var bond_score_old = parseInt(values["repeating_bonds_score_old"]) || 0; var bond_score = 0; if (flag === 0) { - bond_score = initial_willpower; + bond_score = bond_value; } else { bond_score = parseInt(values["repeating_bonds_score"]) || 0; - if (bond_score > willpower_points_max) { - if (willpower_points_max > bond_score_old) { - bond_score = willpower_points_max; + if (bond_score > charisma_score) { + if (bond_score_old <= charisma_score) { + bond_score = charisma_score; } } } update["repeating_bonds_score"] = bond_score; - update["repeating_bonds_score_old"] = bond_score_old; + update["repeating_bonds_score_old"] = bond_score; update["repeating_bonds_setScore"] = 1; update["repeating_bonds_color"] = BondButtonColor(bond_score); }; diff --git a/Delta Green 2/src/js/sheetworkers_helpers.js b/Delta Green 2/src/js/sheetworkers_helpers.js index a9a0360c1419..db405bdabc7a 100644 --- a/Delta Green 2/src/js/sheetworkers_helpers.js +++ b/Delta Green 2/src/js/sheetworkers_helpers.js @@ -474,24 +474,25 @@ const addTargetStat=(values,names,attrName) => { const updatebondscore = (values,update,manualscore=true) => { const character_creation_bonds = values[`character_creation_bonds`] === 'active' ? true : false; - const willpower_points_max = parseInt(values.willpower_points_max) || 0; - const initial_willpower = (character_creation_bonds) ? willpower_points_max : Math.floor(willpower_points_max/2); + const charisma_score = parseInt(values[`charisma_score`]) || 0; + const bond_value = (character_creation_bonds) ? charisma_score : Math.floor(charisma_score/2); const flag = (manualscore) ? 1 : parseInt(values[`repeating_bonds_setScore`]) || 0; const bond_score_old = parseInt(values[`repeating_bonds_score_old`]) || 0; var bond_score = 0; if (flag === 0) { - bond_score = initial_willpower; + bond_score = bond_value; } else { bond_score = parseInt(values[`repeating_bonds_score`]) || 0; - if (bond_score > willpower_points_max) { - if (willpower_points_max > bond_score_old) { - bond_score = willpower_points_max; + if (bond_score > charisma_score) { + if (bond_score_old<= charisma_score) { + bond_score = charisma_score; } + } } update[`repeating_bonds_score`] = bond_score; - update[`repeating_bonds_score_old`] = bond_score_old; + update[`repeating_bonds_score_old`] = bond_score; update[`repeating_bonds_setScore`] = 1; update[`repeating_bonds_color`] = BondButtonColor(bond_score); } diff --git a/Delta Green 2/src/js/sheetworkers_versioning.dev.js b/Delta Green 2/src/js/sheetworkers_versioning.dev.js index 8283b18fa91e..15ed8b1e7a46 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.dev.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.dev.js @@ -5,30 +5,20 @@ var versioning = function versioning(version) { if (version < 1.05) { version_0_105(); - } - - if (version < 1.5) { + } else if (version < 1.5) { version_105_150(); - } - - if (version < 1.7) { + } else if (version < 1.7) { version_150_170(); - } - - if (version < 2.0) { + } else if (version < 2.0) { version_170_200(); - } - - if (version < 2.01) { + } else if (version < 2.01) { version_200_201(); - } - - if (version < 2.02) { + } else if (version < 2.02) { version_201_202(); - } - - if (version < 2.03) { + } else if (version < 2.03) { version_202_203(); + } else if (version < 2.04) { + version_203_204(); } }; // UPDATE TO VERSION 1.05 @@ -345,7 +335,7 @@ var version_202_203 = function version_202_203() { var old_named_skills_names = old_named_skills.map(function (x) { return "".concat(x, "_name"); }); - getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills), function (values) { + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills).concat(['willpower_points_max', 'charisma_score']), function (values) { if (values.hasOwnProperty('art_name')) { var art_value = setMinMax(values["art"]); var art_name = values["art_name"]; @@ -440,4 +430,36 @@ var version_202_203 = function version_202_203() { console.info(update); }); }); +}; + +var version_203_204 = function version_203_204() { + var codeversion = 2.04; + var update = {}; + console.log('verion:', codeversion); + update['version'] = codeversion; + getAttrs(['willpower_points_max', 'charisma_score'], function (values) { + getSectionIDs('bonds', function (ids) { + var repfields = []; + ids.forEach(function (id) { + repfields.push("repeating_bonds_".concat(id, "_score")); + }); + getAttrs(repfields, function (bond_values) { + var willpower_points_max = values['willpower_points_max']; + var charisma_score = values['charisma_score']; + repfields.forEach(function (field) { + if ((parseInt(bond_values[field]) || 0) >= willpower_points_max) { + update[field] = charisma_score; + update["".concat(field, "_old")] = charisma_score; + } + }); + setAttrs(update, { + silent: true + }, function () { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + }); + }); + }); }; \ No newline at end of file diff --git a/Delta Green 2/src/js/sheetworkers_versioning.js b/Delta Green 2/src/js/sheetworkers_versioning.js index 3119f29f5d72..159d7a5ca5d7 100644 --- a/Delta Green 2/src/js/sheetworkers_versioning.js +++ b/Delta Green 2/src/js/sheetworkers_versioning.js @@ -3,24 +3,27 @@ const versioning = (version) => { if (version < 1.05) { version_0_105(); } - if (version <1.5) { + else if (version <1.5) { version_105_150(); } - if (version<1.7) { + else if (version<1.7) { version_150_170(); } - if (version<2.0) { + else if (version<2.0) { version_170_200(); } - if (version<2.01) { + else if (version<2.01) { version_200_201(); } - if (version<2.02) { + else if (version<2.02) { version_201_202(); } - if (version<2.03) { + else if (version<2.03) { version_202_203(); } + else if (version<2.04) { + version_203_204(); + } }; // UPDATE TO VERSION 1.05 @@ -314,7 +317,7 @@ const version_202_203 = () => { const old_named_skills=['art','craft','pilot','military_science','science']; const old_adaptation = ['violence_1','violence_2','violence_3','helplessness_1','helplessness_2','helplessness_3']; const old_named_skills_names=old_named_skills.map(x=> `${x}_name`) - getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills),(values) =>{ + getAttrs(old_adaptation.concat(old_named_skills_names).concat(old_named_skills).concat(['willpower_points_max','charisma_score']),(values) =>{ if (values.hasOwnProperty('art_name')){ const art_value=setMinMax(values[`art`]); const art_name = values[`art_name`]; @@ -372,11 +375,45 @@ const version_202_203 = () => { update[`helplessness`] = helplessness; if (helplessness ==2) {update[`helplessness_adapted`]==1} } + setAttrs(update, {silent:true}, () => { console.log('updated named skills and adaptations'); versioning(codeversion); console.info(update); }); + }); +}; +const version_203_204= () => { + const codeversion = 2.04; + const update ={}; + console.log('verion:',codeversion); + update['version'] = codeversion; + + getAttrs(['willpower_points_max','charisma_score'],values => { + getSectionIDs('bonds',ids => { + const repfields=[]; + ids.forEach(id => { + repfields.push(`repeating_bonds_${id}_score`); + }); + getAttrs(repfields,bond_values => { + const willpower_points_max=values['willpower_points_max']; + const charisma_score = values['charisma_score']; + + repfields.forEach(field => { + if ((parseInt(bond_values[field])||0)>=willpower_points_max){ + update[field]=charisma_score; + update[`${field}_old`]=charisma_score; + } + }); + + setAttrs(update, {silent:true}, () => { + console.log('updated named skills and adaptations'); + versioning(codeversion); + console.info(update); + }); + + }); + }); }); }; \ No newline at end of file