mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 03:07:04 +02:00
fix: correct currencies
This commit is contained in:
1 parent
434d2d3d5d
commit
cfe0060121
3 files changed
+38
-46
No files matched your search
@@ -37,8 +37,8 @@ import {
|
||||
CrewMember,
|
||||
GunDefinition,
|
||||
ShellType,
|
||||
TankDefinitionPrice,
|
||||
TankDefinitions,
|
||||
TankPrice,
|
||||
Tier,
|
||||
Unlock,
|
||||
} from '../../src/core/blitzkit/tankDefinitions';
|
||||
@@ -670,10 +670,7 @@ export async function definitions(production: boolean) {
|
||||
const engineXps = new Map<number, number>();
|
||||
const trackXps = new Map<number, number>();
|
||||
const tank = tankList.root[tankKey];
|
||||
const tankPrice: TankDefinitionPrice =
|
||||
typeof tank.price === 'number'
|
||||
? { type: 'credits', value: tank.price }
|
||||
: { type: 'gold', value: tank.price['#text'] };
|
||||
let tankPrice: TankPrice;
|
||||
const tankDefinition = await readXMLDVPL<{ root: VehicleDefinitions }>(
|
||||
`${DATA}/XML/item_defs/vehicles/${nation}/${tankKey}.xml.dvpl`,
|
||||
);
|
||||
@@ -689,6 +686,23 @@ export async function definitions(production: boolean) {
|
||||
const equipment = tankDefinition.root.optDevicePreset;
|
||||
tankStringIdMap[`${nation}:${tankKey}`] = tankId;
|
||||
|
||||
if (tank.sellPrice) {
|
||||
tankPrice = {
|
||||
type: 'gold',
|
||||
value: tank.sellPrice['#text'] * 2,
|
||||
};
|
||||
} else if (typeof tank.price === 'number') {
|
||||
tankPrice = {
|
||||
type: 'credits',
|
||||
value: tank.price,
|
||||
};
|
||||
} else {
|
||||
tankPrice = {
|
||||
type: 'credits',
|
||||
value: tank.price['#text'] * 400,
|
||||
};
|
||||
}
|
||||
|
||||
Object.keys(tankDefinition.root.hull.armor)
|
||||
.filter((name) => name.startsWith('armor_'))
|
||||
.forEach((name) => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { CheckIcon, Cross1Icon } from '@radix-ui/react-icons';
|
||||
import { Code, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { classIcons } from '../../../../../../components/ClassIcon';
|
||||
import { asset } from '../../../../../../core/blitzkit/asset';
|
||||
@@ -10,20 +9,7 @@ import * as Duel from '../../../../../../stores/duel';
|
||||
export function MetaSection() {
|
||||
const developerMode = App.useDeferred(false, (state) => state.developerMode);
|
||||
const tank = Duel.use((state) => state.protagonist.tank);
|
||||
const rawPrice =
|
||||
typeof tank.price === 'number' ? tank.price : tank.price.value;
|
||||
const priceType =
|
||||
typeof tank.price === 'number' ? 'credits' : tank.price.type;
|
||||
const salePrice = 0.5 * rawPrice;
|
||||
const purchasePrice = rawPrice;
|
||||
const ClassIcon = classIcons[tank.class];
|
||||
let worthSelling: boolean;
|
||||
|
||||
if (priceType === 'gold') {
|
||||
worthSelling = tank.tier <= 6 || purchasePrice - salePrice <= 500;
|
||||
} else {
|
||||
worthSelling = tank.tier <= 7;
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex justify="center" align="center" py="8" px="4">
|
||||
@@ -95,21 +81,32 @@ export function MetaSection() {
|
||||
<Flex gap="6">
|
||||
<Flex direction="column">
|
||||
<Text color="gray">
|
||||
{priceType === 'credits' ? 'Purchase' : 'Restoration'} price
|
||||
{tank.price.type === 'credits' ? 'Purchase' : 'Restoration'}{' '}
|
||||
price
|
||||
</Text>
|
||||
{tank.xp && <Text color="gray">Research XP</Text>}
|
||||
<Text color="gray">Sale price</Text>
|
||||
<Text color="gray">Worth selling</Text>
|
||||
{tank.xp && <Text color="gray">Research XP</Text>}
|
||||
</Flex>
|
||||
|
||||
<Flex direction="column" align="end">
|
||||
<Flex align="center" gap="2">
|
||||
<Text>{purchasePrice.toLocaleString()}</Text>
|
||||
<Text>{tank.price.value.toLocaleString()}</Text>
|
||||
<img
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
alt={priceType}
|
||||
alt={tank.price.type}
|
||||
src={asset(
|
||||
`icons/currencies/${priceType === 'gold' ? 'gold' : 'silver'}.webp`,
|
||||
`icons/currencies/${tank.price.type === 'gold' ? 'gold' : 'silver'}.webp`,
|
||||
)}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Flex align="center" gap="2">
|
||||
<Text>{(tank.price.value / 2).toLocaleString()}</Text>
|
||||
<img
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
alt={tank.price.type}
|
||||
src={asset(
|
||||
`icons/currencies/${tank.price.type === 'gold' ? 'gold' : 'silver'}.webp`,
|
||||
)}
|
||||
/>
|
||||
</Flex>
|
||||
@@ -124,25 +121,6 @@ export function MetaSection() {
|
||||
/>
|
||||
</Flex>
|
||||
)}
|
||||
|
||||
<Flex align="center" gap="2">
|
||||
<Text>{salePrice.toLocaleString()}</Text>
|
||||
<img
|
||||
style={{ width: '1em', height: '1em' }}
|
||||
alt={priceType}
|
||||
src={asset(
|
||||
`icons/currencies/${priceType === 'gold' ? 'gold' : 'silver'}.webp`,
|
||||
)}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
<Text color={worthSelling ? 'green' : 'red'}>
|
||||
<Flex align="center" gap="1">
|
||||
{worthSelling ? 'Yes' : 'No'}
|
||||
{worthSelling && <CheckIcon />}
|
||||
{!worthSelling && <Cross1Icon />}
|
||||
</Flex>
|
||||
</Text>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -60,7 +60,7 @@ export interface TankDefinition {
|
||||
turrets: TurretDefinition[];
|
||||
engines: EngineDefinition[];
|
||||
tracks: TrackDefinition[];
|
||||
price: TankDefinitionPrice;
|
||||
price: TankPrice;
|
||||
xp?: number;
|
||||
speed: {
|
||||
forwards: number;
|
||||
@@ -102,7 +102,7 @@ export interface EngineDefinition {
|
||||
weight: number;
|
||||
unlocks?: Unlock[];
|
||||
}
|
||||
export type TankDefinitionPrice =
|
||||
export type TankPrice =
|
||||
| { type: 'credits'; value: number }
|
||||
| { type: 'gold'; value: number };
|
||||
export interface TurretDefinition {
|
||||
|
||||
Reference in new issue
Block a user