diff --git a/scripts/buildAssets/definitions.ts b/scripts/buildAssets/definitions.ts index 5aa659b0e..8d96b3985 100644 --- a/scripts/buildAssets/definitions.ts +++ b/scripts/buildAssets/definitions.ts @@ -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(); const trackXps = new Map(); 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) => { diff --git a/src/app/tools/tankopedia/[id]/components/Model/MetaSection.tsx b/src/app/tools/tankopedia/[id]/components/Model/MetaSection.tsx index 4523c3190..4f45720c6 100644 --- a/src/app/tools/tankopedia/[id]/components/Model/MetaSection.tsx +++ b/src/app/tools/tankopedia/[id]/components/Model/MetaSection.tsx @@ -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 ( @@ -95,21 +81,32 @@ export function MetaSection() { - {priceType === 'credits' ? 'Purchase' : 'Restoration'} price + {tank.price.type === 'credits' ? 'Purchase' : 'Restoration'}{' '} + price - {tank.xp && Research XP} Sale price - Worth selling + {tank.xp && Research XP} - {purchasePrice.toLocaleString()} + {tank.price.value.toLocaleString()} {priceType} + + + + {(tank.price.value / 2).toLocaleString()} + {tank.price.type} @@ -124,25 +121,6 @@ export function MetaSection() { /> )} - - - {salePrice.toLocaleString()} - {priceType} - - - - - {worthSelling ? 'Yes' : 'No'} - {worthSelling && } - {!worthSelling && } - - diff --git a/src/core/blitzkit/tankDefinitions/index.ts b/src/core/blitzkit/tankDefinitions/index.ts index a411f02b6..c92d25e1c 100644 --- a/src/core/blitzkit/tankDefinitions/index.ts +++ b/src/core/blitzkit/tankDefinitions/index.ts @@ -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 {