2026-05-11 16:49:14 -05:00
|
|
|
import { romanize } from "@blitzkit/core";
|
2026-05-17 13:29:03 -05:00
|
|
|
import type { BlitzStaticEquipmentPresetComponent_EquipmentSlot } from "@protos/blitz_static_equipment_preset_component";
|
2026-05-15 22:46:36 -05:00
|
|
|
import { Grade } from "@protos/blitz_static_standard_grades_enum";
|
2026-05-19 13:20:54 -05:00
|
|
|
import { StandardPrice } from "@protos/blitz_static_standard_price";
|
2026-05-15 22:46:36 -05:00
|
|
|
import type { UpgradeLine } from "@protos/blitz_static_tank_upgrade_line";
|
|
|
|
|
import type { StageParameters } from "@protos/blitz_static_tank_upgrade_single_stage";
|
2026-05-19 13:20:54 -05:00
|
|
|
import {
|
|
|
|
|
CornerBottomLeftIcon,
|
|
|
|
|
DoubleArrowLeftIcon,
|
|
|
|
|
DoubleArrowRightIcon,
|
2026-05-26 11:41:08 -05:00
|
|
|
TrashIcon,
|
2026-05-19 13:20:54 -05:00
|
|
|
} from "@radix-ui/react-icons";
|
2026-05-17 13:19:28 -05:00
|
|
|
import { chunk } from "lodash-es";
|
2026-05-15 10:54:36 -05:00
|
|
|
import { useMemo } from "react";
|
2026-05-17 13:19:28 -05:00
|
|
|
import { equipmentColumns } from "../../config/equipment";
|
2026-05-15 18:43:08 -05:00
|
|
|
import {
|
|
|
|
|
alternativeLines,
|
|
|
|
|
isAlternativeLine,
|
2026-05-19 13:20:54 -05:00
|
|
|
maxModulesPerRow,
|
2026-05-15 21:18:01 -05:00
|
|
|
originalLineName,
|
2026-05-17 13:19:28 -05:00
|
|
|
} from "../../config/modules";
|
2026-05-20 13:48:20 -05:00
|
|
|
import { useCompatibility } from "../../hooks/useCompatibility";
|
2026-05-20 13:09:19 -05:00
|
|
|
import { useConsumables } from "../../hooks/useConsumables";
|
2026-05-17 12:56:23 -05:00
|
|
|
import { useEquipment } from "../../hooks/useEquipment";
|
2026-05-15 10:54:36 -05:00
|
|
|
import { useProtagonist } from "../../hooks/useProtagonist";
|
2026-04-29 16:27:13 -05:00
|
|
|
import { useStrings } from "../../hooks/useStrings";
|
2026-05-20 13:09:19 -05:00
|
|
|
import { useTierPrices } from "../../hooks/useTierPrices";
|
2026-05-15 10:54:36 -05:00
|
|
|
import { useUpgradePreset } from "../../hooks/useUpgradePreset";
|
2026-04-29 16:27:13 -05:00
|
|
|
import { Tankopedia } from "../../stores/tankopedia";
|
2026-05-15 18:16:06 -05:00
|
|
|
import { Button } from "../Button";
|
2026-04-29 16:27:13 -05:00
|
|
|
import { Heading } from "../Heading";
|
2026-05-26 11:55:51 -05:00
|
|
|
import { IconButton } from "../IconButton";
|
2026-05-15 10:54:36 -05:00
|
|
|
import { Price } from "../Price";
|
2026-04-29 16:27:13 -05:00
|
|
|
import { Section } from "../Section";
|
2026-05-11 16:49:14 -05:00
|
|
|
import { Text } from "../Text";
|
2026-04-29 16:27:13 -05:00
|
|
|
import styles from "./index.module.css";
|
2026-05-26 11:55:51 -05:00
|
|
|
import type { ComputedCharacteristics } from "../../tankopedia/computeCharacteristics";
|
2026-04-29 16:27:13 -05:00
|
|
|
|
2026-05-26 11:55:51 -05:00
|
|
|
interface TankopediaLoadoutProps {
|
|
|
|
|
characteristics: ComputedCharacteristics;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TankopediaLoadout({ characteristics }: TankopediaLoadoutProps) {
|
2026-05-18 16:57:21 -05:00
|
|
|
const tank = useProtagonist();
|
|
|
|
|
|
|
|
|
|
const showModules = tank.tank!.upgrade_lines.some(
|
|
|
|
|
(line) => line.stages.length > 1 || line.name in alternativeLines,
|
|
|
|
|
);
|
|
|
|
|
|
2026-05-15 21:41:40 -05:00
|
|
|
return (
|
|
|
|
|
<Section>
|
2026-05-18 16:57:21 -05:00
|
|
|
{showModules && <Modules />}
|
2026-05-15 21:58:30 -05:00
|
|
|
<Equipment />
|
2026-05-26 11:55:51 -05:00
|
|
|
<Consumables characteristics={characteristics} />
|
2026-05-15 21:41:40 -05:00
|
|
|
</Section>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-04-29 16:27:13 -05:00
|
|
|
|
2026-05-26 11:55:51 -05:00
|
|
|
interface ConsumablesProps {
|
|
|
|
|
characteristics: ComputedCharacteristics;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Consumables({ characteristics }: ConsumablesProps) {
|
2026-05-20 13:09:19 -05:00
|
|
|
const consumables = useConsumables();
|
|
|
|
|
const tierPrices = useTierPrices();
|
2026-05-20 13:48:20 -05:00
|
|
|
const tank = useProtagonist();
|
2026-05-26 11:55:51 -05:00
|
|
|
const isCompatible = useCompatibility(tank, characteristics);
|
2026-05-20 13:09:19 -05:00
|
|
|
|
2026-05-26 11:55:51 -05:00
|
|
|
return Object.entries(consumables.consumables).map(
|
|
|
|
|
([id, { compatibility, consumable, purchase }]) => {
|
2026-05-20 13:57:05 -05:00
|
|
|
if (!isCompatible(compatibility!)) return null;
|
2026-05-22 13:51:30 -05:00
|
|
|
|
2026-05-26 11:55:51 -05:00
|
|
|
return (
|
|
|
|
|
<span>
|
|
|
|
|
{id} {JSON.stringify(consumable, null, 2)}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
2026-05-20 13:09:19 -05:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 21:58:30 -05:00
|
|
|
function Equipment() {
|
|
|
|
|
const strings = useStrings();
|
|
|
|
|
const tank = useProtagonist();
|
2026-05-17 13:46:53 -05:00
|
|
|
const equipment = useEquipment(tank.tank!);
|
2026-05-15 21:58:30 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.section}>
|
|
|
|
|
<div className={styles.header}>
|
|
|
|
|
<Heading size="4">{strings.tanks.loadout.equipment}</Heading>
|
2026-05-26 11:41:08 -05:00
|
|
|
|
|
|
|
|
<IconButton
|
|
|
|
|
color="red"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
Tankopedia.mutate((draft) => {
|
|
|
|
|
for (const key in draft.protagonist.equipment) {
|
|
|
|
|
delete draft.protagonist.equipment[key];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<TrashIcon />
|
|
|
|
|
</IconButton>
|
2026-05-15 21:58:30 -05:00
|
|
|
</div>
|
2026-05-17 13:19:28 -05:00
|
|
|
|
|
|
|
|
<div className={styles.equipment}>
|
2026-05-17 13:29:03 -05:00
|
|
|
{chunk(equipment.preset.slots, equipmentColumns).map((chunk, index) => (
|
|
|
|
|
<EquipmentRow key={index} chunk={chunk} rowIndex={index} />
|
|
|
|
|
))}
|
2026-05-17 13:19:28 -05:00
|
|
|
</div>
|
2026-05-15 21:58:30 -05:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 13:29:03 -05:00
|
|
|
interface EquipmentRowProps {
|
|
|
|
|
chunk: BlitzStaticEquipmentPresetComponent_EquipmentSlot[];
|
|
|
|
|
rowIndex: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EquipmentRow({ chunk, rowIndex }: EquipmentRowProps) {
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.row}>
|
|
|
|
|
{chunk.map((slot, index) => (
|
|
|
|
|
<EquipmentSlot
|
|
|
|
|
key={index}
|
|
|
|
|
slot={slot}
|
|
|
|
|
rowIndex={rowIndex}
|
|
|
|
|
columnIndex={index}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface EquipmentSlotProps {
|
|
|
|
|
slot: BlitzStaticEquipmentPresetComponent_EquipmentSlot;
|
|
|
|
|
rowIndex: number;
|
|
|
|
|
columnIndex: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EquipmentSlot({ slot, rowIndex, columnIndex }: EquipmentSlotProps) {
|
2026-05-17 13:46:53 -05:00
|
|
|
const equipmentIndex = rowIndex * equipmentColumns + columnIndex;
|
|
|
|
|
const tank = useProtagonist();
|
|
|
|
|
const equipment = useEquipment(tank.tank!);
|
|
|
|
|
const { price } = equipment.price.unlock_slot_prices[equipmentIndex];
|
|
|
|
|
|
2026-05-17 13:29:03 -05:00
|
|
|
return (
|
|
|
|
|
<div className={styles.slots}>
|
2026-05-17 13:46:53 -05:00
|
|
|
<div className={styles.options}>
|
|
|
|
|
{slot.options_catalog_i_ds.map((id, index) => (
|
|
|
|
|
<EquipmentOption
|
|
|
|
|
key={id}
|
|
|
|
|
optionIndex={index}
|
|
|
|
|
rowIndex={rowIndex}
|
|
|
|
|
columnIndex={columnIndex}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Price price={price!} />
|
2026-05-17 13:29:03 -05:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface EquipmentOptionProps {
|
|
|
|
|
optionIndex: number;
|
|
|
|
|
rowIndex: number;
|
|
|
|
|
columnIndex: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EquipmentOption({
|
|
|
|
|
optionIndex,
|
|
|
|
|
rowIndex,
|
|
|
|
|
columnIndex,
|
|
|
|
|
}: EquipmentOptionProps) {
|
|
|
|
|
const equipmentIndex = rowIndex * equipmentColumns + columnIndex;
|
2026-05-24 12:42:08 -05:00
|
|
|
const tank = useProtagonist();
|
|
|
|
|
const equipment = useEquipment(tank.tank!);
|
|
|
|
|
const slot = equipment.preset.slots[equipmentIndex];
|
|
|
|
|
const id = slot.options_catalog_i_ds[optionIndex];
|
2026-05-17 13:46:53 -05:00
|
|
|
|
2026-05-17 13:29:03 -05:00
|
|
|
const isSelected = Tankopedia.use(
|
|
|
|
|
(state) =>
|
|
|
|
|
equipmentIndex in state.protagonist.equipment &&
|
|
|
|
|
state.protagonist.equipment[equipmentIndex] === optionIndex,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
color={isSelected ? undefined : "gray"}
|
|
|
|
|
variant={isSelected ? "surface" : "soft"}
|
|
|
|
|
data-selected={isSelected}
|
|
|
|
|
radius="1"
|
2026-05-26 11:36:45 -05:00
|
|
|
array
|
2026-05-17 13:29:03 -05:00
|
|
|
className={styles.slot}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
Tankopedia.mutate((draft) => {
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
delete draft.protagonist.equipment[equipmentIndex];
|
|
|
|
|
} else {
|
|
|
|
|
draft.protagonist.equipment[equipmentIndex] = optionIndex;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-05-24 12:42:08 -05:00
|
|
|
<img src={`/media/equipment/${id}.webp`} />
|
2026-05-17 13:29:03 -05:00
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 21:41:40 -05:00
|
|
|
function Modules() {
|
|
|
|
|
const strings = useStrings();
|
2026-05-15 10:54:36 -05:00
|
|
|
const tank = useProtagonist();
|
2026-05-26 11:36:45 -05:00
|
|
|
const upgrades = Tankopedia.use((state) => state.protagonist.upgrades);
|
|
|
|
|
const alternates = Tankopedia.use((state) => state.protagonist.alternates);
|
|
|
|
|
const isStock = useMemo(() => {
|
|
|
|
|
return tank.tank!.upgrade_lines.every((line) => {
|
|
|
|
|
if (isAlternativeLine(line.name)) return true;
|
|
|
|
|
return upgrades[line.name] === 0;
|
|
|
|
|
});
|
|
|
|
|
}, [upgrades]);
|
|
|
|
|
const isUpgraded = useMemo(() => {
|
|
|
|
|
return tank.tank!.upgrade_lines.every((line) => {
|
|
|
|
|
if (isAlternativeLine(line.name)) return true;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
upgrades[line.name] === line.stages.length - 1 ||
|
|
|
|
|
(line.name in alternates && alternates[line.name])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}, [upgrades]);
|
2026-04-29 16:27:13 -05:00
|
|
|
|
|
|
|
|
return (
|
2026-05-15 21:41:40 -05:00
|
|
|
<div className={styles.section}>
|
|
|
|
|
<div className={styles.header}>
|
|
|
|
|
<Heading size="4">{strings.tanks.loadout.modules}</Heading>
|
|
|
|
|
|
2026-05-26 11:36:45 -05:00
|
|
|
<div className={styles["upgrade-buttons"]}>
|
|
|
|
|
<IconButton
|
|
|
|
|
variant={isStock ? "solid" : "soft"}
|
|
|
|
|
size="minor"
|
|
|
|
|
array
|
|
|
|
|
onClick={() => {
|
|
|
|
|
Tankopedia.mutate((draft) => {
|
|
|
|
|
for (const line of tank.tank!.upgrade_lines) {
|
|
|
|
|
if (isAlternativeLine(line.name)) continue;
|
2026-05-15 21:41:40 -05:00
|
|
|
|
2026-05-26 11:36:45 -05:00
|
|
|
draft.protagonist.upgrades[line.name] = 0;
|
|
|
|
|
draft.protagonist.alternates[line.name] = false;
|
2026-05-15 21:41:40 -05:00
|
|
|
}
|
2026-05-26 11:36:45 -05:00
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
color="gray"
|
|
|
|
|
>
|
|
|
|
|
<DoubleArrowLeftIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
|
|
|
|
|
<IconButton
|
|
|
|
|
variant={isUpgraded ? "solid" : "soft"}
|
|
|
|
|
size="minor"
|
|
|
|
|
array
|
|
|
|
|
onClick={() => {
|
|
|
|
|
Tankopedia.mutate((draft) => {
|
|
|
|
|
for (const line of tank.tank!.upgrade_lines) {
|
|
|
|
|
draft.protagonist.upgrades[line.name] =
|
|
|
|
|
line.stages.length - 1;
|
|
|
|
|
|
|
|
|
|
if (isAlternativeLine(line.name)) {
|
|
|
|
|
const original = originalLineName(line.name)!;
|
|
|
|
|
draft.protagonist.alternates[original] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
color="gray"
|
|
|
|
|
>
|
|
|
|
|
<DoubleArrowRightIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</div>
|
2026-05-15 21:41:40 -05:00
|
|
|
</div>
|
2026-04-29 16:27:13 -05:00
|
|
|
|
|
|
|
|
<div className={styles.lines}>
|
2026-05-18 16:57:21 -05:00
|
|
|
{/* TODO: hide lines with 1 module except for alts */}
|
2026-04-29 16:27:13 -05:00
|
|
|
{tank.tank!.upgrade_lines.map((line) => (
|
2026-05-11 17:00:30 -05:00
|
|
|
<Line
|
|
|
|
|
key={line.name}
|
2026-05-15 10:54:36 -05:00
|
|
|
name={line.name}
|
2026-05-11 17:00:30 -05:00
|
|
|
lines={tank.tank!.upgrade_lines}
|
|
|
|
|
/>
|
2026-04-29 16:27:13 -05:00
|
|
|
))}
|
|
|
|
|
</div>
|
2026-05-15 21:41:40 -05:00
|
|
|
</div>
|
2026-04-29 16:27:13 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface LineProps {
|
2026-05-15 10:54:36 -05:00
|
|
|
name: string;
|
2026-05-11 17:00:30 -05:00
|
|
|
lines: UpgradeLine[];
|
2026-04-29 16:27:13 -05:00
|
|
|
}
|
|
|
|
|
|
2026-05-15 10:54:36 -05:00
|
|
|
function Line({ name, lines }: LineProps) {
|
2026-05-11 17:00:30 -05:00
|
|
|
const combinedLines = useMemo(() => {
|
2026-05-15 10:54:36 -05:00
|
|
|
const names: string[] = [name];
|
2026-05-11 17:00:30 -05:00
|
|
|
|
2026-05-15 18:43:08 -05:00
|
|
|
for (const originalLine in alternativeLines) {
|
|
|
|
|
const alternativeLine = alternativeLines[originalLine];
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
originalLine === name &&
|
|
|
|
|
lines.some((line) => line.name === alternativeLine)
|
|
|
|
|
) {
|
|
|
|
|
names.push(alternativeLine);
|
2026-05-11 17:00:30 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 10:54:36 -05:00
|
|
|
return names;
|
|
|
|
|
}, [name]);
|
2026-04-29 16:27:13 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles.line}>
|
2026-05-15 18:43:08 -05:00
|
|
|
{!isAlternativeLine(name) &&
|
2026-05-15 10:54:36 -05:00
|
|
|
combinedLines.map((name) => (
|
2026-05-19 13:43:43 -05:00
|
|
|
<div className={styles["chunks-wrapper"]}>
|
|
|
|
|
<LineInner key={name} name={name} lines={lines} />
|
|
|
|
|
</div>
|
2026-05-15 10:54:36 -05:00
|
|
|
))}
|
2026-04-29 16:27:13 -05:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-05-11 17:00:30 -05:00
|
|
|
|
2026-05-15 10:54:36 -05:00
|
|
|
function LineInner({ name, lines }: LineProps) {
|
|
|
|
|
const line = lines.find((line) => line.name === name)!;
|
2026-05-11 17:00:30 -05:00
|
|
|
|
2026-05-19 13:20:54 -05:00
|
|
|
return chunk(line.stages, maxModulesPerRow).map((chunk, wrapIndex) => (
|
|
|
|
|
<div className={styles["line-wrap"]}>
|
|
|
|
|
{wrapIndex > 0 && (
|
|
|
|
|
<Text size="minor" className={styles["wrap-marker"]} lowContrast>
|
|
|
|
|
<CornerBottomLeftIcon />
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{chunk.map((stage, elementIndex) => (
|
|
|
|
|
<LineElement
|
|
|
|
|
key={elementIndex}
|
|
|
|
|
index={wrapIndex * maxModulesPerRow + elementIndex}
|
|
|
|
|
lineName={name}
|
|
|
|
|
stage={stage}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-05-15 10:54:36 -05:00
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface LineElementProps {
|
|
|
|
|
index: number;
|
|
|
|
|
lineName: string;
|
|
|
|
|
stage: StageParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function LineElement({ index, lineName, stage }: LineElementProps) {
|
|
|
|
|
const upgrades = Tankopedia.use((state) => state.protagonist.upgrades);
|
2026-05-15 21:18:01 -05:00
|
|
|
const alternates = Tankopedia.use((state) => state.protagonist.alternates);
|
2026-05-15 10:54:36 -05:00
|
|
|
const tank = useProtagonist();
|
2026-05-11 17:00:30 -05:00
|
|
|
const strings = useStrings();
|
2026-05-15 10:54:36 -05:00
|
|
|
const upgradePreset = useUpgradePreset(tank.tank!.tank_upgrade_preset);
|
|
|
|
|
|
|
|
|
|
let price: StandardPrice | undefined;
|
|
|
|
|
|
|
|
|
|
switch (stage.grade) {
|
|
|
|
|
case Grade.GRADE_COMMON:
|
|
|
|
|
price = upgradePreset.common_grade_price;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Grade.GRADE_RARE:
|
|
|
|
|
price = upgradePreset.rare_grade_price;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Grade.GRADE_EPIC:
|
|
|
|
|
price = upgradePreset.unique_grade_price;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Grade.GRADE_LEGENDARY:
|
|
|
|
|
price = upgradePreset.legendary_grade_price;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const override of upgradePreset.prices_overrides) {
|
|
|
|
|
if (override.stage_tech_name !== stage.tech_name) continue;
|
|
|
|
|
price = override.price;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 13:20:54 -05:00
|
|
|
price ??= StandardPrice.create();
|
|
|
|
|
|
2026-05-15 21:18:01 -05:00
|
|
|
let isSelected: boolean;
|
|
|
|
|
|
|
|
|
|
if (isAlternativeLine(lineName)) {
|
|
|
|
|
const originalLine = originalLineName(lineName);
|
|
|
|
|
isSelected = alternates[originalLine!];
|
|
|
|
|
} else {
|
|
|
|
|
if (alternates[lineName]) {
|
|
|
|
|
isSelected = false;
|
|
|
|
|
} else {
|
|
|
|
|
isSelected = upgrades[lineName] === index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-15 10:54:36 -05:00
|
|
|
|
|
|
|
|
return (
|
2026-05-17 13:46:53 -05:00
|
|
|
<div className={styles.wrapper}>
|
|
|
|
|
<Button
|
|
|
|
|
className={styles.stage}
|
|
|
|
|
color={isSelected ? undefined : "gray"}
|
|
|
|
|
variant={isSelected ? "surface" : "soft"}
|
|
|
|
|
radius="1"
|
|
|
|
|
onClick={() => {
|
2026-05-19 13:43:43 -05:00
|
|
|
// TODO: make minimum selectable upgrade the last free module for tanks like the destiny
|
|
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
Tankopedia.mutate((draft) => {
|
|
|
|
|
const tankData = tank.tank!;
|
2026-05-15 21:18:01 -05:00
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
if (isAlternativeLine(lineName)) {
|
|
|
|
|
const originalLine = originalLineName(lineName)!;
|
2026-05-15 21:18:01 -05:00
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
draft.protagonist.alternates[originalLine] = true;
|
|
|
|
|
draft.protagonist.upgrades[lineName] = index;
|
|
|
|
|
} else {
|
|
|
|
|
draft.protagonist.alternates[lineName] = false;
|
|
|
|
|
draft.protagonist.upgrades[lineName] = index;
|
|
|
|
|
}
|
2026-05-15 10:54:36 -05:00
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
for (const required of stage.required_upgrades) {
|
|
|
|
|
for (const line of tankData.upgrade_lines) {
|
|
|
|
|
let i = 0;
|
2026-05-11 17:00:30 -05:00
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
for (const candidateStage of line.stages) {
|
|
|
|
|
if (candidateStage.tech_name === required) {
|
|
|
|
|
draft.protagonist.upgrades[line.name] = Math.max(
|
|
|
|
|
draft.protagonist.upgrades[line.name],
|
|
|
|
|
i,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
2026-05-11 17:00:30 -05:00
|
|
|
}
|
2026-05-15 10:54:36 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
for (const line of tankData.upgrade_lines) {
|
|
|
|
|
if (draft.protagonist.alternates[line.name]) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let i = draft.protagonist.upgrades[line.name];
|
|
|
|
|
|
|
|
|
|
while (i > 0) {
|
|
|
|
|
const currentStage = line.stages[i];
|
|
|
|
|
|
|
|
|
|
const valid = currentStage.required_upgrades.every(
|
|
|
|
|
(required) => {
|
|
|
|
|
for (const otherLine of tankData.upgrade_lines) {
|
|
|
|
|
const idx = draft.protagonist.upgrades[otherLine.name];
|
|
|
|
|
|
|
|
|
|
if (otherLine.stages[idx]?.tech_name === required) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (valid) break;
|
|
|
|
|
|
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draft.protagonist.upgrades[line.name] = i;
|
2026-05-15 21:18:01 -05:00
|
|
|
}
|
2026-05-17 13:46:53 -05:00
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
className={styles.icon}
|
2026-05-24 12:55:30 -05:00
|
|
|
src={`/media/modules/${stage.stage_type}.webp`}
|
2026-05-17 13:46:53 -05:00
|
|
|
/>
|
|
|
|
|
{/* {stage.display_name} */}
|
2026-05-15 21:18:01 -05:00
|
|
|
|
2026-05-17 13:46:53 -05:00
|
|
|
<Text weight="light" lowContrast size="minor" className={styles.tier}>
|
|
|
|
|
{isAlternativeLine(lineName)
|
|
|
|
|
? strings.tanks.loadout.alternative
|
|
|
|
|
: romanize(stage.number)}
|
|
|
|
|
</Text>
|
|
|
|
|
</Button>
|
2026-05-11 17:00:30 -05:00
|
|
|
|
2026-05-19 13:20:54 -05:00
|
|
|
{<Price className={styles.price} price={price} />}
|
2026-05-17 13:46:53 -05:00
|
|
|
</div>
|
2026-05-15 10:54:36 -05:00
|
|
|
);
|
2026-05-11 17:00:30 -05:00
|
|
|
}
|