refactoring 1

This commit is contained in:
François-Xavier Guillois
2023-09-05 18:47:36 +02:00
parent 3ceac1194e
commit c376055bf3
5 changed files with 71 additions and 90 deletions
-84
View File
@@ -45,87 +45,3 @@ export function updateActorSkillScore(selectedActor, skillLabel, property = "val
}
}
/**
* renvoie le score de Sang froid (carac mental + social)
* @param {VermineActor}
* @return {number||null} Data for rendering or null
*/
export function setCharacterSelfControl(actor) {
let returnedValue = null;
for(let i in actor.system.abilities){
if (actor.system.abilities[i].category == 'mental' || actor.system.abilities[i].category == 'social'){
returnedValue += actor.system.abilities[i].value;
}
}
/// gestion de l'age
if (actor.system.identity.ageType == 1){
returnedValue--;
}
actor.update({ "system.attributes.self_control.max": returnedValue });
return returnedValue;
}
/**
* renvoie le score d'Effort (carac physical + manual)
* @param {VermineActor}
* @return {number||null} Data for rendering or null
*/
export function setCharacterEffort(actor) {
let returnedValue = null;
for(let i in actor.system.abilities){
if (actor.system.abilities[i].category == 'physical' || actor.system.abilities[i].category == 'manual'){
returnedValue += actor.system.abilities[i].value;
}
}
/// gestion de l'age
if (actor.system.identity.ageType == 1){
returnedValue--;
} else if (actor.system.identity.ageType == 3){
returnedValue -= 2;
}
actor.update({ "system.attributes.effort.max": returnedValue });
return returnedValue;
}
/**
* définis les scores de seuil
* @param {VermineActor}
* @return {number||null} Data for rendering or null
*/
export function setCharacterThresholds(actor) {
const health = actor.system.abilities.health.value;
let returnedValue = null;
actor.update({ "system.minorWound.threshold": health });
actor.update({ "system.majorWound.threshold": health + 3});
actor.update({ "system.deadlyWound.threshold": (health + 7 < 11) ? health + 7 : 10 });
let lightWounds = 4;
let heavyWounds = 3;
let deadlyWounds = 2;
if (actor.system.identity.ageType == 3){
lightWounds--;
heavyWounds--;
deadlyWounds--;
} else if (actor.system.identity.ageType == 1){
deadlyWounds--;
}
actor.update({ "system.minorWound.max": lightWounds });
actor.update({ "system.majorWound.max": heavyWounds });
actor.update({ "system.deadlyWound.max": deadlyWounds });
// console.log('wounds', actor.system.minorWound, actor.system.majorWound, actor.system.deadlyWound);
return returnedValue;
}