#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:
25
module/item-sort.js
Normal file
25
module/item-sort.js
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user