Fix: calcul de la place dans un conteneur
Correction de l'ajout dans un conteneur, en faisant un calcul arrondi pour éviter les problèmes de virgule flotante
This commit is contained in:
@ -395,6 +395,16 @@ export class RdDItem extends Item {
|
||||
return Math.max(this.system.encombrement ?? 0, 0);
|
||||
}
|
||||
|
||||
getEncContenu() {
|
||||
return this.getContenu()
|
||||
.map(it => it.getRecursiveEnc())
|
||||
.reduce(Misc.sum(), 0);
|
||||
}
|
||||
|
||||
getRecursiveEnc() {
|
||||
return this.getEncTotal() + this.getEncContenu()
|
||||
}
|
||||
|
||||
getEncHerbe() {
|
||||
switch (this.system.categorie) {
|
||||
case 'Repos': case 'Soin': case 'Alchimie':
|
||||
@ -404,6 +414,18 @@ export class RdDItem extends Item {
|
||||
|
||||
}
|
||||
|
||||
getContenu() {
|
||||
if (this.isConteneur()) {
|
||||
return this.system.contenu.map(idContenu => this.actor.getItem(idContenu));
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
isConteneurContenu(conteneur) {
|
||||
return this.getContenu()
|
||||
.find(it => it.id == conteneur.id || it.isConteneurContenu(conteneur))
|
||||
}
|
||||
|
||||
valeurTotale() {
|
||||
return (this.isService() ? 1 : this.getQuantite()) * this.valeur()
|
||||
}
|
||||
@ -675,7 +697,7 @@ export class RdDItem extends Item {
|
||||
_armeChatData() {
|
||||
return [
|
||||
`<b>Compétence</b>: ${this.system.competence}`,
|
||||
`<b>Dommages</b>: ${this.system.dommages} ${this.system.mortalite=='non-mortel'? '(Non mortel)':''}`,
|
||||
`<b>Dommages</b>: ${this.system.dommages} ${this.system.mortalite == 'non-mortel' ? '(Non mortel)' : ''}`,
|
||||
`<b>Force minimum</b>: ${this.system.force}`,
|
||||
`<b>Resistance</b>: ${this.system.resistance}`,
|
||||
...this._inventaireTemplateChatData()
|
||||
|
Reference in New Issue
Block a user