mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: compact format tech tree
This commit is contained in:
1 parent
c39351929c
commit
fe98d52c31
7 files changed
+24
-32
No files matched your search
@@ -4,11 +4,11 @@ import { InfoCircledIcon } from '@radix-ui/react-icons';
|
|||||||
import { Callout, Flex } from '@radix-ui/themes';
|
import { Callout, Flex } from '@radix-ui/themes';
|
||||||
import { use } from 'react';
|
import { use } from 'react';
|
||||||
import { averageDefinitions } from '../../../../core/blitzkit/averageDefinitions';
|
import { averageDefinitions } from '../../../../core/blitzkit/averageDefinitions';
|
||||||
|
import { formatCompact } from '../../../../core/math/formatCompact';
|
||||||
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
||||||
|
|
||||||
export function Info() {
|
export function Info() {
|
||||||
const awaitedAverageDefinitions = use(averageDefinitions);
|
const awaitedAverageDefinitions = use(averageDefinitions);
|
||||||
const numberFormat = Intl.NumberFormat(undefined, { notation: 'compact' });
|
|
||||||
const ratio = useAveragesExclusionRatio();
|
const ratio = useAveragesExclusionRatio();
|
||||||
const samples = ratio * awaitedAverageDefinitions.samples.d_120;
|
const samples = ratio * awaitedAverageDefinitions.samples.d_120;
|
||||||
|
|
||||||
@@ -19,9 +19,9 @@ export function Info() {
|
|||||||
<InfoCircledIcon />
|
<InfoCircledIcon />
|
||||||
</Callout.Icon>
|
</Callout.Icon>
|
||||||
<Callout.Text>
|
<Callout.Text>
|
||||||
Career stats based on {numberFormat.format(Math.round(samples))}{' '}
|
Career stats based on {formatCompact(Math.round(samples))} players
|
||||||
players with at least 5K career battles and 1 battle in the past 120
|
with at least 5K career battles and 1 battle in the past 120 days;
|
||||||
days; updated daily.
|
updated daily.
|
||||||
</Callout.Text>
|
</Callout.Text>
|
||||||
</Callout.Root>
|
</Callout.Root>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { memo, use } from 'react';
|
|||||||
import { TankRowHeaderCell } from '../../../../components/TankRowHeaderCell';
|
import { TankRowHeaderCell } from '../../../../components/TankRowHeaderCell';
|
||||||
import { averageDefinitions } from '../../../../core/blitzkit/averageDefinitions';
|
import { averageDefinitions } from '../../../../core/blitzkit/averageDefinitions';
|
||||||
import { TankDefinition } from '../../../../core/blitzkit/tankDefinitions';
|
import { TankDefinition } from '../../../../core/blitzkit/tankDefinitions';
|
||||||
|
import { formatCompact } from '../../../../core/math/formatCompact';
|
||||||
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
||||||
|
|
||||||
interface TankRowProps {
|
interface TankRowProps {
|
||||||
@@ -13,7 +14,6 @@ export const TankRow = memo<TankRowProps>(
|
|||||||
({ tank }) => {
|
({ tank }) => {
|
||||||
const awaitedAverageDefinitions = use(averageDefinitions);
|
const awaitedAverageDefinitions = use(averageDefinitions);
|
||||||
const averages = awaitedAverageDefinitions.averages[tank.id];
|
const averages = awaitedAverageDefinitions.averages[tank.id];
|
||||||
const numberFormat = Intl.NumberFormat(undefined, { notation: 'compact' });
|
|
||||||
const ratio = useAveragesExclusionRatio();
|
const ratio = useAveragesExclusionRatio();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -24,10 +24,10 @@ export const TankRow = memo<TankRowProps>(
|
|||||||
{((averages.mu.wins / averages.mu.battles) * 100).toFixed(1)}%
|
{((averages.mu.wins / averages.mu.battles) * 100).toFixed(1)}%
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell align="center">
|
<Table.Cell align="center">
|
||||||
{numberFormat.format(Math.round(ratio * averages.samples.d_30))}
|
{formatCompact(Math.round(ratio * averages.samples.d_30))}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell align="center">
|
<Table.Cell align="center">
|
||||||
{numberFormat.format(
|
{formatCompact(
|
||||||
Math.round(ratio * averages.mu.battles * averages.samples.total),
|
Math.round(ratio * averages.mu.battles * averages.samples.total),
|
||||||
)}
|
)}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import {
|
|||||||
Tier,
|
Tier,
|
||||||
} from '../../../../core/blitzkit/tankDefinitions';
|
} from '../../../../core/blitzkit/tankDefinitions';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
|
import { formatCompact } from '../../../../core/math/formatCompact';
|
||||||
import { nivoTheme } from '../../../../core/nivo/theme';
|
import { nivoTheme } from '../../../../core/nivo/theme';
|
||||||
import strings from '../../../../lang/en-US.json';
|
import strings from '../../../../lang/en-US.json';
|
||||||
|
|
||||||
export function TierBreakdown() {
|
export function TierBreakdown() {
|
||||||
const awaitedAverageDefinitionsArray = use(averageDefinitionsArray);
|
const awaitedAverageDefinitionsArray = use(averageDefinitionsArray);
|
||||||
const awaitedTankDefinitions = use(tankDefinitions);
|
const awaitedTankDefinitions = use(tankDefinitions);
|
||||||
const numberFormat = Intl.NumberFormat(undefined, { notation: 'compact' });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex justify="center" py="6">
|
<Flex justify="center" py="6">
|
||||||
@@ -57,14 +57,14 @@ export function TierBreakdown() {
|
|||||||
keys={[...TANK_CLASSES].reverse()}
|
keys={[...TANK_CLASSES].reverse()}
|
||||||
indexBy="tier"
|
indexBy="tier"
|
||||||
colors={{ scheme: 'dark2' }}
|
colors={{ scheme: 'dark2' }}
|
||||||
label={(d) => numberFormat.format(d.value as number)}
|
label={(d) => formatCompact(d.value as number)}
|
||||||
margin={{ right: 96, bottom: 20, left: 40 }}
|
margin={{ right: 96, bottom: 20, left: 40 }}
|
||||||
legendLabel={(d) =>
|
legendLabel={(d) =>
|
||||||
strings.common.tank_class_short[d.id as TankClass]
|
strings.common.tank_class_short[d.id as TankClass]
|
||||||
}
|
}
|
||||||
axisLeft={{
|
axisLeft={{
|
||||||
tickSize: 0,
|
tickSize: 0,
|
||||||
format: (value) => numberFormat.format(value as number),
|
format: (value) => formatCompact(value as number),
|
||||||
}}
|
}}
|
||||||
axisBottom={{ tickSize: 0 }}
|
axisBottom={{ tickSize: 0 }}
|
||||||
legends={[
|
legends={[
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
AverageDefinitionsAllStats,
|
AverageDefinitionsAllStats,
|
||||||
AverageDefinitionsEntryWithId,
|
AverageDefinitionsEntryWithId,
|
||||||
} from '../../../../core/blitzkit/averageDefinitions';
|
} from '../../../../core/blitzkit/averageDefinitions';
|
||||||
|
import { formatCompact } from '../../../../core/math/formatCompact';
|
||||||
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
import { useAveragesExclusionRatio } from '../../../../hooks/useAveragesExclusionRatio';
|
||||||
|
|
||||||
interface TotalProps {
|
interface TotalProps {
|
||||||
@@ -14,7 +15,6 @@ interface TotalProps {
|
|||||||
export const Total = memo<TotalProps>(
|
export const Total = memo<TotalProps>(
|
||||||
({ tanks }) => {
|
({ tanks }) => {
|
||||||
const ratio = useAveragesExclusionRatio();
|
const ratio = useAveragesExclusionRatio();
|
||||||
const numberFormat = Intl.NumberFormat(undefined, { notation: 'compact' });
|
|
||||||
const sum = useCallback(
|
const sum = useCallback(
|
||||||
(slice: (tank: AverageDefinitionsAllStats) => number) => {
|
(slice: (tank: AverageDefinitionsAllStats) => number) => {
|
||||||
return tanks.reduce(
|
return tanks.reduce(
|
||||||
@@ -45,12 +45,8 @@ export const Total = memo<TotalProps>(
|
|||||||
<Table.Row>
|
<Table.Row>
|
||||||
<StickyRowHeaderCell>Total</StickyRowHeaderCell>
|
<StickyRowHeaderCell>Total</StickyRowHeaderCell>
|
||||||
<Table.Cell align="center">{(winrate * 100).toFixed(1)}%</Table.Cell>
|
<Table.Cell align="center">{(winrate * 100).toFixed(1)}%</Table.Cell>
|
||||||
<Table.Cell align="center">
|
<Table.Cell align="center">{formatCompact(ratio * players)}</Table.Cell>
|
||||||
{numberFormat.format(ratio * players)}
|
<Table.Cell align="center">{formatCompact(ratio * battles)}</Table.Cell>
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell align="center">
|
|
||||||
{numberFormat.format(ratio * battles)}
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell align="center">
|
<Table.Cell align="center">
|
||||||
{Math.round(damage).toLocaleString()}
|
{Math.round(damage).toLocaleString()}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
} from '../../../../../../../core/blitzkit/tankDefinitions';
|
} from '../../../../../../../core/blitzkit/tankDefinitions';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
import { tankIcon } from '../../../../../../../core/blitzkit/tankIcon';
|
import { tankIcon } from '../../../../../../../core/blitzkit/tankIcon';
|
||||||
|
import { formatCompact } from '../../../../../../../core/math/formatCompact';
|
||||||
import * as Duel from '../../../../../../../stores/duel';
|
import * as Duel from '../../../../../../../stores/duel';
|
||||||
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
|
||||||
|
|
||||||
@@ -35,10 +36,6 @@ function ModuleButton({
|
|||||||
top: boolean;
|
top: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}) {
|
}) {
|
||||||
const numberFormat = Intl.NumberFormat(undefined, {
|
|
||||||
notation: 'compact',
|
|
||||||
maximumFractionDigits: 0,
|
|
||||||
});
|
|
||||||
const isTank = unlock.type === 'vehicle';
|
const isTank = unlock.type === 'vehicle';
|
||||||
const button = (
|
const button = (
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -77,7 +74,7 @@ function ModuleButton({
|
|||||||
gap={isTank ? '1' : undefined}
|
gap={isTank ? '1' : undefined}
|
||||||
>
|
>
|
||||||
<Text size="1" color="gray">
|
<Text size="1" color="gray">
|
||||||
{numberFormat.format(unlock.cost.value)}
|
{formatCompact(unlock.cost.value)}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import PageWrapper from '../../../../../../components/PageWrapper';
|
|||||||
import { asset } from '../../../../../../core/blitzkit/asset';
|
import { asset } from '../../../../../../core/blitzkit/asset';
|
||||||
import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions';
|
import { tankDefinitions } from '../../../../../../core/blitzkit/tankDefinitions';
|
||||||
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
import { TIER_ROMAN_NUMERALS } from '../../../../../../core/blitzkit/tankDefinitions/constants';
|
||||||
|
import { formatCompact } from '../../../../../../core/math/formatCompact';
|
||||||
import * as Duel from '../../../../../../stores/duel';
|
import * as Duel from '../../../../../../stores/duel';
|
||||||
|
|
||||||
export function TreeArrow({
|
export function TreeArrow({
|
||||||
@@ -99,7 +100,7 @@ export function TechTreeSection() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Text color="gray" size="1">
|
<Text color="gray" size="1">
|
||||||
{ancestor.xp?.toLocaleString()}
|
{formatCompact(ancestor.xp!)}
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ export function TechTreeSection() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Text color="gray" size="1">
|
<Text color="gray" size="1">
|
||||||
{ancestor.price.value?.toLocaleString()}
|
{formatCompact(ancestor.price.value)}
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -141,14 +142,7 @@ export function TechTreeSection() {
|
|||||||
<Heading>Tech tree</Heading>
|
<Heading>Tech tree</Heading>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{/* BIG TODO: use number format to shorten currencies */}
|
<Flex align="center" gap="6" direction={{ initial: 'column', sm: 'row' }}>
|
||||||
|
|
||||||
<Flex
|
|
||||||
align="center"
|
|
||||||
gap="6"
|
|
||||||
style={{}}
|
|
||||||
direction={{ initial: 'column', sm: 'row' }}
|
|
||||||
>
|
|
||||||
{tank.ancestors && (
|
{tank.ancestors && (
|
||||||
<>
|
<>
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const numberFormat = Intl.NumberFormat('en', { notation: 'compact' });
|
||||||
|
|
||||||
|
export function formatCompact(number: number) {
|
||||||
|
return numberFormat.format(number);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user