mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 14:16:00 +01:00
23 lines
634 B
TypeScript
23 lines
634 B
TypeScript
import { TierWeightsRecord } from '../../components/TierWeights';
|
|
import { AllStats } from '../../core/blitz/getAccountInfo';
|
|
import { tankopedia } from '../blitz/tankopedia';
|
|
|
|
export async function getTierWeights(
|
|
stats: Record<number, AllStats>,
|
|
order: number[] = Object.keys(stats).map(parseInt),
|
|
) {
|
|
const awaitedTankopedia = await tankopedia;
|
|
const tierWeights: TierWeightsRecord = {};
|
|
|
|
order.map((id) => {
|
|
const entry = awaitedTankopedia[id];
|
|
|
|
if (!entry) return;
|
|
if (!tierWeights[entry.tier]) tierWeights[entry.tier] = 0;
|
|
|
|
tierWeights[entry.tier]! += stats[id].battles;
|
|
});
|
|
|
|
return tierWeights;
|
|
}
|