Skip to content

Commit

Permalink
Merge pull request #13314 from uriele/v2.02
Browse files Browse the repository at this point in the history
bugfix Delta Green by ArcDream V2.03
  • Loading branch information
kfroll20 authored Sep 17, 2024
2 parents 4085fe5 + 8708919 commit 4d618ac
Show file tree
Hide file tree
Showing 9 changed files with 445 additions and 58 deletions.
156 changes: 139 additions & 17 deletions Delta Green 2/deltagreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
<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"/>
Expand All @@ -37,15 +39,18 @@
<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"/>
Expand Down Expand Up @@ -4764,6 +4769,7 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>

const _score_info = [
`willpower_points_max`,
`charisma_score`,
`character_creation_bonds`,
`repeating_bonds_setScore`,
`repeating_bonds_score`,
Expand Down Expand Up @@ -5356,24 +5362,25 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>
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);
}
Expand Down Expand Up @@ -5810,21 +5817,27 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>
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();
}
else if (version<2.03) {
version_202_203();
}
else if (version<2.04) {
version_203_204();
}
};

// UPDATE TO VERSION 1.05
Expand Down Expand Up @@ -6108,7 +6121,116 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>
});
});
});
}
};

const version_202_203 = () => {
const codeversion = 2.03
const update ={}
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).concat(['willpower_points_max','charisma_score']),(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 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);
});

});
});
});
};


const BondButtonColor= (bondvalue) => {
Expand Down
13 changes: 9 additions & 4 deletions Delta Green 2/deltagreen.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion Delta Green 2/src/js/sheetworkers_constants.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions Delta Green 2/src/js/sheetworkers_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const _repeating_sections={

const _score_info = [
`willpower_points_max`,
`charisma_score`,
`character_creation_bonds`,
`repeating_bonds_setScore`,
`repeating_bonds_score`,
Expand Down
14 changes: 7 additions & 7 deletions Delta Green 2/src/js/sheetworkers_helpers.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
15 changes: 8 additions & 7 deletions Delta Green 2/src/js/sheetworkers_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 4d618ac

Please sign in to comment.