Fix xp des compétences tronc #182
La méthode splice retourne les éléments supprimées, et non pas le tableau après suppression
This commit is contained in:
parent
f25ae66de1
commit
0ae77f6889
@ -151,11 +151,11 @@ export class RdDItemCompetence extends Item {
|
|||||||
static computeEconomieXPTronc(competences) {
|
static computeEconomieXPTronc(competences) {
|
||||||
return competenceTroncs.map(
|
return competenceTroncs.map(
|
||||||
list => list.map(name => RdDItemCompetence.findCompetence(competences, name))
|
list => list.map(name => RdDItemCompetence.findCompetence(competences, name))
|
||||||
// calcul du coût xp jusqu'au niveau 0 maximum
|
// calcul du coût xp jusqu'au niveau 0 maximum
|
||||||
.map(it => RdDItemCompetence.computeDeltaXP(it?.data.base ?? -11, Math.min(it?.data.niveau ?? -11, 0)))
|
.map(it => RdDItemCompetence.computeDeltaXP(it?.data.base ?? -11, Math.min(it?.data.niveau ?? -11, 0)))
|
||||||
.sort(Misc.descending(x => x))
|
.sort(Misc.ascending())
|
||||||
.splice(0, 1) // ignorer le coût xp le plus élevé
|
.splice(0, list.length-1) // prendre toutes les valeurs sauf l'une des plus élevées
|
||||||
.reduce(Misc.sum(), 0)
|
.reduce(Misc.sum(), 0)
|
||||||
).reduce(Misc.sum(), 0);
|
).reduce(Misc.sum(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ export class Misc {
|
|||||||
return (a, b) => a + b;
|
return (a, b) => a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ascending(orderFunction) {
|
static ascending(orderFunction = x=>x) {
|
||||||
return (a, b) => Misc.sortingBy(orderFunction(a), orderFunction(b));
|
return (a, b) => Misc.sortingBy(orderFunction(a), orderFunction(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static descending(orderFunction) {
|
static descending(orderFunction = x=>x) {
|
||||||
return (a, b) => Misc.sortingBy(orderFunction(b), orderFunction(a));
|
return (a, b) => Misc.sortingBy(orderFunction(b), orderFunction(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user