Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/schemas/src/player/gamemodes/pit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { type ExtractGameModes, GameModes } from "#game";
import { Field } from "#metadata";
import { Progression } from "#progression";
import {
FINAL_PRESTIGE_XP,
RenownUnlock,
getBounty,
getLevel,
Expand Down Expand Up @@ -161,11 +162,13 @@ export class Pit {

this.trueLevel = prestige * 120 + level;

const prestigeReq = getPrestigeReq(prestige);
const lastPrestigeReq = getPrestigeReq(prestige - 1);

// XP past the final requirement would push the progress bar over 100%
this.progression = new Progression(
this.exp - lastPrestigeReq,
Math.min(getPrestigeReq(prestige) - lastPrestigeReq, 11_787_293_080)
Math.min(this.exp, prestigeReq) - lastPrestigeReq,
Math.min(prestigeReq - lastPrestigeReq, FINAL_PRESTIGE_XP)
);

this.levelFormatted = getLevelFormatted(level, prestige);
Expand Down
9 changes: 6 additions & 3 deletions packages/schemas/src/player/gamemodes/pit/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const PRESTIGE_XP_REQUIREMENTS = [
11_787_293_080,
];

export const FINAL_PRESTIGE_XP =
PRESTIGE_XP_REQUIREMENTS[PRESTIGE_XP_REQUIREMENTS.length - 1];

const PRESTIGE_COLORS = [
"7",
"9",
Expand Down Expand Up @@ -70,13 +73,13 @@ export type Bounty = {
};

export const getPrestige = (xp: number) => {
for (let i = 0; i <= 50; i++) {
for (let i = 0; i < PRESTIGE_XP_REQUIREMENTS.length; i++) {
if (xp <= PRESTIGE_XP_REQUIREMENTS[i]) {
return i;
}
}

return PRESTIGE_XP_REQUIREMENTS[1];
return PRESTIGE_XP_REQUIREMENTS.length - 1;
};

export const getPrestigeReq = (prestige: number) =>
Expand All @@ -86,7 +89,7 @@ export const getLevel = (pres: number, xp: number) => {
let level = 120;
if (
(4_042_276_727 <= xp && xp <= 5_192_293_080) ||
(7_339_776_727 <= xp && xp <= 11_787_293_080)
(7_339_776_727 <= xp && xp <= FINAL_PRESTIGE_XP)
)
return 120;

Expand Down
Loading