diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js index 2729f2af..5803f3f7 100644 --- a/module/actor-vehicule-sheet.js +++ b/module/actor-vehicule-sheet.js @@ -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); + }); + } } diff --git a/module/actor.js b/module/actor.js index a49c3a25..d9af9b98 100644 --- a/module/actor.js +++ b/module/actor.js @@ -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() diff --git a/templates/actor-vehicule-sheet.html b/templates/actor-vehicule-sheet.html index 3c3f60db..e21924c5 100644 --- a/templates/actor-vehicule-sheet.html +++ b/templates/actor-vehicule-sheet.html @@ -2,13 +2,37 @@ {{!-- Sheet Header --}}
-
-

+ +
+

+
+
+
    +
  • + RĂ©sistance + + + / + + +
  • +
  • + Structure + + + / + + +
  • +
+
+
+
-
+ {{!-- Sheet Tab Navigation --}}