fix: casing

This commit is contained in:
TrèsAbhi committed 2024-10-07 18:45:11 -05:00
1 parent ef52434a42
commit fc8e0e55f0
34 files changed
+321 -304

No files matched your search

@@ -99,7 +99,7 @@ export function ArmorPlateDisplay() {
const tank = draft.model; const tank = draft.model;
const turret = tank.turrets[protagonist.turret.id]; const turret = tank.turrets[protagonist.turret.id];
const gun = const gun =
turret.guns[protagonist.gun.gunType!.value.base.id]; turret.guns[protagonist.gun.gun_type!.value.base.id];
const track = tank.tracks[protagonist.track.id]; const track = tank.tracks[protagonist.track.id];
console.log(highlightArmor.name); console.log(highlightArmor.name);
@@ -154,10 +154,10 @@ export function ArmorPlateDisplay() {
const initialTurret = const initialTurret =
initialTank.turrets[protagonist.turret.id]; initialTank.turrets[protagonist.turret.id];
const gun = const gun =
turret.guns[protagonist.gun.gunType!.value.base.id]; turret.guns[protagonist.gun.gun_type!.value.base.id];
const initialGun = const initialGun =
initialTurret.guns[ initialTurret.guns[
protagonist.gun.gunType!.value.base.id protagonist.gun.gun_type!.value.base.id
]; ];
const track = tank.tracks[protagonist.track.id]; const track = tank.tracks[protagonist.track.id];
const initialTrack = const initialTrack =
@@ -25,10 +25,10 @@ export const PrimaryArmorScene = memo(() => {
const trackModelDefinition = tankModelDefinition.tracks[track.id]; const trackModelDefinition = tankModelDefinition.tracks[track.id];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
const hullOrigin = correctZYTuple(trackModelDefinition.origin); const hullOrigin = correctZYTuple(trackModelDefinition.origin);
const turretOrigin = correctZYTuple(tankModelDefinition.turretOrigin); const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin);
const gunOrigin = correctZYTuple(turretModelDefinition.gunOrigin); const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin);
const isDynamicArmorActive = Duel.use((state) => const isDynamicArmorActive = Duel.use((state) =>
state.protagonist.consumables.includes(73), state.protagonist.consumables.includes(73),
); );
@@ -69,7 +69,7 @@ export const PrimaryArmorScene = memo(() => {
<group ref={turretContainer}> <group ref={turretContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentTurret = node.name.startsWith( const isCurrentTurret = node.name.startsWith(
`turret_${turretModelDefinition.modelId.toString().padStart(2, '0')}`, `turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentTurret; const isVisible = isCurrentTurret;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -103,7 +103,7 @@ export const PrimaryArmorScene = memo(() => {
<group ref={gunContainer}> <group ref={gunContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentGun = node.name.startsWith( const isCurrentGun = node.name.startsWith(
`gun_${gunModelDefinition.modelId.toString().padStart(2, '0')}`, `gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentGun; const isVisible = isCurrentGun;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -68,8 +68,8 @@ export function PrimaryArmorSceneComponent({
); );
material.uniforms.isExplosive.value = isExplosive(shell.type); material.uniforms.isExplosive.value = isExplosive(shell.type);
material.uniforms.canSplash.value = canSplash(shell.type); material.uniforms.canSplash.value = canSplash(shell.type);
material.uniforms.damage.value = shell.armorDamage; material.uniforms.damage.value = shell.armor_damage;
material.uniforms.explosionRadius.value = shell.explosionRadius; material.uniforms.explosionRadius.value = shell.explosion_radius;
const duel = duelStore.getState(); const duel = duelStore.getState();
await handleProtagonistEquipmentChange(duel.protagonist.equipmentMatrix); await handleProtagonistEquipmentChange(duel.protagonist.equipmentMatrix);
@@ -90,7 +90,7 @@ export function PrimaryArmorSceneComponent({
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasEnhancedArmor = await hasEquipment( const hasEnhancedArmor = await hasEquipment(
110, 110,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
equipment, equipment,
); );
material.uniforms.thickness.value = hasEnhancedArmor material.uniforms.thickness.value = hasEnhancedArmor
@@ -103,7 +103,7 @@ export function PrimaryArmorSceneComponent({
const penetration = shell.penetration.near; const penetration = shell.penetration.near;
const hasCalibratedShells = await hasEquipment( const hasCalibratedShells = await hasEquipment(
103, 103,
duel.antagonist.tank.equipmentPreset, duel.antagonist.tank.equipment_preset,
equipment, equipment,
); );
@@ -38,10 +38,10 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
const trackModelDefinition = tankModelDefinition.tracks[track.id]; const trackModelDefinition = tankModelDefinition.tracks[track.id];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
const hullOrigin = correctZYTuple(trackModelDefinition.origin); const hullOrigin = correctZYTuple(trackModelDefinition.origin);
const turretOrigin = correctZYTuple(tankModelDefinition.turretOrigin); const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin);
const gunOrigin = correctZYTuple(turretModelDefinition.gunOrigin); const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin);
const maskOrigin = const maskOrigin =
gunModelDefinition.mask === undefined gunModelDefinition.mask === undefined
? undefined ? undefined
@@ -106,7 +106,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
<group ref={turretContainer}> <group ref={turretContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentTurret = node.name.startsWith( const isCurrentTurret = node.name.startsWith(
`turret_${turretModelDefinition.modelId.toString().padStart(2, '0')}`, `turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentTurret; const isVisible = isCurrentTurret;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -141,7 +141,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
<group ref={gunContainer}> <group ref={gunContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentGun = node.name.startsWith( const isCurrentGun = node.name.startsWith(
`gun_${gunModelDefinition.modelId.toString().padStart(2, '0')}`, `gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentGun; const isVisible = isCurrentGun;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -173,7 +173,7 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
})} })}
{modelNodes.map((node) => { {modelNodes.map((node) => {
const gunString = `gun_${gunModelDefinition.modelId const gunString = `gun_${gunModelDefinition.model_id
.toString() .toString()
.padStart(2, '0')}`; .padStart(2, '0')}`;
const isCurrentGun = gunModelDefinition.mask const isCurrentGun = gunModelDefinition.mask
@@ -58,7 +58,7 @@ export function SpacedArmorSubExternal({
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasEnhancedArmor = await hasEquipment( const hasEnhancedArmor = await hasEquipment(
110, 110,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
equipment, equipment,
); );
material.uniforms.thickness.value = hasEnhancedArmor material.uniforms.thickness.value = hasEnhancedArmor
@@ -71,7 +71,7 @@ export function SpacedArmorSubExternal({
const penetration = shell.penetration.near; const penetration = shell.penetration.near;
const hasCalibratedShells = await hasEquipment( const hasCalibratedShells = await hasEquipment(
103, 103,
duel.antagonist.tank.equipmentPreset, duel.antagonist.tank.equipment_preset,
equipment, equipment,
); );
@@ -68,7 +68,7 @@ export function SpacedArmorSubSpaced({
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasEnhancedArmor = await hasEquipment( const hasEnhancedArmor = await hasEquipment(
110, 110,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
equipment, equipment,
); );
material.uniforms.thickness.value = hasEnhancedArmor material.uniforms.thickness.value = hasEnhancedArmor
@@ -81,7 +81,7 @@ export function SpacedArmorSubSpaced({
const penetration = shell.penetration.near; const penetration = shell.penetration.near;
const hasCalibratedShells = await hasEquipment( const hasCalibratedShells = await hasEquipment(
103, 103,
duel.antagonist.tank.equipmentPreset, duel.antagonist.tank.equipment_preset,
equipment, equipment,
); );
@@ -91,7 +91,7 @@ export function SpacedArmorSceneComponent({
const shell = antagonist.shell; const shell = antagonist.shell;
const cameraNormal = camera.position.clone().sub(point).normalize(); const cameraNormal = camera.position.clone().sub(point).normalize();
const shot: Shot = { const shot: Shot = {
splashRadius: shell.explosionRadius, splashRadius: shell.explosion_radius,
damage: -1, damage: -1,
containsGaps: shell.type === ShellType.HEAT, containsGaps: shell.type === ShellType.HEAT,
in: { in: {
@@ -103,12 +103,12 @@ export function SpacedArmorSceneComponent({
const hasCalibratedShells = await hasEquipment( const hasCalibratedShells = await hasEquipment(
103, 103,
antagonist.tank.equipmentPreset, antagonist.tank.equipment_preset,
antagonist.equipmentMatrix, antagonist.equipmentMatrix,
); );
const hasEnhancedArmor = await hasEquipment( const hasEnhancedArmor = await hasEquipment(
110, 110,
protagonist.tank.equipmentPreset, protagonist.tank.equipment_preset,
protagonist.equipmentMatrix, protagonist.equipmentMatrix,
); );
const penetration = const penetration =
@@ -288,8 +288,8 @@ export function SpacedArmorSceneComponent({
const finalDamage = Math.max( const finalDamage = Math.max(
0, 0,
0.5 * 0.5 *
shell.armorDamage * shell.armor_damage *
(1 - distanceFromSpacedArmor / shell.explosionRadius!) - (1 - distanceFromSpacedArmor / shell.explosion_radius!) -
1.1 * 1.1 *
(lastLayer.thicknessAngled + (lastLayer.thicknessAngled +
Math.min(penetration, totalSpacedArmorThickness)), Math.min(penetration, totalSpacedArmorThickness)),
@@ -311,7 +311,7 @@ export function SpacedArmorSceneComponent({
shot.damage = finalDamage; shot.damage = finalDamage;
} else { } else {
shot.in.status = 'penetration'; shot.in.status = 'penetration';
shot.damage = shell.armorDamage; shot.damage = shell.armor_damage;
} }
} else { } else {
if (lastLayer.status === 'blocked') { if (lastLayer.status === 'blocked') {
@@ -319,7 +319,7 @@ export function SpacedArmorSceneComponent({
shot.damage = 0; shot.damage = 0;
} else if (lastLayer.status === 'penetration') { } else if (lastLayer.status === 'penetration') {
shot.in.status = 'penetration'; shot.in.status = 'penetration';
shot.damage = shell.armorDamage; shot.damage = shell.armor_damage;
} else { } else {
const caster = new Raycaster(); const caster = new Raycaster();
// https://math.stackexchange.com/a/13263/1222875 // https://math.stackexchange.com/a/13263/1222875
@@ -44,10 +44,10 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
const trackModelDefinition = tankModelDefinition.tracks[track.id]; const trackModelDefinition = tankModelDefinition.tracks[track.id];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
const hullOrigin = correctZYTuple(trackModelDefinition.origin); const hullOrigin = correctZYTuple(trackModelDefinition.origin);
const turretOrigin = correctZYTuple(tankModelDefinition.turretOrigin); const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin);
const gunOrigin = correctZYTuple(turretModelDefinition.gunOrigin); const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin);
const mutateDuel = Duel.useMutation(); const mutateDuel = Duel.useMutation();
const canvas = useThree((state) => state.gl.domElement); const canvas = useThree((state) => state.gl.domElement);
const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation(); const mutateTankopediaEphemeral = TankopediaEphemeral.useMutation();
@@ -131,7 +131,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
<group ref={turretContainer}> <group ref={turretContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentTurret = node.name.startsWith( const isCurrentTurret = node.name.startsWith(
`turret_${turretModelDefinition.modelId.toString().padStart(2, '0')}`, `turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentTurret; const isVisible = isCurrentTurret;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -177,7 +177,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
const boundingRect = canvas.getBoundingClientRect(); const boundingRect = canvas.getBoundingClientRect();
@@ -226,7 +226,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
<group ref={gunContainer}> <group ref={gunContainer}>
{armorNodes.map((node) => { {armorNodes.map((node) => {
const isCurrentGun = node.name.startsWith( const isCurrentGun = node.name.startsWith(
`gun_${gunModelDefinition.modelId.toString().padStart(2, '0')}`, `gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`,
); );
const isVisible = isCurrentGun; const isVisible = isCurrentGun;
const armorId = nameToArmorId(node.name); const armorId = nameToArmorId(node.name);
@@ -272,7 +272,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
const boundingRect = canvas.getBoundingClientRect(); const boundingRect = canvas.getBoundingClientRect();
@@ -317,7 +317,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
})} })}
{modelNodes.map((node) => { {modelNodes.map((node) => {
const gunString = `gun_${gunModelDefinition.modelId const gunString = `gun_${gunModelDefinition.model_id
.toString() .toString()
.padStart(2, '0')}`; .padStart(2, '0')}`;
const isCurrentGun = gunModelDefinition.mask const isCurrentGun = gunModelDefinition.mask
@@ -354,7 +354,7 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
const boundingRect = canvas.getBoundingClientRect(); const boundingRect = canvas.getBoundingClientRect();
@@ -13,7 +13,7 @@ interface BodyProps {
export function Body({ stats }: BodyProps) { export function Body({ stats }: BodyProps) {
const members = CompareEphemeral.use((state) => state.members); const members = CompareEphemeral.use((state) => state.members);
const hasNonRegularGun = members.some( const hasNonRegularGun = members.some(
({ gun }) => gun.gunType!.$case !== 'regular', ({ gun }) => gun.gun_type!.$case !== 'regular',
); );
const mutateCompareEphemeral = CompareEphemeral.useMutation(); const mutateCompareEphemeral = CompareEphemeral.useMutation();
@@ -31,7 +31,7 @@ export function Body({ stats }: BodyProps) {
<StickyColumnHeaderCell key={key} top={137}> <StickyColumnHeaderCell key={key} top={137}>
<Flex justify="center"> <Flex justify="center">
<Flex> <Flex>
{gun.gunType!.value.base.shells.map( {gun.gun_type!.value.base.shells.map(
(thisShell, shellIndex) => ( (thisShell, shellIndex) => (
<IconButton <IconButton
color={thisShell.id === shell.id ? undefined : 'gray'} color={thisShell.id === shell.id ? undefined : 'gray'}
@@ -43,12 +43,12 @@ export function Body({ stats }: BodyProps) {
shellIndex === 0 ? undefined : 0, shellIndex === 0 ? undefined : 0,
borderTopRightRadius: borderTopRightRadius:
shellIndex === shellIndex ===
gun.gunType!.value.base.shells.length - 1 gun.gun_type!.value.base.shells.length - 1
? undefined ? undefined
: 0, : 0,
borderBottomRightRadius: borderBottomRightRadius:
shellIndex === shellIndex ===
gun.gunType!.value.base.shells.length - 1 gun.gun_type!.value.base.shells.length - 1
? undefined ? undefined
: 0, : 0,
marginLeft: shellIndex === 0 ? 0 : -1, marginLeft: shellIndex === 0 ? 0 : -1,
@@ -169,7 +169,7 @@ export function CompareTable({ stats }: CompareTableProps) {
index, index,
) => { ) => {
const equipmentPreset = const equipmentPreset =
equipmentDefinitions.presets[tank.equipmentPreset]; equipmentDefinitions.presets[tank.equipment_preset];
const provisionsList = availableProvisions( const provisionsList = availableProvisions(
tank, tank,
gun, gun,
@@ -239,7 +239,7 @@ export function CompareTable({ stats }: CompareTableProps) {
member.turret = member.tank.turrets[0]; member.turret = member.tank.turrets[0];
member.gun = member.turret.guns[0]; member.gun = member.turret.guns[0];
member.shell = member.shell =
member.gun.gunType!.value.base.shells[0]; member.gun.gun_type!.value.base.shells[0];
member.engine = member.tank.engines[0]; member.engine = member.tank.engines[0];
member.track = member.tank.tracks[0]; member.track = member.tank.tracks[0];
}); });
@@ -256,7 +256,7 @@ export function CompareTable({ stats }: CompareTableProps) {
member.turret = member.tank.turrets.at(-1)!; member.turret = member.tank.turrets.at(-1)!;
member.gun = member.turret.guns.at(-1)!; member.gun = member.turret.guns.at(-1)!;
member.shell = member.shell =
member.gun.gunType!.value.base.shells[0]; member.gun.gun_type!.value.base.shells[0];
member.engine = member.tank.engines.at(-1)!; member.engine = member.tank.engines.at(-1)!;
member.track = member.tank.tracks.at(-1)!; member.track = member.tank.tracks.at(-1)!;
}); });
@@ -329,7 +329,7 @@ export function CompareTable({ stats }: CompareTableProps) {
(provision) => provision.id, (provision) => provision.id,
)} )}
selected={provisions} selected={provisions}
disabled={tank.maxProvisions === provisions.length} disabled={tank.max_provisions === provisions.length}
onChange={(provisions) => { onChange={(provisions) => {
mutateCompareEphemeral((draft) => { mutateCompareEphemeral((draft) => {
draft.members[index].provisions = provisions; draft.members[index].provisions = provisions;
@@ -515,7 +515,7 @@ export function CompareTable({ stats }: CompareTableProps) {
}); });
}} }}
disabled={ disabled={
tank.maxConsumables === consumables.length tank.max_consumables === consumables.length
} }
/> />
@@ -60,7 +60,7 @@ export function ModuleManager({
const draft = { ...modules }; const draft = { ...modules };
draft.turret = turret; draft.turret = turret;
draft.gun = draft.turret.guns.at(-1)!; draft.gun = draft.turret.guns.at(-1)!;
draft.shell = draft.gun.gunType!.value.base.shells[0]; draft.shell = draft.gun.gun_type!.value.base.shells[0];
onChange?.(draft); onChange?.(draft);
setTurretMenuOpen(false); setTurretMenuOpen(false);
@@ -82,7 +82,7 @@ export function ModuleManager({
<ModuleButton <ModuleButton
module="gun" module="gun"
discriminator={ discriminator={
TIER_ROMAN_NUMERALS[modules.gun.gunType!.value.base.tier] TIER_ROMAN_NUMERALS[modules.gun.gun_type!.value.base.tier]
} }
onClick={() => setGunMenuOpen(true)} onClick={() => setGunMenuOpen(true)}
/> />
@@ -94,17 +94,17 @@ export function ModuleManager({
<DropdownMenu.Content> <DropdownMenu.Content>
<DropdownMenu.RadioGroup <DropdownMenu.RadioGroup
value={`${modules.gun.gunType!.value.base.id}`} value={`${modules.gun.gun_type!.value.base.id}`}
> >
{[...modules.turret.guns].reverse().map((gun) => { {[...modules.turret.guns].reverse().map((gun) => {
return ( return (
<DropdownMenu.RadioItem <DropdownMenu.RadioItem
key={gun.gunType!.value.base.id} key={gun.gun_type!.value.base.id}
value={`${gun.gunType!.value.base.id}`} value={`${gun.gun_type!.value.base.id}`}
onClick={() => { onClick={() => {
const draft = { ...modules }; const draft = { ...modules };
draft.gun = gun; draft.gun = gun;
draft.shell = draft.gun.gunType!.value.base.shells[0]; draft.shell = draft.gun.gun_type!.value.base.shells[0];
onChange?.(draft); onChange?.(draft);
setGunMenuOpen(false); setGunMenuOpen(false);
@@ -114,10 +114,10 @@ export function ModuleManager({
variant="ghost" variant="ghost"
module="gun" module="gun"
discriminator={ discriminator={
TIER_ROMAN_NUMERALS[gun.gunType!.value.base.tier] TIER_ROMAN_NUMERALS[gun.gun_type!.value.base.tier]
} }
/>{' '} />{' '}
{gun.gunType!.value.base.name} {gun.gun_type!.value.base.name}
</DropdownMenu.RadioItem> </DropdownMenu.RadioItem>
); );
})} })}
@@ -32,26 +32,26 @@ export function TankCard({ tank, onSelect }: TankCardProps) {
const turret = tank.turrets.at(-1)!; const turret = tank.turrets.at(-1)!;
const gun = turret.guns.at(-1)!; const gun = turret.guns.at(-1)!;
const shell0 = gun.gunType!.value.base.shells[0]; const shell0 = gun.gun_type!.value.base.shells[0];
const shell1 = gun.gunType!.value.base.shells[1]; const shell1 = gun.gun_type!.value.base.shells[1];
const tracks = tank.tracks.at(-1)!; const tracks = tank.tracks.at(-1)!;
const engine = tank.engines.at(-1)!; const engine = tank.engines.at(-1)!;
const tankModelDefinition = modelDefinitions.models[tank.id]; const tankModelDefinition = modelDefinitions.models[tank.id];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
switch (tankopediaSort.by) { switch (tankopediaSort.by) {
case 'fire.aimTime': case 'fire.aimTime':
return gun.gunType!.value.base.aimTime.toFixed(2); return gun.gun_type!.value.base.aim_time.toFixed(2);
case 'fire.caliber': case 'fire.caliber':
return shell0.caliber.toFixed(0); return shell0.caliber.toFixed(0);
case 'fire.damage': case 'fire.damage':
return shell0.armorDamage.toFixed(0); return shell0.armor_damage.toFixed(0);
case 'fire.dispersionMoving': case 'fire.dispersionMoving':
return tracks.dispersionMove.toFixed(3); return tracks.dispersion_move.toFixed(3);
case 'fire.dispersionStill': case 'fire.dispersionStill':
return gun.gunType!.value.base.dispersionBase.toFixed(3); return gun.gun_type!.value.base.dispersion_base.toFixed(3);
case 'fire.dpm': case 'fire.dpm':
return resolveDpm(gun, shell0).toFixed(0); return resolveDpm(gun, shell0).toFixed(0);
case 'fire.dpmPremium': case 'fire.dpmPremium':
@@ -67,17 +67,17 @@ export function TankCard({ tank, onSelect }: TankCardProps) {
case 'fire.gunDepression': case 'fire.gunDepression':
return ( return (
gunModelDefinition.pitch.max + gunModelDefinition.pitch.max +
(tankModelDefinition.initialTurretRotation?.pitch ?? 0) (tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
).toFixed(1); ).toFixed(1);
case 'fire.gunElevation': case 'fire.gunElevation':
return ( return (
-gunModelDefinition.pitch.min - -gunModelDefinition.pitch.min -
(tankModelDefinition.initialTurretRotation?.pitch ?? 0) (tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
).toFixed(1); ).toFixed(1);
case 'maneuverability.forwardsSpeed': case 'maneuverability.forwardsSpeed':
return tank.speedForwards.toFixed(0); return tank.speed_forwards.toFixed(0);
case 'maneuverability.backwardsSpeed': case 'maneuverability.backwardsSpeed':
return tank.speedBackwards.toFixed(0); return tank.speed_backwards.toFixed(0);
case 'maneuverability.power': case 'maneuverability.power':
return engine.power.toFixed(0); return engine.power.toFixed(0);
case 'maneuverability.powerToWeight': case 'maneuverability.powerToWeight':
@@ -87,7 +87,7 @@ export function TankCard({ tank, onSelect }: TankCardProps) {
engine.weight + engine.weight +
tracks.weight + tracks.weight +
turret.weight + turret.weight +
gun.gunType!.value.base.weight) gun.gun_type!.value.base.weight)
).toFixed(1); ).toFixed(1);
case 'maneuverability.weight': case 'maneuverability.weight':
return ( return (
@@ -95,30 +95,30 @@ export function TankCard({ tank, onSelect }: TankCardProps) {
engine.weight + engine.weight +
tracks.weight + tracks.weight +
turret.weight + turret.weight +
gun.gunType!.value.base.weight) / gun.gun_type!.value.base.weight) /
1000 1000
).toFixed(1); ).toFixed(1);
case 'maneuverability.traverseSpeed': case 'maneuverability.traverseSpeed':
return tracks.traverseSpeed.toFixed(1); return tracks.traverse_speed.toFixed(1);
case 'survivability.health': case 'survivability.health':
return (tank.health + turret.health).toFixed(0); return (tank.health + turret.health).toFixed(0);
case 'survivability.viewRange': case 'survivability.viewRange':
return turret.viewRange.toFixed(0); return turret.view_range.toFixed(0);
case 'survivability.camouflageStill': case 'survivability.camouflageStill':
return (tank.camouflageStill * 100).toFixed(0); return (tank.camouflage_still * 100).toFixed(0);
case 'survivability.camouflageMoving': case 'survivability.camouflageMoving':
return (tank.camouflageMoving * 100).toFixed(0); return (tank.camouflage_moving * 100).toFixed(0);
case 'survivability.camouflageShooting': case 'survivability.camouflageShooting':
return ( return (
tank.camouflageStill * tank.camouflage_still *
gun.gunType!.value.base.camouflageLoss * gun.gun_type!.value.base.camouflage_loss *
100 100
).toFixed(0); ).toFixed(0);
case 'survivability.volume': { case 'survivability.volume': {
const dimensions = normalizeBoundingBox( const dimensions = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
tankModelDefinition.boundingBox, tankModelDefinition.bounding_box,
turretModelDefinition.boundingBox, turretModelDefinition.bounding_box,
), ),
); );
@@ -128,8 +128,8 @@ export function TankCard({ tank, onSelect }: TankCardProps) {
case 'survivability.length': { case 'survivability.length': {
const bounds = normalizeBoundingBox( const bounds = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
tankModelDefinition.boundingBox, tankModelDefinition.bounding_box,
turretModelDefinition.boundingBox, turretModelDefinition.bounding_box,
), ),
); );
@@ -94,31 +94,31 @@ export const TankSearch = memo<TankSearchProps>(
case 'survivability.viewRange': case 'survivability.viewRange':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.viewRange - b.turrets.at(-1)!.viewRange, a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range,
); );
break; break;
case 'survivability.camouflageStill': case 'survivability.camouflageStill':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => a.camouflageStill - b.camouflageStill, (a, b) => a.camouflage_still - b.camouflage_still,
); );
break; break;
case 'survivability.camouflageMoving': case 'survivability.camouflageMoving':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => a.camouflageMoving - b.camouflageMoving, (a, b) => a.camouflage_moving - b.camouflage_moving,
); );
break; break;
case 'survivability.camouflageShooting': case 'survivability.camouflageShooting':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.camouflageStill * a.camouflage_still *
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.camouflageLoss - .camouflage_loss -
b.camouflageStill * b.camouflage_still *
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.camouflageLoss, .camouflage_loss,
); );
break; break;
@@ -132,14 +132,14 @@ export const TankSearch = memo<TankSearchProps>(
bTankModelDefinition.turrets[b.turrets.at(-1)!.id]; bTankModelDefinition.turrets[b.turrets.at(-1)!.id];
const aSize = normalizeBoundingBox( const aSize = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
aTankModelDefinition.boundingBox, aTankModelDefinition.bounding_box,
aTurretModelDefinition.boundingBox, aTurretModelDefinition.bounding_box,
), ),
); );
const bSize = normalizeBoundingBox( const bSize = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
bTankModelDefinition.boundingBox, bTankModelDefinition.bounding_box,
bTurretModelDefinition.boundingBox, bTurretModelDefinition.bounding_box,
), ),
); );
const aVolume = aSize.x * aSize.y * aSize.z; const aVolume = aSize.x * aSize.y * aSize.z;
@@ -159,14 +159,14 @@ export const TankSearch = memo<TankSearchProps>(
bTankModelDefinition.turrets[b.turrets.at(-1)!.id]; bTankModelDefinition.turrets[b.turrets.at(-1)!.id];
const aSize = normalizeBoundingBox( const aSize = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
aTankModelDefinition.boundingBox, aTankModelDefinition.bounding_box,
aTurretModelDefinition.boundingBox, aTurretModelDefinition.bounding_box,
), ),
); );
const bSize = normalizeBoundingBox( const bSize = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
bTankModelDefinition.boundingBox, bTankModelDefinition.bounding_box,
bTurretModelDefinition.boundingBox, bTurretModelDefinition.bounding_box,
), ),
); );
const aLength = Math.max(aSize.x, aSize.y, aSize.z); const aLength = Math.max(aSize.x, aSize.y, aSize.z);
@@ -181,11 +181,11 @@ export const TankSearch = memo<TankSearchProps>(
(a, b) => (a, b) =>
resolveDpm( resolveDpm(
a.turrets.at(-1)!.guns.at(-1)!, a.turrets.at(-1)!.guns.at(-1)!,
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0], a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0],
) - ) -
resolveDpm( resolveDpm(
b.turrets.at(-1)!.guns.at(-1)!, b.turrets.at(-1)!.guns.at(-1)!,
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0], b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0],
), ),
); );
break; break;
@@ -193,17 +193,17 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.dpmPremium': case 'fire.dpmPremium':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
(a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[1] (a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[1]
? resolveDpm( ? resolveDpm(
a.turrets.at(-1)!.guns.at(-1)!, a.turrets.at(-1)!.guns.at(-1)!,
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.shells[1], .shells[1],
) )
: 0) - : 0) -
(b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[1] (b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[1]
? resolveDpm( ? resolveDpm(
b.turrets.at(-1)!.guns.at(-1)!, b.turrets.at(-1)!.guns.at(-1)!,
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.shells[1], .shells[1],
) )
: 0), : 0),
@@ -221,9 +221,9 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.caliber': case 'fire.caliber':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.caliber - .caliber -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.caliber, .caliber,
); );
break; break;
@@ -231,9 +231,9 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.standardPenetration': case 'fire.standardPenetration':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.penetration.near - .penetration.near -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.penetration.near, .penetration.near,
); );
break; break;
@@ -241,9 +241,9 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.premiumPenetration': case 'fire.premiumPenetration':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
(a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[1] (a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[1]
?.penetration.near ?? 0) - ?.penetration.near ?? 0) -
(b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[1] (b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[1]
?.penetration.near ?? 0), ?.penetration.near ?? 0),
); );
break; break;
@@ -251,19 +251,19 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.damage': case 'fire.damage':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.armorDamage - .armor_damage -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.armorDamage, .armor_damage,
); );
break; break;
case 'fire.shellVelocity': case 'fire.shellVelocity':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.velocity - .velocity -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.velocity, .velocity,
); );
break; break;
@@ -271,26 +271,26 @@ export const TankSearch = memo<TankSearchProps>(
case 'fire.aimTime': case 'fire.aimTime':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.aimTime - a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.aim_time -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.aimTime, b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.aim_time,
); );
break; break;
case 'fire.dispersionStill': case 'fire.dispersionStill':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.dispersionBase - .dispersion_base -
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.dispersionBase, .dispersion_base,
); );
break; break;
case 'fire.dispersionMoving': case 'fire.dispersionMoving':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.tracks.at(-1)!.dispersionMove - a.tracks.at(-1)!.dispersion_move -
b.tracks.at(-1)!.dispersionMove, b.tracks.at(-1)!.dispersion_move,
); );
break; break;
@@ -298,14 +298,14 @@ export const TankSearch = memo<TankSearchProps>(
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id] modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
.guns[a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.id] .guns[a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.id]
.pitch.max + .pitch.max +
(modelDefinitions.models[a.id].initialTurretRotation?.pitch ?? (modelDefinitions.models[a.id].initial_turret_rotation?.pitch ??
0) - 0) -
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id] modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
.guns[b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.id] .guns[b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.id]
.pitch.max - .pitch.max -
(modelDefinitions.models[b.id].initialTurretRotation?.pitch ?? (modelDefinitions.models[b.id].initial_turret_rotation?.pitch ??
0), 0),
); );
break; break;
@@ -314,25 +314,27 @@ export const TankSearch = memo<TankSearchProps>(
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id] modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id]
.guns[b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.id] .guns[b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.id]
.pitch.min + .pitch.min +
(modelDefinitions.models[b.id].initialTurretRotation?.pitch ?? (modelDefinitions.models[b.id].initial_turret_rotation?.pitch ??
0) - 0) -
modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id] modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id]
.guns[a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.id] .guns[a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.id]
.pitch.min - .pitch.min -
(modelDefinitions.models[a.id].initialTurretRotation?.pitch ?? (modelDefinitions.models[a.id].initial_turret_rotation?.pitch ??
0), 0),
); );
break; break;
case 'maneuverability.forwardsSpeed': case 'maneuverability.forwardsSpeed':
sorted = filtered.sort((a, b) => a.speedForwards - b.speedForwards); sorted = filtered.sort(
(a, b) => a.speed_forwards - b.speed_forwards,
);
break; break;
case 'maneuverability.backwardsSpeed': case 'maneuverability.backwardsSpeed':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => a.speedBackwards - b.speedBackwards, (a, b) => a.speed_backwards - b.speed_backwards,
); );
break; break;
@@ -350,13 +352,14 @@ export const TankSearch = memo<TankSearchProps>(
a.engines.at(-1)!.weight + a.engines.at(-1)!.weight +
a.tracks.at(-1)!.weight + a.tracks.at(-1)!.weight +
a.turrets.at(-1)!.weight + a.turrets.at(-1)!.weight +
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.weight) - a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base
.weight) -
b.engines.at(-1)!.power / b.engines.at(-1)!.power /
(b.weight + (b.weight +
b.engines.at(-1)!.weight + b.engines.at(-1)!.weight +
b.tracks.at(-1)!.weight + b.tracks.at(-1)!.weight +
b.turrets.at(-1)!.weight + b.turrets.at(-1)!.weight +
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.weight), b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.weight),
); );
break; break;
@@ -367,19 +370,20 @@ export const TankSearch = memo<TankSearchProps>(
a.engines.at(-1)!.weight + a.engines.at(-1)!.weight +
a.tracks.at(-1)!.weight + a.tracks.at(-1)!.weight +
a.turrets.at(-1)!.weight + a.turrets.at(-1)!.weight +
a.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.weight - a.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.weight -
(b.weight + (b.weight +
b.engines.at(-1)!.weight + b.engines.at(-1)!.weight +
b.tracks.at(-1)!.weight + b.tracks.at(-1)!.weight +
b.turrets.at(-1)!.weight + b.turrets.at(-1)!.weight +
b.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.weight), b.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.weight),
); );
break; break;
case 'maneuverability.traverseSpeed': case 'maneuverability.traverseSpeed':
sorted = filtered.sort( sorted = filtered.sort(
(a, b) => (a, b) =>
a.tracks.at(-1)!.traverseSpeed - b.tracks.at(-1)!.traverseSpeed, a.tracks.at(-1)!.traverse_speed -
b.tracks.at(-1)!.traverse_speed,
); );
break; break;
} }
@@ -75,7 +75,7 @@ export function Characteristics() {
const tankModelDefinition = useTankModelDefinition(); const tankModelDefinition = useTankModelDefinition();
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
const stats = tankCharacteristics( const stats = tankCharacteristics(
{ {
tank, tank,
@@ -148,7 +148,7 @@ export function Characteristics() {
<Heading size="5">Firepower</Heading> <Heading size="5">Firepower</Heading>
<Flex> <Flex>
{gun.gunType!.value.base.shells.map((thisShell, shellIndex) => ( {gun.gun_type!.value.base.shells.map((thisShell, shellIndex) => (
<Tooltip content={thisShell.name} key={thisShell.id}> <Tooltip content={thisShell.name} key={thisShell.id}>
<IconButton <IconButton
color={thisShell.id === shell.id ? undefined : 'gray'} color={thisShell.id === shell.id ? undefined : 'gray'}
@@ -157,11 +157,13 @@ export function Characteristics() {
borderTopLeftRadius: shellIndex === 0 ? undefined : 0, borderTopLeftRadius: shellIndex === 0 ? undefined : 0,
borderBottomLeftRadius: shellIndex === 0 ? undefined : 0, borderBottomLeftRadius: shellIndex === 0 ? undefined : 0,
borderTopRightRadius: borderTopRightRadius:
shellIndex === gun.gunType!.value.base.shells.length - 1 shellIndex ===
gun.gun_type!.value.base.shells.length - 1
? undefined ? undefined
: 0, : 0,
borderBottomRightRadius: borderBottomRightRadius:
shellIndex === gun.gunType!.value.base.shells.length - 1 shellIndex ===
gun.gun_type!.value.base.shells.length - 1
? undefined ? undefined
: 0, : 0,
marginLeft: shellIndex === 0 ? 0 : -1, marginLeft: shellIndex === 0 ? 0 : -1,
@@ -183,11 +185,11 @@ export function Characteristics() {
))} ))}
</Flex> </Flex>
</Flex> </Flex>
<Info name="Gun type">{GUN_TYPE_NAMES[gun.gunType!.$case]}</Info> <Info name="Gun type">{GUN_TYPE_NAMES[gun.gun_type!.$case]}</Info>
<InfoWithDelta name="DPM" decimals={0} unit="hp / min"> <InfoWithDelta name="DPM" decimals={0} unit="hp / min">
{stats.dpm} {stats.dpm}
</InfoWithDelta> </InfoWithDelta>
{gun.gunType!.$case === 'autoReloader' && ( {gun.gun_type!.$case === 'auto_reloader' && (
<InfoWithDelta <InfoWithDelta
decimals={0} decimals={0}
indent indent
@@ -197,10 +199,10 @@ export function Characteristics() {
{stats.dpmEffective!} {stats.dpmEffective!}
</InfoWithDelta> </InfoWithDelta>
)} )}
{gun.gunType!.$case !== 'regular' && ( {gun.gun_type!.$case !== 'regular' && (
<InfoWithDelta name="Shells">{stats.shells}</InfoWithDelta> <InfoWithDelta name="Shells">{stats.shells}</InfoWithDelta>
)} )}
{gun.gunType!.$case === 'autoReloader' ? ( {gun.gun_type!.$case === 'auto_reloader' ? (
<> <>
<Info indent name="Most optimal shell index"> <Info indent name="Most optimal shell index">
{stats.mostOptimalShellIndex! + 1} {stats.mostOptimalShellIndex! + 1}
@@ -228,8 +230,8 @@ export function Characteristics() {
{stats.shellReload!} {stats.shellReload!}
</InfoWithDelta> </InfoWithDelta>
)} )}
{(gun.gunType!.$case === 'autoLoader' || {(gun.gun_type!.$case === 'auto_loader' ||
gun.gunType!.$case === 'autoReloader') && ( gun.gun_type!.$case === 'auto_reloader') && (
<InfoWithDelta <InfoWithDelta
indent indent
decimals={2} decimals={2}
@@ -300,7 +302,7 @@ export function Characteristics() {
<InfoWithDelta name="Damage" unit="hp" decimals={0}> <InfoWithDelta name="Damage" unit="hp" decimals={0}>
{stats.damage} {stats.damage}
</InfoWithDelta> </InfoWithDelta>
{gun.gunType!.$case !== 'regular' && ( {gun.gun_type!.$case !== 'regular' && (
<InfoWithDelta name="Clipping potential" indent> <InfoWithDelta name="Clipping potential" indent>
{stats.clipDamage!} {stats.clipDamage!}
</InfoWithDelta> </InfoWithDelta>
@@ -74,7 +74,7 @@ export function Consumables() {
consumables={consumablesList} consumables={consumablesList}
selected={consumables} selected={consumables}
cooldownBooster={cooldownBooster} cooldownBooster={cooldownBooster}
disabled={protagonist.tank.maxConsumables === consumables.length} disabled={protagonist.tank.max_consumables === consumables.length}
hasConsumableDeliverySystem={hasConsumableDeliverySystem} hasConsumableDeliverySystem={hasConsumableDeliverySystem}
hasHighEndConsumables={hasHighEndConsumables} hasHighEndConsumables={hasHighEndConsumables}
timers timers
@@ -10,7 +10,7 @@ export function Equipment() {
const mutateDuel = Duel.useMutation(); const mutateDuel = Duel.useMutation();
const protagonist = Duel.use((state) => state.protagonist); const protagonist = Duel.use((state) => state.protagonist);
const equipmentPreset = const equipmentPreset =
equipmentDefinitions.presets[protagonist.tank.equipmentPreset]; equipmentDefinitions.presets[protagonist.tank.equipment_preset];
const equipmentMatrix = Duel.use( const equipmentMatrix = Duel.use(
(state) => state.protagonist.equipmentMatrix, (state) => state.protagonist.equipmentMatrix,
); );
@@ -38,7 +38,7 @@ export function Miscellaneous() {
<Heading size="4">Miscellaneous</Heading> <Heading size="4">Miscellaneous</Heading>
<Flex gap="2" align="center"> <Flex gap="2" align="center">
{!tank.fixedCamouflage && ( {!tank.fixed_camouflage && (
<GenericTankComponentButton <GenericTankComponentButton
icon={asset('icons/camo.webp')} icon={asset('icons/camo.webp')}
selected={camouflage} selected={camouflage}
@@ -32,8 +32,8 @@ type ModuleDefinition =
| EngineDefinition; | EngineDefinition;
function extractModule(raw: ModuleDefinition | TankDefinition) { function extractModule(raw: ModuleDefinition | TankDefinition) {
if ('gunType' in raw) { if ('gun_type' in raw) {
return raw.gunType!.value.base; return raw.gun_type!.value.base;
} else } else
return raw as Exclude<ModuleDefinition | TankDefinition, GunDefinition>; return raw as Exclude<ModuleDefinition | TankDefinition, GunDefinition>;
} }
@@ -172,34 +172,36 @@ export function Modules() {
if ( if (
!draft.protagonist.turret.guns.some( !draft.protagonist.turret.guns.some(
(gun) => (gun) =>
gun.gunType!.value.base.id === gun.gun_type!.value.base.id ===
draft.protagonist.gun.gunType!.value.base.id, draft.protagonist.gun.gun_type!.value.base.id,
) )
) { ) {
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!; draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
draft.protagonist.shell = draft.protagonist.shell =
draft.protagonist.gun.gunType!.value.base.shells[0]; draft.protagonist.gun.gun_type!.value.base.shells[0];
} }
} else if (unlock.type === ModuleType.GUN) { } else if (unlock.type === ModuleType.GUN) {
const gunInTurret = draft.protagonist.turret.guns.find( const gunInTurret = draft.protagonist.turret.guns.find(
(gun) => gun.gunType!.value.base.id === unlock.id, (gun) => gun.gun_type!.value.base.id === unlock.id,
); );
if (gunInTurret) { if (gunInTurret) {
draft.protagonist.gun = gunInTurret; draft.protagonist.gun = gunInTurret;
draft.protagonist.shell = gunInTurret.gunType!.value.base.shells[0]; draft.protagonist.shell = gunInTurret.gun_type!.value.base.shells[0];
} else { } else {
// TODO: warn somehow? // TODO: warn somehow?
const suitableTurret = draft.protagonist.tank.turrets.find((turret) => const suitableTurret = draft.protagonist.tank.turrets.find((turret) =>
turret.guns.some((gun) => gun.gunType!.value.base.id === unlock.id), turret.guns.some(
(gun) => gun.gun_type!.value.base.id === unlock.id,
),
)!; )!;
const gunInSuitableTurret = suitableTurret.guns.find( const gunInSuitableTurret = suitableTurret.guns.find(
(gun) => gun.gunType!.value.base.id === unlock.id, (gun) => gun.gun_type!.value.base.id === unlock.id,
)!; )!;
draft.protagonist.turret = suitableTurret; draft.protagonist.turret = suitableTurret;
draft.protagonist.gun = gunInSuitableTurret; draft.protagonist.gun = gunInSuitableTurret;
draft.protagonist.shell = draft.protagonist.shell =
gunInSuitableTurret.gunType!.value.base.shells[0]; gunInSuitableTurret.gun_type!.value.base.shells[0];
} }
} else if (unlock.type === ModuleType.ENGINE) { } else if (unlock.type === ModuleType.ENGINE) {
draft.protagonist.engine = draft.protagonist.tank.engines.find( draft.protagonist.engine = draft.protagonist.tank.engines.find(
@@ -232,10 +234,10 @@ export function Modules() {
module = tank.turrets module = tank.turrets
.find((turret) => .find((turret) =>
turret.guns.some( turret.guns.some(
(gun) => gun.gunType!.value.base.id === unlock.id, (gun) => gun.gun_type!.value.base.id === unlock.id,
), ),
)! )!
.guns.find((gun) => gun.gunType!.value.base.id === unlock.id)!; .guns.find((gun) => gun.gun_type!.value.base.id === unlock.id)!;
} else if (unlock.type === ModuleType.VEHICLE) { } else if (unlock.type === ModuleType.VEHICLE) {
module = tankDefinitions.tanks[unlock.id]; module = tankDefinitions.tanks[unlock.id];
} }
@@ -298,7 +300,7 @@ export function Modules() {
(unlock.type === ModuleType.TURRET (unlock.type === ModuleType.TURRET
? turret.id ? turret.id
: unlock.type === ModuleType.GUN : unlock.type === ModuleType.GUN
? gun.gunType!.value.base.id ? gun.gun_type!.value.base.id
: unlock.type === ModuleType.ENGINE : unlock.type === ModuleType.ENGINE
? engine.id ? engine.id
: unlock.type === ModuleType.TRACKS : unlock.type === ModuleType.TRACKS
@@ -310,7 +312,7 @@ export function Modules() {
? extractModule(module).id == topTurret.id ? extractModule(module).id == topTurret.id
: unlock.type === ModuleType.GUN : unlock.type === ModuleType.GUN
? extractModule(module).id === ? extractModule(module).id ===
topGun.gunType!.value.base.id topGun.gun_type!.value.base.id
: unlock.type === ModuleType.ENGINE : unlock.type === ModuleType.ENGINE
? extractModule(module).id === topEngine.id ? extractModule(module).id === topEngine.id
: unlock.type === ModuleType.TRACKS : unlock.type === ModuleType.TRACKS
@@ -360,7 +362,7 @@ export function Modules() {
draft.protagonist.turret = draft.protagonist.tank.turrets[0]; draft.protagonist.turret = draft.protagonist.tank.turrets[0];
draft.protagonist.gun = draft.protagonist.turret.guns[0]; draft.protagonist.gun = draft.protagonist.turret.guns[0];
draft.protagonist.shell = draft.protagonist.shell =
draft.protagonist.gun.gunType!.value.base.shells[0]; draft.protagonist.gun.gun_type!.value.base.shells[0];
draft.protagonist.engine = draft.protagonist.tank.engines[0]; draft.protagonist.engine = draft.protagonist.tank.engines[0];
draft.protagonist.track = draft.protagonist.tank.tracks[0]; draft.protagonist.track = draft.protagonist.tank.tracks[0];
}); });
@@ -376,7 +378,7 @@ export function Modules() {
draft.protagonist.tank.turrets.at(-1)!; draft.protagonist.tank.turrets.at(-1)!;
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!; draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
draft.protagonist.shell = draft.protagonist.shell =
draft.protagonist.gun.gunType!.value.base.shells[0]; draft.protagonist.gun.gun_type!.value.base.shells[0];
draft.protagonist.engine = draft.protagonist.engine =
draft.protagonist.tank.engines.at(-1)!; draft.protagonist.tank.engines.at(-1)!;
draft.protagonist.track = draft.protagonist.track =
@@ -415,7 +417,7 @@ export function Modules() {
{tree(ModuleType.GUN, [ {tree(ModuleType.GUN, [
{ {
cost: { type: 'xp', value: 0 }, cost: { type: 'xp', value: 0 },
id: gun0.gunType!.value.base.id, id: gun0.gun_type!.value.base.id,
type: ModuleType.GUN, type: ModuleType.GUN,
}, },
])} ])}
@@ -32,7 +32,7 @@ export function Provisions() {
<ProvisionsManager <ProvisionsManager
provisions={provisionsList.map((provision) => provision.id)} provisions={provisionsList.map((provision) => provision.id)}
selected={provisions} selected={provisions}
disabled={tank.maxProvisions === provisions.length} disabled={tank.max_provisions === provisions.length}
onChange={(provisions) => { onChange={(provisions) => {
mutateDuel((draft) => { mutateDuel((draft) => {
draft.protagonist.provisions = provisions; draft.protagonist.provisions = provisions;
@@ -28,8 +28,8 @@ export function DynamicArmorSwitcher() {
draft.protagonist.consumables = draft.protagonist.consumables =
draft.protagonist.consumables.filter((id) => id !== 73); draft.protagonist.consumables.filter((id) => id !== 73);
} else { } else {
if (draft.protagonist.consumables.length === tank.maxConsumables) { if (draft.protagonist.consumables.length === tank.max_consumables) {
draft.protagonist.consumables[tank.maxConsumables - 1] = 73; draft.protagonist.consumables[tank.max_consumables - 1] = 73;
} else { } else {
draft.protagonist.consumables.push(73); draft.protagonist.consumables.push(73);
} }
@@ -21,8 +21,9 @@ export function QuickInputs() {
const turretModelDefinition = const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id]; tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id]; turretModelDefinition.guns[protagonist.gun.gun_type!.value.base.id];
const initialGunPitch = tankModelDefinition.initialTurretRotation?.pitch ?? 0; const initialGunPitch =
tankModelDefinition.initial_turret_rotation?.pitch ?? 0;
const hasImprovedVerticalStabilizer = useEquipment(122); const hasImprovedVerticalStabilizer = useEquipment(122);
useEffect(() => { useEffect(() => {
@@ -45,7 +46,7 @@ export function QuickInputs() {
pitchInput.current.value = ( pitchInput.current.value = (
-radToDeg(pitch) + -radToDeg(pitch) +
(tankModelDefinition.initialTurretRotation?.pitch ?? 0) (tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
).toFixed(1); ).toFixed(1);
if (yaw === undefined) return; if (yaw === undefined) return;
@@ -131,7 +131,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
> >
{ {
TIER_ROMAN_NUMERALS[ TIER_ROMAN_NUMERALS[
antagonistGun.gunType!.value.base.tier antagonistGun.gun_type!.value.base.tier
] ]
} }
</Text> </Text>
@@ -155,21 +155,21 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
.map(({ gun, turret }) => ( .map(({ gun, turret }) => (
<ModuleButton <ModuleButton
module="gun" module="gun"
key={gun.gunType!.value.base.id} key={gun.gun_type!.value.base.id}
onClick={() => onClick={() =>
mutateDuel((draft) => { mutateDuel((draft) => {
draft.antagonist.turret = turret; draft.antagonist.turret = turret;
draft.antagonist.gun = gun; draft.antagonist.gun = gun;
draft.antagonist.shell = draft.antagonist.shell =
gun.gunType!.value.base.shells[0]; gun.gun_type!.value.base.shells[0];
}) })
} }
selected={ selected={
gun.gunType!.value.base.id === gun.gun_type!.value.base.id ===
antagonistGun.gunType!.value.base.id antagonistGun.gun_type!.value.base.id
} }
discriminator={ discriminator={
TIER_ROMAN_NUMERALS[gun.gunType!.value.base.tier] TIER_ROMAN_NUMERALS[gun.gun_type!.value.base.tier]
} }
/> />
))} ))}
@@ -184,7 +184,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
}} }}
overflow="hidden" overflow="hidden"
> >
{antagonistGun.gunType!.value.base.shells.map( {antagonistGun.gun_type!.value.base.shells.map(
(thisShell, shellIndex) => ( (thisShell, shellIndex) => (
<IconButton <IconButton
color={ color={
@@ -332,7 +332,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
draft.antagonist.gun = draft.antagonist.gun =
draft.antagonist.turret.guns.at(-1)!; draft.antagonist.turret.guns.at(-1)!;
draft.antagonist.shell = draft.antagonist.shell =
draft.antagonist.gun.gunType!.value.base.shells[0]; draft.antagonist.gun.gun_type!.value.base.shells[0];
}); });
setAntagonistSelectorOpen(false); setAntagonistSelectorOpen(false);
}} }}
@@ -38,7 +38,7 @@ export function Controls() {
antagonistModelDefinition.turrets[antagonist.turret.id]; antagonistModelDefinition.turrets[antagonist.turret.id];
const protagonistGunModelDefinition = const protagonistGunModelDefinition =
protagonistTurretModelDefinition.guns[ protagonistTurretModelDefinition.guns[
protagonist.gun.gunType!.value.base.id protagonist.gun.gun_type!.value.base.id
]; ];
const protagonistHullOrigin = new Vector3( const protagonistHullOrigin = new Vector3(
protagonistTrackModelDefinition.origin.x, protagonistTrackModelDefinition.origin.x,
@@ -46,19 +46,19 @@ export function Controls() {
-protagonistTrackModelDefinition.origin.z, -protagonistTrackModelDefinition.origin.z,
); );
const protagonistTurretOrigin = new Vector3( const protagonistTurretOrigin = new Vector3(
protagonistModelDefinition.turretOrigin.x, protagonistModelDefinition.turret_origin.x,
protagonistModelDefinition.turretOrigin.y, protagonistModelDefinition.turret_origin.y,
-protagonistModelDefinition.turretOrigin.z, -protagonistModelDefinition.turret_origin.z,
); );
const protagonistGunOrigin = new Vector3( const protagonistGunOrigin = new Vector3(
protagonistTurretModelDefinition.gunOrigin.x, protagonistTurretModelDefinition.gun_origin.x,
protagonistTurretModelDefinition.gunOrigin.y, protagonistTurretModelDefinition.gun_origin.y,
-protagonistTurretModelDefinition.gunOrigin.z, -protagonistTurretModelDefinition.gun_origin.z,
); );
const antagonistGunHeight = const antagonistGunHeight =
protagonistTrackModelDefinition.origin.y + protagonistTrackModelDefinition.origin.y +
antagonistModelDefinition.turretOrigin.y + antagonistModelDefinition.turret_origin.y +
antagonistTurretModelDefinition.gunOrigin.y; antagonistTurretModelDefinition.gun_origin.y;
const [autoRotate, setAutoRotate] = useState(true); const [autoRotate, setAutoRotate] = useState(true);
useEffect(() => { useEffect(() => {
@@ -78,7 +78,7 @@ export function Controls() {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
@@ -29,7 +29,7 @@ export const TankModel = memo(() => {
const turretModelDefinition = const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id]; tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id]; turretModelDefinition.guns[protagonist.gun.gun_type!.value.base.id];
const { gltf } = useModel(protagonist.tank.id); const { gltf } = useModel(protagonist.tank.id);
const nodes = Object.values(gltf.nodes); const nodes = Object.values(gltf.nodes);
const isDynamicArmorActive = Duel.use((state) => const isDynamicArmorActive = Duel.use((state) =>
@@ -136,7 +136,7 @@ export const TankModel = memo(() => {
const isTurret = node.name.startsWith('turret_'); const isTurret = node.name.startsWith('turret_');
const isCurrentTurret = const isCurrentTurret =
node.name === node.name ===
`turret_${turretModelDefinition.modelId.toString().padStart(2, '0')}`; `turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`;
const isVisible = isCurrentTurret; const isVisible = isCurrentTurret;
const position = new Vector2(); const position = new Vector2();
const delta = new Vector2(); const delta = new Vector2();
@@ -169,7 +169,7 @@ export const TankModel = memo(() => {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
const boundingRect = canvas.getBoundingClientRect(); const boundingRect = canvas.getBoundingClientRect();
@@ -232,12 +232,12 @@ export const TankModel = memo(() => {
{nodes.map((node) => { {nodes.map((node) => {
const isCurrentMantlet = const isCurrentMantlet =
node.name === node.name ===
`gun_${gunModelDefinition.modelId `gun_${gunModelDefinition.model_id
.toString() .toString()
.padStart(2, '0')}_mask`; .padStart(2, '0')}_mask`;
const isCurrentGun = const isCurrentGun =
node.name === node.name ===
`gun_${gunModelDefinition.modelId.toString().padStart(2, '0')}`; `gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`;
const isVisible = isCurrentGun || isCurrentMantlet; const isVisible = isCurrentGun || isCurrentMantlet;
const position = new Vector2(); const position = new Vector2();
const delta = new Vector2(); const delta = new Vector2();
@@ -269,7 +269,7 @@ export const TankModel = memo(() => {
const duel = duelStore.getState(); const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment( const hasImprovedVerticalStabilizer = await hasEquipment(
122, 122,
duel.protagonist.tank.equipmentPreset, duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix, duel.protagonist.equipmentMatrix,
); );
const boundingRect = canvas.getBoundingClientRect(); const boundingRect = canvas.getBoundingClientRect();
@@ -45,7 +45,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
const turretModelDefinition = const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id]; tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id]; turretModelDefinition.guns[protagonist.gun.gun_type!.value.base.id];
const display = TankopediaPersistent.useDeferred( const display = TankopediaPersistent.useDeferred(
(state) => state.display, (state) => state.display,
TankopediaDisplay.Model, TankopediaDisplay.Model,
@@ -34,7 +34,7 @@ export function HeroSection() {
(filtered.reduce((accumulator, thisTank) => { (filtered.reduce((accumulator, thisTank) => {
return ( return (
accumulator + accumulator +
thisTank.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0] thisTank.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0]
.penetration.near .penetration.near
); );
}, 0) / }, 0) /
@@ -105,8 +105,8 @@ export function MetaSection() {
direction={{ initial: 'column', sm: 'row' }} direction={{ initial: 'column', sm: 'row' }}
> >
<Flex direction="column" width="100%"> <Flex direction="column" width="100%">
{protagonist.nameFull && ( {protagonist.name_full && (
<Listing label="Full-name">{protagonist.nameFull}</Listing> <Listing label="Full-name">{protagonist.name_full}</Listing>
)} )}
<Listing label="Nation"> <Listing label="Nation">
<Flex align="center" gap="1"> <Flex align="center" gap="1">
@@ -199,11 +199,12 @@ export function MetaSection() {
/> />
</Flex> </Flex>
</Listing> </Listing>
{protagonist.researchCost && ( {protagonist.research_cost && (
<Listing label="Research XP"> <Listing label="Research XP">
<Flex align="center" gap="1"> <Flex align="center" gap="1">
{( {(
protagonist.researchCost.researchCostType!.value as number protagonist.research_cost.research_cost_type!
.value as number
).toLocaleString()} ).toLocaleString()}
<img <img
style={{ width: '1em', height: '1em' }} style={{ width: '1em', height: '1em' }}
@@ -22,15 +22,17 @@ export function Node({ id, highlight, nextIds }: NodeProps) {
const tank = tankDefinitions.tanks[id]; const tank = tankDefinitions.tanks[id];
const nextTanks = nextIds?.map((id) => tankDefinitions.tanks[id]); const nextTanks = nextIds?.map((id) => tankDefinitions.tanks[id]);
const thisTankXp = const thisTankXp =
tank.researchCost === undefined || tank.tier === 1 tank.research_cost === undefined || tank.tier === 1
? 0 ? 0
: (tank.researchCost.researchCostType!.value as number)! / xpMultiplier; : (tank.research_cost.research_cost_type!.value as number)! /
xpMultiplier;
const nextTanksXp = nextTanks?.reduce( const nextTanksXp = nextTanks?.reduce(
(xp, tank) => (xp, tank) =>
xp + xp +
(tank.researchCost === undefined || tank.tier === 1 (tank.research_cost === undefined || tank.tier === 1
? 0 ? 0
: (tank.researchCost.researchCostType!.value as number) / xpMultiplier), : (tank.research_cost.research_cost_type!.value as number) /
xpMultiplier),
0, 0,
); );
const averages = averageDefinitions.averages[tank.id]?.mu; const averages = averageDefinitions.averages[tank.id]?.mu;
@@ -53,10 +53,10 @@ export function TechTreeSection() {
const totalXp = line.reduce( const totalXp = line.reduce(
(xp, id) => (xp, id) =>
xp + xp +
(tankDefinitions.tanks[id].researchCost === undefined || (tankDefinitions.tanks[id].research_cost === undefined ||
tankDefinitions.tanks[id].tier === 1 tankDefinitions.tanks[id].tier === 1
? 0 ? 0
: (tankDefinitions.tanks[id].researchCost.researchCostType! : (tankDefinitions.tanks[id].research_cost.research_cost_type!
.value as number)), .value as number)),
0, 0,
); );
@@ -1,19 +1,19 @@
import type { GunDefinition } from '@blitzkit/core'; import type { GunDefinition } from '@blitzkit/core';
export function resolveReload(gun: GunDefinition) { export function resolveReload(gun: GunDefinition) {
if (gun.gunType!.$case === 'regular') { if (gun.gun_type!.$case === 'regular') {
return gun.gunType!.value.extension.reload; return gun.gun_type!.value.extension.reload;
} else if (gun.gunType!.$case === 'autoLoader') { } else if (gun.gun_type!.$case === 'auto_loader') {
return ( return (
gun.gunType!.value.extension.clipReload + gun.gun_type!.value.extension.clip_reload +
(gun.gunType!.value.extension.shellCount - 1) * (gun.gun_type!.value.extension.shell_count - 1) *
gun.gunType!.value.extension.intraClip gun.gun_type!.value.extension.intra_clip
); );
} else { } else {
return ( return (
gun.gunType!.value.extension.shellReloads.reduce((a, b) => a + b, 0) + gun.gun_type!.value.extension.shell_reloads.reduce((a, b) => a + b, 0) +
(gun.gunType!.value.extension.shellCount - 1) * (gun.gun_type!.value.extension.shell_count - 1) *
gun.gunType!.value.extension.intraClip gun.gun_type!.value.extension.intra_clip
); );
} }
} }
@@ -77,10 +77,10 @@ export function tankCharacteristics(
provisionDefinitions: ProvisionDefinitions; provisionDefinitions: ProvisionDefinitions;
}, },
) { ) {
const preset = equipmentDefinitions.presets[tank.equipmentPreset]; const preset = equipmentDefinitions.presets[tank.equipment_preset];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition = const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id]; turretModelDefinition.guns[gun.gun_type!.value.base.id];
function equipment(id: number) { function equipment(id: number) {
return preset.slots.some((slot, index) => { return preset.slots.some((slot, index) => {
@@ -129,7 +129,8 @@ export function tankCharacteristics(
const hasGearOil = provision(44); const hasGearOil = provision(44);
const hasImprovedGearOil = provision(45); const hasImprovedGearOil = provision(45);
const gunDefaultPitch = tankModelDefinition.initialTurretRotation?.pitch ?? 0; const gunDefaultPitch =
tankModelDefinition.initial_turret_rotation?.pitch ?? 0;
const provisionCrewBonus = const provisionCrewBonus =
provisions.reduce( provisions.reduce(
(total, provision) => (total, provision) =>
@@ -159,7 +160,7 @@ export function tankCharacteristics(
const reloadCoefficient = const reloadCoefficient =
(coefficient([hasGunRammer, -0.05]) * (coefficient([hasGunRammer, -0.05]) *
coefficient([true, degressiveStat(loaderMastery)])) / coefficient([true, degressiveStat(loaderMastery)])) /
coefficient([hasAdrenaline && gun.gunType!.$case === 'regular', 0.17]); coefficient([hasAdrenaline && gun.gun_type!.$case === 'regular', 0.17]);
const penetrationCoefficient = coefficient([ const penetrationCoefficient = coefficient([
hasCalibratedShells, hasCalibratedShells,
resolvePenetrationCoefficient(true, shell.type) - 1, resolvePenetrationCoefficient(true, shell.type) - 1,
@@ -310,8 +311,8 @@ export function tankCharacteristics(
const size = normalizeBoundingBox( const size = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
tankModelDefinition.boundingBox, tankModelDefinition.bounding_box,
turretModelDefinition.boundingBox, turretModelDefinition.bounding_box,
), ),
); );
const weightKg = const weightKg =
@@ -319,14 +320,14 @@ export function tankCharacteristics(
engine.weight + engine.weight +
track.weight + track.weight +
turret.weight + turret.weight +
gun.gunType!.value.base.weight; gun.gun_type!.value.base.weight;
const weightTons = weightKg / 1000; const weightTons = weightKg / 1000;
const stockWeight = const stockWeight =
tank.weight + tank.weight +
stockEngine.weight + stockEngine.weight +
stockTrack.weight + stockTrack.weight +
stockTurret.weight + stockTurret.weight +
stockGun.gunType!.value.base.weight; stockGun.gun_type!.value.base.weight;
const resolvedEnginePower = engine.power * enginePowerCoefficient; const resolvedEnginePower = engine.power * enginePowerCoefficient;
const dpm = resolveDpm( const dpm = resolveDpm(
gun, gun,
@@ -336,12 +337,12 @@ export function tankCharacteristics(
intraClipCoefficient, intraClipCoefficient,
); );
const intraClip = const intraClip =
gun.gunType?.$case === 'regular' gun.gun_type?.$case === 'regular'
? undefined ? undefined
: gun.gunType!.value.extension.intraClip * intraClipCoefficient; : gun.gun_type!.value.extension.intra_clip * intraClipCoefficient;
const mostOptimalShellIndex = const mostOptimalShellIndex =
gun.gunType!.$case === 'autoReloader' gun.gun_type!.$case === 'auto_reloader'
? gun.gunType!.value.extension.shellReloads.reduce<null | { ? gun.gun_type!.value.extension.shell_reloads.reduce<null | {
index: number; index: number;
reload: number; reload: number;
}>((current, reloadRaw, index) => { }>((current, reloadRaw, index) => {
@@ -354,82 +355,86 @@ export function tankCharacteristics(
return current; return current;
}, null)!.index }, null)!.index
: undefined; : undefined;
const damage = shell.armorDamage * damageCoefficient; const damage = shell.armor_damage * damageCoefficient;
const dpmEffective = const dpmEffective =
gun.gunType!.$case === 'autoReloader' gun.gun_type!.$case === 'auto_reloader'
? gun.gunType!.value.extension.shellReloads[0] > ? gun.gun_type!.value.extension.shell_reloads[0] >
gun.gunType!.value.extension.shellReloads[1] + gun.gun_type!.value.extension.shell_reloads[1] +
gun.gunType!.value.extension.intraClip gun.gun_type!.value.extension.intra_clip
? ((damageCoefficient * shell.armorDamage) / ? ((damageCoefficient * shell.armor_damage) /
(gun.gunType!.value.extension.shellReloads.at(-1)! * (gun.gun_type!.value.extension.shell_reloads.at(-1)! *
reloadCoefficient + reloadCoefficient +
gun.gunType!.value.extension.intraClip * intraClipCoefficient)) * gun.gun_type!.value.extension.intra_clip *
intraClipCoefficient)) *
(60 - (60 -
(gun.gunType!.value.extension.shellReloads.slice(0, -1).length - (gun.gun_type!.value.extension.shell_reloads.slice(0, -1).length -
1) * 1) *
gun.gunType!.value.extension.intraClip * gun.gun_type!.value.extension.intra_clip *
intraClipCoefficient) + intraClipCoefficient) +
damageCoefficient * damageCoefficient *
shell.armorDamage * shell.armor_damage *
gun.gunType!.value.extension.shellReloads.slice(0, -1).length gun.gun_type!.value.extension.shell_reloads.slice(0, -1).length
: ((damageCoefficient * shell.armorDamage) / : ((damageCoefficient * shell.armor_damage) /
(gun.gunType!.value.extension.shellReloads[0] * reloadCoefficient + (gun.gun_type!.value.extension.shell_reloads[0] *
gun.gunType!.value.extension.intraClip * intraClipCoefficient)) * reloadCoefficient +
gun.gun_type!.value.extension.intra_clip *
intraClipCoefficient)) *
(60 - (60 -
(gun.gunType!.value.extension.shellReloads.slice(1).length - 1) * (gun.gun_type!.value.extension.shell_reloads.slice(1).length -
gun.gunType!.value.extension.intraClip * 1) *
gun.gun_type!.value.extension.intra_clip *
intraClipCoefficient) + intraClipCoefficient) +
damageCoefficient * damageCoefficient *
shell.armorDamage * shell.armor_damage *
gun.gunType!.value.extension.shellReloads.slice(1).length gun.gun_type!.value.extension.shell_reloads.slice(1).length
: undefined; : undefined;
const shells = const shells =
gun.gunType!.$case === 'regular' gun.gun_type!.$case === 'regular'
? 1 ? 1
: gun.gunType!.value.extension.shellCount; : gun.gun_type!.value.extension.shell_count;
const shellReloads = const shellReloads =
gun.gunType!.$case === 'autoReloader' gun.gun_type!.$case === 'auto_reloader'
? gun.gunType!.value.extension.shellReloads.map( ? gun.gun_type!.value.extension.shell_reloads.map(
(reload) => reload * reloadCoefficient, (reload) => reload * reloadCoefficient,
) )
: undefined; : undefined;
const shellReload = const shellReload =
gun.gunType!.$case === 'autoReloader' gun.gun_type!.$case === 'auto_reloader'
? undefined ? undefined
: (gun.gunType!.$case === 'regular' : (gun.gun_type!.$case === 'regular'
? gun.gunType!.value.extension.reload ? gun.gun_type!.value.extension.reload
: gun.gunType!.value.extension.clipReload) * reloadCoefficient; : gun.gun_type!.value.extension.clip_reload) * reloadCoefficient;
const caliber = shell.caliber; const caliber = shell.caliber;
const penetration = shell.penetration.near * penetrationCoefficient; const penetration = shell.penetration.near * penetrationCoefficient;
const clipDamage = const clipDamage =
gun.gunType!.$case === 'regular' gun.gun_type!.$case === 'regular'
? undefined ? undefined
: gun.gunType!.value.extension.shellCount * damage; : gun.gun_type!.value.extension.shell_count * damage;
const moduleDamage = shell.moduleDamage * damageCoefficient; const moduleDamage = shell.module_damage * damageCoefficient;
const explosionRadius = shell.explosionRadius; const explosionRadius = shell.explosion_radius;
const shellVelocity = shell.velocity * shellVelocityCoefficient; const shellVelocity = shell.velocity * shellVelocityCoefficient;
const aimTime = gun.gunType!.value.base.aimTime * aimTimeCoefficient; const aimTime = gun.gun_type!.value.base.aim_time * aimTimeCoefficient;
const dispersion = const dispersion =
gun.gunType!.value.base.dispersionBase * dispersionStillCoefficient; gun.gun_type!.value.base.dispersion_base * dispersionStillCoefficient;
const maxDispersion = const maxDispersion =
gun.gunType!.value.base.dispersionBase * gun.gun_type!.value.base.dispersion_base *
Math.sqrt( Math.sqrt(
((gun.gunType!.value.base.dispersionTraverse * turret.traverseSpeed) ** ((gun.gun_type!.value.base.dispersion_traverse * turret.traverse_speed) **
2 + 2 +
(track.traverseSpeed * track.traverseSpeed) ** 2 + (track.traverse_speed * track.traverse_speed) ** 2 +
track.dispersionMove * tank.speedForwards) ** track.dispersion_move * tank.speed_forwards) **
2, 2,
); );
const dispersionMoving = track.dispersionMove * dispersionMovingCoefficient; const dispersionMoving = track.dispersion_move * dispersionMovingCoefficient;
const dispersionHullTraversing = const dispersionHullTraversing =
track.traverseSpeed * dispersionHullTraverseCoefficient; track.traverse_speed * dispersionHullTraverseCoefficient;
const dispersionTurretTraversing = const dispersionTurretTraversing =
gun.gunType!.value.base.dispersionTraverse * gun.gun_type!.value.base.dispersion_traverse *
dispersionTurretTraverseCoefficient; dispersionTurretTraverseCoefficient;
const dispersionShooting = const dispersionShooting =
gun.gunType!.value.base.dispersionShot * dispersionAfterShotCoefficient; gun.gun_type!.value.base.dispersion_shot * dispersionAfterShotCoefficient;
const dispersionGunDamaged = const dispersionGunDamaged =
gun.gunType!.value.base.dispersionDamaged * dispersionDamagedCoefficient; gun.gun_type!.value.base.dispersion_damaged * dispersionDamagedCoefficient;
const gunDepression = const gunDepression =
gunModelDefinition.pitch.max + gunModelDefinition.pitch.max +
gunDefaultPitch + gunDefaultPitch +
@@ -450,17 +455,17 @@ export function tankCharacteristics(
? -turretModelDefinition.yaw.min ? -turretModelDefinition.yaw.min
: undefined; : undefined;
const azimuthRight = turretModelDefinition.yaw?.max; const azimuthRight = turretModelDefinition.yaw?.max;
const speedForwards = tank.speedForwards + speedForwardsSum; const speedForwards = tank.speed_forwards + speedForwardsSum;
const speedBackwards = tank.speedBackwards + speedBackwardsSum; const speedBackwards = tank.speed_backwards + speedBackwardsSum;
const enginePower = resolvedEnginePower; const enginePower = resolvedEnginePower;
const hardTerrainCoefficientRaw = const hardTerrainCoefficientRaw =
track.resistanceHard * resistanceHardCoefficient; track.resistance_hard * resistanceHardCoefficient;
const hardTerrainCoefficient = 100 / hardTerrainCoefficientRaw; const hardTerrainCoefficient = 100 / hardTerrainCoefficientRaw;
const mediumTerrainCoefficientRaw = const mediumTerrainCoefficientRaw =
track.resistanceMedium * resistanceMediumCoefficient; track.resistance_medium * resistanceMediumCoefficient;
const mediumTerrainCoefficient = 100 / mediumTerrainCoefficientRaw; const mediumTerrainCoefficient = 100 / mediumTerrainCoefficientRaw;
const softTerrainCoefficientRaw = const softTerrainCoefficientRaw =
track.resistanceSoft * resistanceSoftCoefficient; track.resistance_soft * resistanceSoftCoefficient;
const softTerrainCoefficient = 100 / softTerrainCoefficientRaw; const softTerrainCoefficient = 100 / softTerrainCoefficientRaw;
const powerToWeightRatioHardTerrain = const powerToWeightRatioHardTerrain =
resolvedEnginePower / weightTons / hardTerrainCoefficientRaw; resolvedEnginePower / weightTons / hardTerrainCoefficientRaw;
@@ -469,44 +474,44 @@ export function tankCharacteristics(
const powerToWeightRatioSoftTerrain = const powerToWeightRatioSoftTerrain =
resolvedEnginePower / weightTons / softTerrainCoefficientRaw; resolvedEnginePower / weightTons / softTerrainCoefficientRaw;
const weight = weightTons; const weight = weightTons;
const turretTraverseSpeed = turret.traverseSpeed * turretTraverseCoefficient; const turretTraverseSpeed = turret.traverse_speed * turretTraverseCoefficient;
const hullTraverseHardTerrain = const hullTraverseHardTerrain =
(resolvedEnginePower / stockEngine.power) * (resolvedEnginePower / stockEngine.power) *
track.traverseSpeed * track.traverse_speed *
hullTraverseCoefficient * hullTraverseCoefficient *
(track.resistanceHard / hardTerrainCoefficientRaw) * (track.resistance_hard / hardTerrainCoefficientRaw) *
(stockWeight / weightKg); (stockWeight / weightKg);
const hullTraverseMediumTerrain = const hullTraverseMediumTerrain =
(resolvedEnginePower / stockEngine.power) * (resolvedEnginePower / stockEngine.power) *
track.traverseSpeed * track.traverse_speed *
hullTraverseCoefficient * hullTraverseCoefficient *
(track.resistanceHard / mediumTerrainCoefficientRaw) * (track.resistance_hard / mediumTerrainCoefficientRaw) *
(stockWeight / weightKg); (stockWeight / weightKg);
const hullTraverseSoftTerrain = const hullTraverseSoftTerrain =
(resolvedEnginePower / stockEngine.power) * (resolvedEnginePower / stockEngine.power) *
track.traverseSpeed * track.traverse_speed *
hullTraverseCoefficient * hullTraverseCoefficient *
(track.resistanceHard / softTerrainCoefficientRaw) * (track.resistance_hard / softTerrainCoefficientRaw) *
(stockWeight / weightKg); (stockWeight / weightKg);
const health = (tank.health + turret.health) * healthCoefficient; const health = (tank.health + turret.health) * healthCoefficient;
const fireChance = engine.fireChance * fireChanceCoefficient; const fireChance = engine.fire_chance * fireChanceCoefficient;
const viewRange = turret.viewRange * viewRangeCoefficient; const viewRange = turret.view_range * viewRangeCoefficient;
const camouflageStill = tank.camouflageStill * camouflageCoefficientStill; const camouflageStill = tank.camouflage_still * camouflageCoefficientStill;
const camouflageMoving = const camouflageMoving =
tank.class === TankClass.LIGHT tank.class === TankClass.LIGHT
? tank.camouflageStill * camouflageCoefficientStill ? tank.camouflage_still * camouflageCoefficientStill
: tank.camouflageMoving * camouflageCoefficientMoving; : tank.camouflage_moving * camouflageCoefficientMoving;
const camouflageShootingStill = const camouflageShootingStill =
tank.camouflageStill * tank.camouflage_still *
gun.gunType!.value.base.camouflageLoss * gun.gun_type!.value.base.camouflage_loss *
camouflageCoefficientStill; camouflageCoefficientStill;
const camouflageShootingMoving = const camouflageShootingMoving =
(tank.class === TankClass.LIGHT (tank.class === TankClass.LIGHT
? tank.camouflageStill * camouflageCoefficientStill ? tank.camouflage_still * camouflageCoefficientStill
: tank.camouflageMoving * camouflageCoefficientMoving) * : tank.camouflage_moving * camouflageCoefficientMoving) *
gun.gunType!.value.base.camouflageLoss; gun.gun_type!.value.base.camouflage_loss;
const camouflageCaughtOnFire = const camouflageCaughtOnFire =
tank.camouflageOnFire * tank.camouflageStill * camouflageCoefficientStill; tank.camouflage_onFire * tank.camouflage_still * camouflageCoefficientStill;
const width = size.z; const width = size.z;
const height = size.x; const height = size.x;
const length = size.y; const length = size.y;
@@ -37,11 +37,11 @@ export function tankToDuelMember(
infinityFallback(PROVISION_PREFERENCES.indexOf(b.id)), infinityFallback(PROVISION_PREFERENCES.indexOf(b.id)),
) )
.sort((a, b) => (b.crew ?? 0) - (a.crew ?? 0)) .sort((a, b) => (b.crew ?? 0) - (a.crew ?? 0))
.slice(0, tank.maxProvisions) .slice(0, tank.max_provisions)
.map(({ id }) => id), .map(({ id }) => id),
engine: tank.engines.at(-1)!, engine: tank.engines.at(-1)!,
gun, gun,
shell: tank.turrets.at(-1)!.guns.at(-1)!.gunType!.value.base.shells[0], shell: tank.turrets.at(-1)!.guns.at(-1)!.gun_type!.value.base.shells[0],
tank, tank,
track: tank.tracks.at(-1)!, track: tank.tracks.at(-1)!,
yaw: 0, yaw: 0,
+1 -1
View File
@@ -8,7 +8,7 @@ export function useEquipment(id: number, antagonist = false) {
const member = Duel.use( const member = Duel.use(
(state) => state[antagonist ? 'antagonist' : 'protagonist']!, (state) => state[antagonist ? 'antagonist' : 'protagonist']!,
); );
const preset = equipmentDefinitions.presets[member.tank.equipmentPreset]; const preset = equipmentDefinitions.presets[member.tank.equipment_preset];
const equipmentMatrix = Duel.use( const equipmentMatrix = Duel.use(
(state) => (state) =>
state[antagonist ? 'antagonist' : 'protagonist']!.equipmentMatrix, state[antagonist ? 'antagonist' : 'protagonist']!.equipmentMatrix,
@@ -22,8 +22,8 @@ export function useTankTransform(
const turretModelDefinition = tankModelDefinition.turrets[member.turret.id]; const turretModelDefinition = tankModelDefinition.turrets[member.turret.id];
const hullOrigin = correctZYTuple(trackModelDefinition.origin); const hullOrigin = correctZYTuple(trackModelDefinition.origin);
const turretOrigin = correctZYTuple(tankModelDefinition.turretOrigin); const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin);
const gunOrigin = correctZYTuple(turretModelDefinition.gunOrigin); const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin);
const turretPosition = new Vector3(); const turretPosition = new Vector3();
const turretRotation = new Euler(); const turretRotation = new Euler();
const gunPosition = new Vector3(); const gunPosition = new Vector3();
@@ -52,15 +52,15 @@ export function useTankTransform(
.applyAxisAngle(new Vector3(0, 0, 1), yaw); .applyAxisAngle(new Vector3(0, 0, 1), yaw);
turretRotation.set(0, 0, yaw); turretRotation.set(0, 0, yaw);
if (tankModelDefinition.initialTurretRotation) { if (tankModelDefinition.initial_turret_rotation) {
const initialPitch = -degToRad( const initialPitch = -degToRad(
tankModelDefinition.initialTurretRotation.pitch, tankModelDefinition.initial_turret_rotation.pitch,
); );
const initialYaw = -degToRad( const initialYaw = -degToRad(
tankModelDefinition.initialTurretRotation.yaw, tankModelDefinition.initial_turret_rotation.yaw,
); );
const initialRoll = -degToRad( const initialRoll = -degToRad(
tankModelDefinition.initialTurretRotation.roll, tankModelDefinition.initial_turret_rotation.roll,
); );
turretPosition turretPosition