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

@ -18,5 +18,22 @@ export class RdDActorVehiculeSheet extends RdDActorSheet {
});
}
activateListeners(html) {
super.activateListeners(html);
if (!this.options.editable) return;
html.find('.resistance-moins').click(async event => {
this.actor.vehicleIncDec("resistance", -1);
});
html.find('.resistance-plus').click(async event => {
this.actor.vehicleIncDec("resistance", 1);
});
html.find('.structure-moins').click(async event => {
this.actor.vehicleIncDec("structure", -1);
});
html.find('.structure-plus').click(async event => {
this.actor.vehicleIncDec("structure", 1);
});
}
}

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()