Feuille de véhicule avec compteurs

This commit is contained in:
Vincent Vandemeulebrouck
2022-11-28 21:01:28 +01:00
parent e35f77b5a8
commit 7557d33c73
3 changed files with 56 additions and 19 deletions

View File

@ -1779,6 +1779,18 @@ export class RdDActor extends Actor {
}
return result;
}
async vehicleIncDec(name, inc) {
if (!this.isVehicule() || !['resistance', 'structure'].includes(name)) {
return
}
const value = this.system.etat[name].value;
const max = this.system.etat[name].max;
const newValue = value + inc;
if (0 <= newValue && newValue <=max) {
await this.update({ [`system.etat.${name}.value`]: newValue })
}
}
isDead() {
return !this.isEntite() && this.system.sante.vie.value < -this.getSConst()