mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: totals
This commit is contained in:
1 parent
781d2da933
commit
c2abc94241
1 file changed
+70
-23
@@ -1,6 +1,7 @@
|
|||||||
import { CaretLeftIcon, CaretRightIcon, PlusIcon } from '@radix-ui/react-icons';
|
import { CaretLeftIcon, CaretRightIcon, PlusIcon } from '@radix-ui/react-icons';
|
||||||
import { Flex, Heading, IconButton, ScrollArea, Text } from '@radix-ui/themes';
|
import { Flex, Heading, IconButton, ScrollArea, Text } from '@radix-ui/themes';
|
||||||
import { use, useEffect, useMemo, useRef, useState } from 'react';
|
import { use, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { asset } from '../../../../../../../core/blitzkit/asset';
|
||||||
import { tankDefinitions } from '../../../../../../../core/blitzkit/tankDefinitions';
|
import { tankDefinitions } from '../../../../../../../core/blitzkit/tankDefinitions';
|
||||||
import * as Duel from '../../../../../../../stores/duel';
|
import * as Duel from '../../../../../../../stores/duel';
|
||||||
import { Arrow } from './components/Arrow';
|
import { Arrow } from './components/Arrow';
|
||||||
@@ -62,6 +63,14 @@ export function TechTreeSection() {
|
|||||||
() => [...lines[lineIndex]].toReversed(),
|
() => [...lines[lineIndex]].toReversed(),
|
||||||
[master, lineIndex],
|
[master, lineIndex],
|
||||||
);
|
);
|
||||||
|
const totalXp = line.reduce(
|
||||||
|
(xp, id) => xp + (awaitedTankDefinitions[id].xp ?? 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const totalCredits = line.reduce(
|
||||||
|
(credits, id) => credits + awaitedTankDefinitions[id].price.value,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
master.treeType !== 'researchable' ||
|
master.treeType !== 'researchable' ||
|
||||||
@@ -82,36 +91,48 @@ export function TechTreeSection() {
|
|||||||
my="6"
|
my="6"
|
||||||
direction="column"
|
direction="column"
|
||||||
align="center"
|
align="center"
|
||||||
gap="4"
|
gap="0"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: 'var(--color-surface)',
|
backgroundColor: 'var(--color-surface)',
|
||||||
}}
|
}}
|
||||||
py="6"
|
py="6"
|
||||||
>
|
>
|
||||||
<Flex gap="0" direction="column" align="center">
|
<Flex direction="column" align="center">
|
||||||
<Heading size="6">Tech tree</Heading>
|
<Heading size="6">Tech tree</Heading>
|
||||||
|
|
||||||
{lines.length > 1 && (
|
<Flex gap="4" align="center">
|
||||||
<Flex align="center" gap="2">
|
<Text color="gray" wrap="nowrap">
|
||||||
<IconButton
|
<Flex gap="1" align="center">
|
||||||
variant="soft"
|
<img
|
||||||
onClick={() =>
|
alt="XP"
|
||||||
setLineIndex((lines.length + lineIndex - 1) % lines.length)
|
src={asset('icons/currencies/xp.webp')}
|
||||||
}
|
style={{
|
||||||
>
|
width: '1em',
|
||||||
<CaretLeftIcon />
|
height: '1em',
|
||||||
</IconButton>
|
objectFit: 'contain',
|
||||||
<Text>
|
objectPosition: 'center',
|
||||||
Route {lineIndex + 1} of {lines.length}
|
}}
|
||||||
</Text>
|
/>
|
||||||
<IconButton
|
{totalXp.toLocaleString()}
|
||||||
variant="soft"
|
</Flex>
|
||||||
onClick={() => setLineIndex((lineIndex + 1) % lines.length)}
|
</Text>
|
||||||
>
|
|
||||||
<CaretRightIcon />
|
<Text color="gray" wrap="nowrap">
|
||||||
</IconButton>
|
<Flex gap="1" align="center">
|
||||||
</Flex>
|
<img
|
||||||
)}
|
alt="Silver"
|
||||||
|
src={asset('icons/currencies/silver.webp')}
|
||||||
|
style={{
|
||||||
|
width: '1em',
|
||||||
|
height: '1em',
|
||||||
|
objectFit: 'contain',
|
||||||
|
objectPosition: 'center',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{totalCredits.toLocaleString()}
|
||||||
|
</Flex>
|
||||||
|
</Text>
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<ScrollArea type="hover" scrollbars="horizontal" ref={container}>
|
<ScrollArea type="hover" scrollbars="horizontal" ref={container}>
|
||||||
@@ -140,6 +161,32 @@ export function TechTreeSection() {
|
|||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
|
<Flex>
|
||||||
|
{lines.length > 1 && (
|
||||||
|
<Flex align="center" gap="2">
|
||||||
|
<IconButton
|
||||||
|
size="2"
|
||||||
|
variant="soft"
|
||||||
|
onClick={() =>
|
||||||
|
setLineIndex((lines.length + lineIndex - 1) % lines.length)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<CaretLeftIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Text>
|
||||||
|
Route {lineIndex + 1} of {lines.length}
|
||||||
|
</Text>
|
||||||
|
<IconButton
|
||||||
|
size="2"
|
||||||
|
variant="soft"
|
||||||
|
onClick={() => setLineIndex((lineIndex + 1) % lines.length)}
|
||||||
|
>
|
||||||
|
<CaretRightIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user