Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
uriele committed Sep 14, 2024
1 parent 97d9b9c commit 8708919
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 55 deletions.
67 changes: 53 additions & 14 deletions Delta Green 2/deltagreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -4769,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 @@ -5361,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 @@ -5815,24 +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();
}
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
Expand Down Expand Up @@ -6126,7 +6131,7 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>
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`];
Expand Down Expand Up @@ -6184,12 +6189,46 @@ <h2>{{#subheader}}({{subheader}}%){{/subheader}}</h2>
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);
});

});
});
});
};

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
60 changes: 41 additions & 19 deletions Delta Green 2/src/js/sheetworkers_versioning.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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);
});
});
});
});
};
51 changes: 44 additions & 7 deletions Delta Green 2/src/js/sheetworkers_versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`];
Expand Down Expand Up @@ -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);
});

});
});
});
};

0 comments on commit 8708919

Please sign in to comment.