Skip to content

Commit

Permalink
Fixed group EXP multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcgode committed Sep 25, 2021
1 parent 5e9aa02 commit 7fc8381
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions build/pf2_encounter_planner.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@
}

if (players.length) {
let maxLevel = Math.max(...Object.values(this.playerHistory).map(p => p.last().level));
let maxXp = Math.min(...Object.values(this.playerHistory).filter(p => p.last().level === maxLevel).map(p => p.last().level * 1000 + p.last().xp));
let maxLevel = Math.max(...players.map(p => p.level));
let maxXp = Math.min(...players.filter(p => p.level === maxLevel).map(p => p.level * 1000 + p.xp));

let xp;
switch (component.type) {
Expand Down Expand Up @@ -708,7 +708,7 @@
xp = component.getEncounterXpPerPlayer();
}

this.xpChange[event.id] = xp;
this.xpChange[event.id] = Math.round(xp);
xp = xp || 0;

for (let player of players) {
Expand All @@ -721,7 +721,7 @@

this.playerHistory[player.id].push({
index: index,
xp: player.xp + additionalXp,
xp: Math.round(player.xp + additionalXp),
level: player.level
});
}
Expand Down
16 changes: 8 additions & 8 deletions build/pf2_encounter_planner.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,8 @@ t && r.push(Object.assign({id: e}, t.last()));
}
if (r.length) {
let i,
o = Math.max(...Object.values(this.playerHistory).map(e => e.last().level)),
a = Math.min(
...Object.values(this.playerHistory)
.filter(e => e.last().level === o)
.map(e => 1e3 * e.last().level + e.last().xp)
);
o = Math.max(...r.map(e => e.level)),
a = Math.min(...r.filter(e => e.level === o).map(e => 1e3 * e.level + e.xp));
switch (s.type) {
case t.FIGHT:
let e = this.session.getPlayerGroupLevel(r),
Expand All @@ -439,15 +435,19 @@ break;
default:
i = s.getEncounterXpPerPlayer();
}
(this.xpChange[n.id] = i), (i = i || 0);
(this.xpChange[n.id] = Math.round(i)), (i = i || 0);
for (let t of r) {
t.level < o && console.log(t, o, a);
let n =
t.level < o
? i * Math.max(1, this.session.params.underLeveledPlayerMultiplier)
: i;
(n = Math.max(i, Math.min(n, i + a - 1e3 * t.level - t.xp))),
this.playerHistory[t.id].push({index: e, xp: t.xp + n, level: t.level});
this.playerHistory[t.id].push({
index: e,
xp: Math.round(t.xp + n),
level: t.level
});
}
} else this.errorEvents.push({event: n, reason: "No player for this event"});
} else this.errorEvents.push({event: n, reason: "Invalid event"});
Expand Down
4 changes: 2 additions & 2 deletions src/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export class Timeline
}

if (players.length) {
let maxLevel = Math.max(...Object.values(this.playerHistory).map(p => p.last().level))
let maxXp = Math.min(...Object.values(this.playerHistory).filter(p => p.last().level === maxLevel).map(p => p.last().level * 1000 + p.last().xp))
let maxLevel = Math.max(...players.map(p => p.level))
let maxXp = Math.min(...players.filter(p => p.level === maxLevel).map(p => p.level * 1000 + p.xp))

let xp;
switch (component.type) {
Expand Down

0 comments on commit 7fc8381

Please sign in to comment.