Fix: Sustentation consommée parfois concaténée
This commit is contained in:
parent
681358238d
commit
ab4c118d12
@ -1722,16 +1722,17 @@ export class RdDActor extends RdDBaseActor {
|
||||
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||
const sust = item.system.sust
|
||||
if (sust > 0) {
|
||||
await this.updateCompteurValue('sust', Misc.keepDecimals(this.system.compteurs.sust.value + sust * doses, 1));
|
||||
await this.updateCompteurValue('sust', RdDActor.$calculNewSust(this.system.compteurs.sust.value, sust, doses));
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||
const desaltere = item.system.desaltere;
|
||||
if (desaltere > 0) {
|
||||
await this.updateCompteurValue('eau', Misc.keepDecimals(this.system.compteurs.eau.value + desaltere * doses, 1));
|
||||
await this.updateCompteurValue('eau', RdDActor.$calculNewSust(this.system.compteurs.eau.value, desaltere, doses));
|
||||
}
|
||||
if (item.isAlcool()) {
|
||||
for (let i = 0; i < doses; i++) {
|
||||
@ -1741,6 +1742,10 @@ export class RdDActor extends RdDBaseActor {
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
static $calculNewSust(value, sust, doses) {
|
||||
return Misc.keepDecimals(Number(value) + Number(sust) * Number(doses), 1);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async saouler(forceAlcool, alcool = undefined) {
|
||||
let ethylisme = duplicate(this.system.compteurs.ethylisme);
|
||||
|
Loading…
Reference in New Issue
Block a user