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 }) {
|
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||||
const sust = item.system.sust
|
const sust = item.system.sust
|
||||||
if (sust > 0) {
|
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);
|
await item.diminuerQuantite(doses, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||||
const desaltere = item.system.desaltere;
|
const desaltere = item.system.desaltere;
|
||||||
if (desaltere > 0) {
|
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()) {
|
if (item.isAlcool()) {
|
||||||
for (let i = 0; i < doses; i++) {
|
for (let i = 0; i < doses; i++) {
|
||||||
@ -1740,6 +1741,10 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
await item.diminuerQuantite(doses, options);
|
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) {
|
async saouler(forceAlcool, alcool = undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user