mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
23 lines
635 B
TypeScript
23 lines
635 B
TypeScript
import { AllStats } from '../../_core/blitz/getAccountInfo';
|
|
import { TierWeightsRecord } from '../../components/TierWeights';
|
|
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;
|
|
}
|