Expand website and game trackers
Some checks failed
Test and deploy staging / staging (push) Failing after 5m29s
Some checks failed
Test and deploy staging / staging (push) Failing after 5m29s
This commit is contained in:
43
src/lib/game-tracker/rank-limits.ts
Normal file
43
src/lib/game-tracker/rank-limits.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { MasteryRules } from './mastery';
|
||||
|
||||
export type RankLimits = {
|
||||
maxLevel: number | null;
|
||||
maxPrestige: number;
|
||||
canPrestigeOnlyAtMaxLevel: boolean;
|
||||
rankable: boolean;
|
||||
};
|
||||
|
||||
const capsFor = (rules: MasteryRules) => rules.rankCaps;
|
||||
|
||||
export function playerRankLimits(rules: MasteryRules): RankLimits {
|
||||
const caps = capsFor(rules)?.player;
|
||||
return {
|
||||
maxLevel: caps?.level ?? null,
|
||||
maxPrestige: caps?.prestige ?? 1000,
|
||||
canPrestigeOnlyAtMaxLevel: false,
|
||||
rankable: true
|
||||
};
|
||||
}
|
||||
|
||||
export function weaponRankLimits(
|
||||
rules: MasteryRules,
|
||||
weapon: Pick<{ category: string; name: string }, 'category' | 'name'>
|
||||
): RankLimits {
|
||||
const caps = capsFor(rules);
|
||||
if (!caps) {
|
||||
return {
|
||||
maxLevel: null,
|
||||
maxPrestige: 1000,
|
||||
canPrestigeOnlyAtMaxLevel: false,
|
||||
rankable: true
|
||||
};
|
||||
}
|
||||
const maxLevel =
|
||||
caps.weaponLevelOverrides?.[weapon.name] ?? caps.weaponLevelsByClass[weapon.category] ?? null;
|
||||
return {
|
||||
maxLevel,
|
||||
maxPrestige: caps.weaponPrestige,
|
||||
canPrestigeOnlyAtMaxLevel: true,
|
||||
rankable: maxLevel !== null
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user