#46 lancer de sort

Fix regressions:
- renommage updatePointsDeReve pas fait partout
- coût de rêve des sort fixes

introduction de RdDItemSort pour grouper les fonctions
liées aux sorts (et tester les sorts variables partout pareil)
This commit is contained in:
2020-11-27 10:21:20 +01:00
parent dca4e28044
commit 759626ebbe
6 changed files with 49 additions and 22 deletions

25
module/item-sort.js Normal file
View File

@ -0,0 +1,25 @@
import { Misc } from "./misc.js";
export class RdDItemSort extends Item {
static isDifficulteVariable(sort) {
return sort && (sort.data.difficulte.toLowerCase() == "variable");
}
static isCoutVariable(sort) {
return sort && (sort.data.ptreve.toLowerCase() == "variable" || sort.data.ptreve.indexOf("+") >= 0);
}
static setCoutReveReel(sort){
if (sort) {
sort.data.ptreve_reel = this.isCoutVariable(sort) ? 1 : sort.data.ptreve;
}
}
static getDifficulte(sort, variable) {
if (sort && !RdDItemSort.isDifficulteVariable(sort)) {
return Misc.toInt(sort.data.difficulte);
}
return variable;
}
}