mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: a drew redundancies
This commit is contained in:
1 parent
7fd128ac49
commit
d88cb02d94
2 files changed
+67
-78
No files matched your search
+67
-67
@@ -7,9 +7,11 @@ import Wrapper from '../components/Wrapper';
|
|||||||
import { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo';
|
import { AllStats, getAccountInfo } from '../core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
import { getClanAccountInfo } from '../core/blitz/getClanAccountInfo';
|
||||||
import getTankStats from '../core/blitz/getTankStats';
|
import getTankStats from '../core/blitz/getTankStats';
|
||||||
import getTreeType from '../core/blitz/getTreeType';
|
|
||||||
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
import { filtersToDescription } from '../core/blitzkrieg/filtersToDescription';
|
||||||
import { tankDefinitions } from '../core/blitzkrieg/tankDefinitions';
|
import {
|
||||||
|
TankDefinition,
|
||||||
|
tankDefinitions,
|
||||||
|
} from '../core/blitzkrieg/tankDefinitions';
|
||||||
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
import { getBlitzStarsLinkButton } from '../core/blitzstars/getBlitzStarsLinkButton';
|
||||||
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
import getStatsInPeriod from '../core/blitzstars/getStatsInPeriod';
|
||||||
import { tankAverages } from '../core/blitzstars/tankAverages';
|
import { tankAverages } from '../core/blitzstars/tankAverages';
|
||||||
@@ -36,7 +38,7 @@ import getWN8Percentile from '../core/statistics/getWN8Percentile';
|
|||||||
import { CommandRegistryPromisable } from '../events/interactionCreate';
|
import { CommandRegistryPromisable } from '../events/interactionCreate';
|
||||||
|
|
||||||
const ROWS_PER_PAGE = 8;
|
const ROWS_PER_PAGE = 8;
|
||||||
const MAX_PAGES = 10;
|
const MAX_PAGES = 9;
|
||||||
|
|
||||||
export async function renderBreakdown(
|
export async function renderBreakdown(
|
||||||
{ region, id }: ResolvedPlayer,
|
{ region, id }: ResolvedPlayer,
|
||||||
@@ -180,68 +182,68 @@ export async function renderBreakdown(
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all(
|
filteredOrder.forEach((id, index) => {
|
||||||
filteredOrder.map(async (id, index) => {
|
const tankDefinition = awaitedTankDefinitions[id] as
|
||||||
const tankDefinition = awaitedTankDefinitions[id];
|
| TankDefinition
|
||||||
const current = orderedCurrentStats[index];
|
| undefined;
|
||||||
const career = orderedCareerStats[index];
|
const current = orderedCurrentStats[index];
|
||||||
const currentWN8 = orderedCurrentWN8[index];
|
const career = orderedCareerStats[index];
|
||||||
const careerWN8 = orderedCareerWN8[index];
|
const currentWN8 = orderedCurrentWN8[index];
|
||||||
|
const careerWN8 = orderedCareerWN8[index];
|
||||||
|
|
||||||
children.push(
|
children.push(
|
||||||
<Breakdown.Row
|
<Breakdown.Row
|
||||||
key={id}
|
key={id}
|
||||||
type="tank"
|
type="tank"
|
||||||
tankType={tankDefinition?.type}
|
tankType={tankDefinition?.type}
|
||||||
treeType={tankDefinition ? await getTreeType(id) : undefined}
|
treeType={tankDefinition?.treeType}
|
||||||
title={awaitedTankDefinitions[id].name}
|
title={tankDefinition?.name ?? `Unknown tank ${id}`}
|
||||||
stats={[
|
stats={[
|
||||||
{
|
{
|
||||||
title: 'Battles',
|
title: 'Battles',
|
||||||
current: current.battles.toLocaleString(),
|
current: current.battles.toLocaleString(),
|
||||||
career: career.battles.toLocaleString(),
|
career: career.battles.toLocaleString(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Winrate',
|
title: 'Winrate',
|
||||||
current: `${(100 * (current.wins / current.battles)).toFixed(
|
current: `${(100 * (current.wins / current.battles)).toFixed(
|
||||||
2,
|
2,
|
||||||
)}%`,
|
)}%`,
|
||||||
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
career: `${(100 * (career.wins / career.battles)).toFixed(2)}%`,
|
||||||
delta:
|
delta:
|
||||||
current.wins / current.battles - career.wins / career.battles,
|
current.wins / current.battles - career.wins / career.battles,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'WN8',
|
title: 'WN8',
|
||||||
current:
|
current:
|
||||||
currentWN8 === undefined
|
currentWN8 === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: Math.round(currentWN8).toLocaleString(),
|
: Math.round(currentWN8).toLocaleString(),
|
||||||
career:
|
career:
|
||||||
careerWN8 === undefined
|
careerWN8 === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: Math.round(careerWN8).toLocaleString(),
|
: Math.round(careerWN8).toLocaleString(),
|
||||||
percentile:
|
percentile:
|
||||||
currentWN8 === undefined
|
currentWN8 === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: getWN8Percentile(currentWN8),
|
: getWN8Percentile(currentWN8),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Damage',
|
title: 'Damage',
|
||||||
current: Math.round(
|
current: Math.round(
|
||||||
current.damage_dealt / current.battles,
|
current.damage_dealt / current.battles,
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
career: Math.round(
|
career: Math.round(
|
||||||
career.damage_dealt / career.battles,
|
career.damage_dealt / career.battles,
|
||||||
).toLocaleString(),
|
).toLocaleString(),
|
||||||
delta:
|
delta:
|
||||||
current.damage_dealt / current.battles -
|
current.damage_dealt / current.battles -
|
||||||
career.damage_dealt / career.battles,
|
career.damage_dealt / career.battles,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages = chunk(
|
const pages = chunk(
|
||||||
@@ -282,9 +284,7 @@ export async function renderBreakdown(
|
|||||||
description={`${name} • ${filterDescriptions}`}
|
description={`${name} • ${filterDescriptions}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{filteredOrder.length === 0 && (
|
<NoData type={NoDataType.BattlesInPeriod} />
|
||||||
<NoData type={NoDataType.BattlesInPeriod} />
|
|
||||||
)}
|
|
||||||
</Wrapper>,
|
</Wrapper>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { TreeType } from '../../components/Tanks';
|
|
||||||
import { tankDefinitions } from '../blitzkrieg/tankDefinitions';
|
|
||||||
|
|
||||||
export default async function getTreeType(id: number): Promise<TreeType> {
|
|
||||||
const entry = (await tankDefinitions)[id];
|
|
||||||
|
|
||||||
if (entry.treeType === 'collector') return 'collector';
|
|
||||||
if (entry.treeType === 'premium') return 'premium';
|
|
||||||
|
|
||||||
return 'researchable';
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user