fix miscalc in favor

This commit is contained in:
Olivier Gagnon 2021-09-05 01:50:26 -04:00
parent cfdf23cd11
commit a475e6297e
2 changed files with 3 additions and 2 deletions

File diff suppressed because one or more lines are too long

@ -89,10 +89,11 @@ export class Faction {
if (this.rolloverRep == null) { if (this.rolloverRep == null) {
this.rolloverRep = 0; this.rolloverRep = 0;
} }
const storedRep = favorToRep(this.favor - 1); const storedRep = Math.max(0, favorToRep(this.favor - 1));
const totalRep = storedRep + this.rolloverRep + this.playerReputation; const totalRep = storedRep + this.rolloverRep + this.playerReputation;
const newFavor = Math.floor(repToFavor(totalRep)); const newFavor = Math.floor(repToFavor(totalRep));
const newRep = favorToRep(newFavor); const newRep = favorToRep(newFavor);
console.log(`${storedRep} ${this.rolloverRep} ${this.playerReputation}`);
return [newFavor - this.favor + 1, totalRep - newRep]; return [newFavor - this.favor + 1, totalRep - newRep];
} }