2024-11-29 13:20:27 -06:00
|
|
|
import { TankDefinition, formatCompact } from '@blitzkit/core';
|
2024-06-30 19:34:55 -05:00
|
|
|
import { Table } from '@radix-ui/themes';
|
2024-10-07 17:31:13 -05:00
|
|
|
import { memo } from 'react';
|
2024-11-29 13:20:27 -06:00
|
|
|
import { awaitableAverageDefinitions } from '../../core/awaitables/averageDefinitions';
|
2024-10-07 17:31:13 -05:00
|
|
|
import { useAveragesExclusionRatio } from '../../hooks/useAveragesExclusionRatio';
|
2024-10-21 21:03:49 -05:00
|
|
|
import { TankPerformanceEphemeral } from '../../stores/tankPerformanceEphemeral';
|
2024-10-07 17:31:13 -05:00
|
|
|
import { TankRowHeaderCell } from '../TankRowHeaderCell';
|
2024-06-30 19:34:55 -05:00
|
|
|
|
|
|
|
|
interface TankRowProps {
|
|
|
|
|
tank: TankDefinition;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-29 13:20:27 -06:00
|
|
|
const averageDefinitions = await awaitableAverageDefinitions;
|
2024-10-07 17:31:13 -05:00
|
|
|
|
2024-06-30 19:34:55 -05:00
|
|
|
export const TankRow = memo<TankRowProps>(
|
|
|
|
|
({ tank }) => {
|
2024-10-07 17:31:13 -05:00
|
|
|
const averages = averageDefinitions.averages[tank.id];
|
2024-07-07 18:56:49 -05:00
|
|
|
const ratio = useAveragesExclusionRatio();
|
2024-10-21 21:03:49 -05:00
|
|
|
const playerCountPeriod = TankPerformanceEphemeral.use(
|
2024-07-12 13:53:11 -05:00
|
|
|
(state) => state.playerCountPeriod,
|
|
|
|
|
);
|
2024-06-30 19:34:55 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Table.Row>
|
|
|
|
|
<TankRowHeaderCell tank={tank} />
|
2024-07-02 18:42:23 -05:00
|
|
|
|
2024-06-30 19:34:55 -05:00
|
|
|
<Table.Cell align="center">
|
2024-07-02 18:58:11 -05:00
|
|
|
{((averages.mu.wins / averages.mu.battles) * 100).toFixed(1)}%
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-12 13:53:11 -05:00
|
|
|
{formatCompact(
|
|
|
|
|
Math.round(ratio * averages.samples[playerCountPeriod]),
|
|
|
|
|
)}
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 19:41:13 -05:00
|
|
|
{Math.round(
|
|
|
|
|
averages.mu.damage_dealt / averages.mu.battles,
|
|
|
|
|
).toLocaleString()}
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 19:41:13 -05:00
|
|
|
{Math.round(
|
|
|
|
|
(averages.mu.survived_battles / averages.mu.battles) * 100,
|
|
|
|
|
)}
|
|
|
|
|
%
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 19:41:13 -05:00
|
|
|
{Math.round(averages.mu.xp / averages.mu.battles).toLocaleString()}
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 19:41:13 -05:00
|
|
|
{(averages.mu.frags / averages.mu.battles).toFixed(2)}
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 19:41:13 -05:00
|
|
|
{(averages.mu.spotted / averages.mu.battles).toFixed(2)}
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 20:18:09 -05:00
|
|
|
{Math.round((averages.mu.hits / averages.mu.shots) * 100)}%
|
2024-07-01 19:41:13 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
|
|
|
|
{(averages.mu.shots / averages.mu.battles).toFixed(1)}
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
|
|
|
|
{(averages.mu.hits / averages.mu.battles).toFixed(1)}
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
2024-07-01 20:18:09 -05:00
|
|
|
{(averages.mu.damage_dealt / averages.mu.damage_received).toFixed(2)}
|
2024-07-01 19:41:13 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
|
|
|
|
{Math.round(
|
|
|
|
|
averages.mu.damage_received / averages.mu.battles,
|
|
|
|
|
).toLocaleString()}
|
|
|
|
|
</Table.Cell>
|
|
|
|
|
<Table.Cell align="center">
|
|
|
|
|
{(averages.mu.capture_points / averages.mu.battles).toFixed(2)}
|
2024-06-30 19:34:55 -05:00
|
|
|
</Table.Cell>
|
|
|
|
|
</Table.Row>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
(prev, next) => prev.tank.id === next.tank.id,
|
|
|
|
|
);
|