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

@@ -75,7 +75,7 @@ export function Characteristics() {
const tankModelDefinition = useTankModelDefinition();
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
const gunModelDefinition =
turretModelDefinition.guns[gun.gunType!.value.base.id];
turretModelDefinition.guns[gun.gun_type!.value.base.id];
const stats = tankCharacteristics(
{
tank,
@@ -148,7 +148,7 @@ export function Characteristics() {
<Heading size="5">Firepower</Heading>
<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}>
<IconButton
color={thisShell.id === shell.id ? undefined : 'gray'}
@@ -157,11 +157,13 @@ export function Characteristics() {
borderTopLeftRadius: shellIndex === 0 ? undefined : 0,
borderBottomLeftRadius: shellIndex === 0 ? undefined : 0,
borderTopRightRadius:
shellIndex === gun.gunType!.value.base.shells.length - 1
shellIndex ===
gun.gun_type!.value.base.shells.length - 1
? undefined
: 0,
borderBottomRightRadius:
shellIndex === gun.gunType!.value.base.shells.length - 1
shellIndex ===
gun.gun_type!.value.base.shells.length - 1
? undefined
: 0,
marginLeft: shellIndex === 0 ? 0 : -1,
@@ -183,11 +185,11 @@ export function Characteristics() {
))}
</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">
{stats.dpm}
</InfoWithDelta>
{gun.gunType!.$case === 'autoReloader' && (
{gun.gun_type!.$case === 'auto_reloader' && (
<InfoWithDelta
decimals={0}
indent
@@ -197,10 +199,10 @@ export function Characteristics() {
{stats.dpmEffective!}
</InfoWithDelta>
)}
{gun.gunType!.$case !== 'regular' && (
{gun.gun_type!.$case !== 'regular' && (
<InfoWithDelta name="Shells">{stats.shells}</InfoWithDelta>
)}
{gun.gunType!.$case === 'autoReloader' ? (
{gun.gun_type!.$case === 'auto_reloader' ? (
<>
<Info indent name="Most optimal shell index">
{stats.mostOptimalShellIndex! + 1}
@@ -228,8 +230,8 @@ export function Characteristics() {
{stats.shellReload!}
</InfoWithDelta>
)}
{(gun.gunType!.$case === 'autoLoader' ||
gun.gunType!.$case === 'autoReloader') && (
{(gun.gun_type!.$case === 'auto_loader' ||
gun.gun_type!.$case === 'auto_reloader') && (
<InfoWithDelta
indent
decimals={2}
@@ -300,7 +302,7 @@ export function Characteristics() {
<InfoWithDelta name="Damage" unit="hp" decimals={0}>
{stats.damage}
</InfoWithDelta>
{gun.gunType!.$case !== 'regular' && (
{gun.gun_type!.$case !== 'regular' && (
<InfoWithDelta name="Clipping potential" indent>
{stats.clipDamage!}
</InfoWithDelta>
@@ -74,7 +74,7 @@ export function Consumables() {
consumables={consumablesList}
selected={consumables}
cooldownBooster={cooldownBooster}
disabled={protagonist.tank.maxConsumables === consumables.length}
disabled={protagonist.tank.max_consumables === consumables.length}
hasConsumableDeliverySystem={hasConsumableDeliverySystem}
hasHighEndConsumables={hasHighEndConsumables}
timers
@@ -10,7 +10,7 @@ export function Equipment() {
const mutateDuel = Duel.useMutation();
const protagonist = Duel.use((state) => state.protagonist);
const equipmentPreset =
equipmentDefinitions.presets[protagonist.tank.equipmentPreset];
equipmentDefinitions.presets[protagonist.tank.equipment_preset];
const equipmentMatrix = Duel.use(
(state) => state.protagonist.equipmentMatrix,
);
@@ -38,7 +38,7 @@ export function Miscellaneous() {
<Heading size="4">Miscellaneous</Heading>
<Flex gap="2" align="center">
{!tank.fixedCamouflage && (
{!tank.fixed_camouflage && (
<GenericTankComponentButton
icon={asset('icons/camo.webp')}
selected={camouflage}
@@ -32,8 +32,8 @@ type ModuleDefinition =
| EngineDefinition;
function extractModule(raw: ModuleDefinition | TankDefinition) {
if ('gunType' in raw) {
return raw.gunType!.value.base;
if ('gun_type' in raw) {
return raw.gun_type!.value.base;
} else
return raw as Exclude<ModuleDefinition | TankDefinition, GunDefinition>;
}
@@ -172,34 +172,36 @@ export function Modules() {
if (
!draft.protagonist.turret.guns.some(
(gun) =>
gun.gunType!.value.base.id ===
draft.protagonist.gun.gunType!.value.base.id,
gun.gun_type!.value.base.id ===
draft.protagonist.gun.gun_type!.value.base.id,
)
) {
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
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) {
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) {
draft.protagonist.gun = gunInTurret;
draft.protagonist.shell = gunInTurret.gunType!.value.base.shells[0];
draft.protagonist.shell = gunInTurret.gun_type!.value.base.shells[0];
} else {
// TODO: warn somehow?
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(
(gun) => gun.gunType!.value.base.id === unlock.id,
(gun) => gun.gun_type!.value.base.id === unlock.id,
)!;
draft.protagonist.turret = suitableTurret;
draft.protagonist.gun = gunInSuitableTurret;
draft.protagonist.shell =
gunInSuitableTurret.gunType!.value.base.shells[0];
gunInSuitableTurret.gun_type!.value.base.shells[0];
}
} else if (unlock.type === ModuleType.ENGINE) {
draft.protagonist.engine = draft.protagonist.tank.engines.find(
@@ -232,10 +234,10 @@ export function Modules() {
module = tank.turrets
.find((turret) =>
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) {
module = tankDefinitions.tanks[unlock.id];
}
@@ -298,7 +300,7 @@ export function Modules() {
(unlock.type === ModuleType.TURRET
? turret.id
: unlock.type === ModuleType.GUN
? gun.gunType!.value.base.id
? gun.gun_type!.value.base.id
: unlock.type === ModuleType.ENGINE
? engine.id
: unlock.type === ModuleType.TRACKS
@@ -310,7 +312,7 @@ export function Modules() {
? extractModule(module).id == topTurret.id
: unlock.type === ModuleType.GUN
? extractModule(module).id ===
topGun.gunType!.value.base.id
topGun.gun_type!.value.base.id
: unlock.type === ModuleType.ENGINE
? extractModule(module).id === topEngine.id
: unlock.type === ModuleType.TRACKS
@@ -360,7 +362,7 @@ export function Modules() {
draft.protagonist.turret = draft.protagonist.tank.turrets[0];
draft.protagonist.gun = draft.protagonist.turret.guns[0];
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.track = draft.protagonist.tank.tracks[0];
});
@@ -376,7 +378,7 @@ export function Modules() {
draft.protagonist.tank.turrets.at(-1)!;
draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!;
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.at(-1)!;
draft.protagonist.track =
@@ -415,7 +417,7 @@ export function Modules() {
{tree(ModuleType.GUN, [
{
cost: { type: 'xp', value: 0 },
id: gun0.gunType!.value.base.id,
id: gun0.gun_type!.value.base.id,
type: ModuleType.GUN,
},
])}
@@ -32,7 +32,7 @@ export function Provisions() {
<ProvisionsManager
provisions={provisionsList.map((provision) => provision.id)}
selected={provisions}
disabled={tank.maxProvisions === provisions.length}
disabled={tank.max_provisions === provisions.length}
onChange={(provisions) => {
mutateDuel((draft) => {
draft.protagonist.provisions = provisions;
@@ -28,8 +28,8 @@ export function DynamicArmorSwitcher() {
draft.protagonist.consumables =
draft.protagonist.consumables.filter((id) => id !== 73);
} else {
if (draft.protagonist.consumables.length === tank.maxConsumables) {
draft.protagonist.consumables[tank.maxConsumables - 1] = 73;
if (draft.protagonist.consumables.length === tank.max_consumables) {
draft.protagonist.consumables[tank.max_consumables - 1] = 73;
} else {
draft.protagonist.consumables.push(73);
}
@@ -21,8 +21,9 @@ export function QuickInputs() {
const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id];
const initialGunPitch = tankModelDefinition.initialTurretRotation?.pitch ?? 0;
turretModelDefinition.guns[protagonist.gun.gun_type!.value.base.id];
const initialGunPitch =
tankModelDefinition.initial_turret_rotation?.pitch ?? 0;
const hasImprovedVerticalStabilizer = useEquipment(122);
useEffect(() => {
@@ -45,7 +46,7 @@ export function QuickInputs() {
pitchInput.current.value = (
-radToDeg(pitch) +
(tankModelDefinition.initialTurretRotation?.pitch ?? 0)
(tankModelDefinition.initial_turret_rotation?.pitch ?? 0)
).toFixed(1);
if (yaw === undefined) return;
@@ -131,7 +131,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
>
{
TIER_ROMAN_NUMERALS[
antagonistGun.gunType!.value.base.tier
antagonistGun.gun_type!.value.base.tier
]
}
</Text>
@@ -155,21 +155,21 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
.map(({ gun, turret }) => (
<ModuleButton
module="gun"
key={gun.gunType!.value.base.id}
key={gun.gun_type!.value.base.id}
onClick={() =>
mutateDuel((draft) => {
draft.antagonist.turret = turret;
draft.antagonist.gun = gun;
draft.antagonist.shell =
gun.gunType!.value.base.shells[0];
gun.gun_type!.value.base.shells[0];
})
}
selected={
gun.gunType!.value.base.id ===
antagonistGun.gunType!.value.base.id
gun.gun_type!.value.base.id ===
antagonistGun.gun_type!.value.base.id
}
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"
>
{antagonistGun.gunType!.value.base.shells.map(
{antagonistGun.gun_type!.value.base.shells.map(
(thisShell, shellIndex) => (
<IconButton
color={
@@ -332,7 +332,7 @@ export function Options({ thicknessRange, canvas }: OptionsProps) {
draft.antagonist.gun =
draft.antagonist.turret.guns.at(-1)!;
draft.antagonist.shell =
draft.antagonist.gun.gunType!.value.base.shells[0];
draft.antagonist.gun.gun_type!.value.base.shells[0];
});
setAntagonistSelectorOpen(false);
}}
@@ -38,7 +38,7 @@ export function Controls() {
antagonistModelDefinition.turrets[antagonist.turret.id];
const protagonistGunModelDefinition =
protagonistTurretModelDefinition.guns[
protagonist.gun.gunType!.value.base.id
protagonist.gun.gun_type!.value.base.id
];
const protagonistHullOrigin = new Vector3(
protagonistTrackModelDefinition.origin.x,
@@ -46,19 +46,19 @@ export function Controls() {
-protagonistTrackModelDefinition.origin.z,
);
const protagonistTurretOrigin = new Vector3(
protagonistModelDefinition.turretOrigin.x,
protagonistModelDefinition.turretOrigin.y,
-protagonistModelDefinition.turretOrigin.z,
protagonistModelDefinition.turret_origin.x,
protagonistModelDefinition.turret_origin.y,
-protagonistModelDefinition.turret_origin.z,
);
const protagonistGunOrigin = new Vector3(
protagonistTurretModelDefinition.gunOrigin.x,
protagonistTurretModelDefinition.gunOrigin.y,
-protagonistTurretModelDefinition.gunOrigin.z,
protagonistTurretModelDefinition.gun_origin.x,
protagonistTurretModelDefinition.gun_origin.y,
-protagonistTurretModelDefinition.gun_origin.z,
);
const antagonistGunHeight =
protagonistTrackModelDefinition.origin.y +
antagonistModelDefinition.turretOrigin.y +
antagonistTurretModelDefinition.gunOrigin.y;
antagonistModelDefinition.turret_origin.y +
antagonistTurretModelDefinition.gun_origin.y;
const [autoRotate, setAutoRotate] = useState(true);
useEffect(() => {
@@ -78,7 +78,7 @@ export function Controls() {
const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment(
122,
duel.protagonist.tank.equipmentPreset,
duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix,
);
@@ -29,7 +29,7 @@ export const TankModel = memo(() => {
const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id];
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 nodes = Object.values(gltf.nodes);
const isDynamicArmorActive = Duel.use((state) =>
@@ -136,7 +136,7 @@ export const TankModel = memo(() => {
const isTurret = node.name.startsWith('turret_');
const isCurrentTurret =
node.name ===
`turret_${turretModelDefinition.modelId.toString().padStart(2, '0')}`;
`turret_${turretModelDefinition.model_id.toString().padStart(2, '0')}`;
const isVisible = isCurrentTurret;
const position = new Vector2();
const delta = new Vector2();
@@ -169,7 +169,7 @@ export const TankModel = memo(() => {
const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment(
122,
duel.protagonist.tank.equipmentPreset,
duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix,
);
const boundingRect = canvas.getBoundingClientRect();
@@ -232,12 +232,12 @@ export const TankModel = memo(() => {
{nodes.map((node) => {
const isCurrentMantlet =
node.name ===
`gun_${gunModelDefinition.modelId
`gun_${gunModelDefinition.model_id
.toString()
.padStart(2, '0')}_mask`;
const isCurrentGun =
node.name ===
`gun_${gunModelDefinition.modelId.toString().padStart(2, '0')}`;
`gun_${gunModelDefinition.model_id.toString().padStart(2, '0')}`;
const isVisible = isCurrentGun || isCurrentMantlet;
const position = new Vector2();
const delta = new Vector2();
@@ -269,7 +269,7 @@ export const TankModel = memo(() => {
const duel = duelStore.getState();
const hasImprovedVerticalStabilizer = await hasEquipment(
122,
duel.protagonist.tank.equipmentPreset,
duel.protagonist.tank.equipment_preset,
duel.protagonist.equipmentMatrix,
);
const boundingRect = canvas.getBoundingClientRect();
@@ -45,7 +45,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
const turretModelDefinition =
tankModelDefinition.turrets[protagonist.turret.id];
const gunModelDefinition =
turretModelDefinition.guns[protagonist.gun.gunType!.value.base.id];
turretModelDefinition.guns[protagonist.gun.gun_type!.value.base.id];
const display = TankopediaPersistent.useDeferred(
(state) => state.display,
TankopediaDisplay.Model,
@@ -34,7 +34,7 @@ export function HeroSection() {
(filtered.reduce((accumulator, thisTank) => {
return (
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
);
}, 0) /
@@ -105,8 +105,8 @@ export function MetaSection() {
direction={{ initial: 'column', sm: 'row' }}
>
<Flex direction="column" width="100%">
{protagonist.nameFull && (
<Listing label="Full-name">{protagonist.nameFull}</Listing>
{protagonist.name_full && (
<Listing label="Full-name">{protagonist.name_full}</Listing>
)}
<Listing label="Nation">
<Flex align="center" gap="1">
@@ -199,11 +199,12 @@ export function MetaSection() {
/>
</Flex>
</Listing>
{protagonist.researchCost && (
{protagonist.research_cost && (
<Listing label="Research XP">
<Flex align="center" gap="1">
{(
protagonist.researchCost.researchCostType!.value as number
protagonist.research_cost.research_cost_type!
.value as number
).toLocaleString()}
<img
style={{ width: '1em', height: '1em' }}
@@ -22,15 +22,17 @@ export function Node({ id, highlight, nextIds }: NodeProps) {
const tank = tankDefinitions.tanks[id];
const nextTanks = nextIds?.map((id) => tankDefinitions.tanks[id]);
const thisTankXp =
tank.researchCost === undefined || tank.tier === 1
tank.research_cost === undefined || tank.tier === 1
? 0
: (tank.researchCost.researchCostType!.value as number)! / xpMultiplier;
: (tank.research_cost.research_cost_type!.value as number)! /
xpMultiplier;
const nextTanksXp = nextTanks?.reduce(
(xp, tank) =>
xp +
(tank.researchCost === undefined || tank.tier === 1
(tank.research_cost === undefined || tank.tier === 1
? 0
: (tank.researchCost.researchCostType!.value as number) / xpMultiplier),
: (tank.research_cost.research_cost_type!.value as number) /
xpMultiplier),
0,
);
const averages = averageDefinitions.averages[tank.id]?.mu;
@@ -53,10 +53,10 @@ export function TechTreeSection() {
const totalXp = line.reduce(
(xp, id) =>
xp +
(tankDefinitions.tanks[id].researchCost === undefined ||
(tankDefinitions.tanks[id].research_cost === undefined ||
tankDefinitions.tanks[id].tier === 1
? 0
: (tankDefinitions.tanks[id].researchCost.researchCostType!
: (tankDefinitions.tanks[id].research_cost.research_cost_type!
.value as number)),
0,
);