import { CaretRightIcon, Cross1Icon, MagnifyingGlassIcon, } from '@radix-ui/react-icons'; import { Button, Card, Checkbox, Dialog, Flex, Heading, Tabs, Text, TextField, Tooltip, } from '@radix-ui/themes'; import { go } from 'fuzzysort'; import { debounce } from 'lodash'; import { use, useRef, useState } from 'react'; import { ModuleButtons } from '../../../../../components/ModuleButton'; import { asset } from '../../../../../core/blitzkrieg/asset'; import { SHELL_NAMES, tankDefinitions, tankNamesDiacritics, } from '../../../../../core/blitzkrieg/tankDefinitions'; import mutateTankopedia, { useTankopedia, } from '../../../../../stores/tankopedia'; export function VersusBar() { const awaitedTankDefinitions = use(tankDefinitions); const mode = useTankopedia((state) => state.mode); const awaitedTankNamesDiacritics = use(tankNamesDiacritics); const [versusTankTab, setVersusTankTab] = useState('search'); const versusTankSearchInput = useRef(null); const antagonist = useTankopedia((state) => { if (!state.areTanksAssigned) return; return state.antagonist; }); const [versusTankSearchResults, setVersusTankSearchResults] = useState< number[] >([]); if (!antagonist || mode !== 'armor') return null; return ( Versus Search Configure { setVersusTankSearchResults( go( versusTankSearchInput.current!.value, awaitedTankNamesDiacritics, { key: 'combined', limit: 8 }, ).map((item) => item.obj.id), ); }, 500)} /> {(versusTankSearchResults.length > 0 || versusTankSearchInput.current?.value) && ( {versusTankSearchResults .map((id) => awaitedTankDefinitions[id]) .map((tank) => ( ))} {versusTankSearchResults.length === 0 && (versusTankSearchInput.current ? versusTankSearchInput.current.value.length > 0 : false) && ( )} )} {antagonist.tank.name} modules {antagonist.tank.turrets.map((turret, index) => ( { mutateTankopedia((draft) => { if (!draft.areTanksAssigned) return; draft.antagonist.turret = turret; draft.antagonist.gun = turret.guns.at(-1)!; draft.antagonist.shell = draft.antagonist.gun.shells[0]; }); }} selected={antagonist.turret.id === turret.id} tier={turret.tier} type="turret" style={{ margin: -0.5, borderTopLeftRadius: index === 0 ? undefined : 0, borderBottomLeftRadius: index === 0 ? undefined : 0, borderTopRightRadius: index === antagonist.tank.turrets.length - 1 ? undefined : 0, borderBottomRightRadius: index === antagonist.tank.turrets.length - 1 ? undefined : 0, }} /> ))} {antagonist.turret.guns.map((gun, index) => ( { mutateTankopedia((draft) => { if (!draft.areTanksAssigned) return; draft.antagonist.gun = gun; draft.antagonist.shell = gun.shells[0]; }); }} selected={antagonist.gun.id === gun.id} tier={gun.tier} type="gun" style={{ margin: -0.5, borderTopLeftRadius: index === 0 ? undefined : 0, borderBottomLeftRadius: index === 0 ? undefined : 0, borderTopRightRadius: index === antagonist.turret.guns.length - 1 ? undefined : 0, borderBottomRightRadius: index === antagonist.turret.guns.length - 1 ? undefined : 0, }} /> ))} Properties
  • Turret: {antagonist.turret.name}
  • Gun: {antagonist.gun.name}
  • Shells:
    • {antagonist.gun.shells.map((shell) => (
    • {SHELL_NAMES[shell.type]}:{' '} {shell.damage.armor} HP
    • ))}
Calibrated
); }