diff --git a/packages/bot/src/commands/ownedTanks.tsx b/packages/bot/src/commands/ownedTanks.tsx index fec0bcd4d..ba4b6e549 100644 --- a/packages/bot/src/commands/ownedTanks.tsx +++ b/packages/bot/src/commands/ownedTanks.tsx @@ -43,7 +43,7 @@ export const ownedTanksCommand = new Promise((resolve) => { tankStats.map(async (tankData) => ({ tankDefinitions: (await tankDefinitions).tanks[tankData.tank_id]!, id: tankData.tank_id, - })) + })), ) ).filter((tank) => tank.tankDefinitions?.tier === tier); const groupedTanks: Record = {}; @@ -69,16 +69,16 @@ export const ownedTanksCommand = new Promise((resolve) => { .filter((tank) => tank.tier === tier) .sort( (a, b) => - TANK_CLASSES.indexOf(a.class) - TANK_CLASSES.indexOf(b.class) + TANK_CLASSES.indexOf(a.class) - TANK_CLASSES.indexOf(b.class), ) .sort( (a, b) => awaitedGameDefinitions.nations.indexOf(a.nation) - - awaitedGameDefinitions.nations.indexOf(b.nation) + awaitedGameDefinitions.nations.indexOf(b.nation), ) .map( (tank) => - `[${flags[tank.nation]} ${markdownEscape(unwrap(tank.name))}]()` + `[${flags[tank.nation]} ${markdownEscape(unwrap(tank.name!))}]()`, ); const lines = [title, ...tankList]; diff --git a/packages/bot/src/commands/replay.tsx b/packages/bot/src/commands/replay.tsx index 364a8ef75..ed6da65fc 100644 --- a/packages/bot/src/commands/replay.tsx +++ b/packages/bot/src/commands/replay.tsx @@ -280,7 +280,7 @@ async function playerListing( }} > {unwrap(tank.name)} - {unwrap(tank.name)} + {unwrap(tank.name!)} diff --git a/packages/bot/src/commands/research.tsx b/packages/bot/src/commands/research.tsx index 7615f40b8..e0a987044 100644 --- a/packages/bot/src/commands/research.tsx +++ b/packages/bot/src/commands/research.tsx @@ -35,49 +35,49 @@ export const researchCommand = new Promise((resolve) => { command: createLocalizedCommand("research") .addStringOption((option) => option - .setName(strings.bot.commands.research.options.target_tank.name) + .setName(strings.bot.commands.research.options.target_tank.name!) .setNameLocalizations( localizationObject( (strings) => strings.bot.commands.research.options.target_tank.name, undefined, - true - ) + true, + ), ) .setDescription( - strings.bot.commands.research.options.target_tank.description + strings.bot.commands.research.options.target_tank.description, ) .setDescriptionLocalizations( localizationObject( (strings) => - strings.bot.commands.research.options.target_tank.description - ) + strings.bot.commands.research.options.target_tank.description, + ), ) .setAutocomplete(true) - .setRequired(true) + .setRequired(true), ) .addStringOption((option) => option - .setName(strings.bot.commands.research.options.starting_tank.name) + .setName(strings.bot.commands.research.options.starting_tank.name!) .setNameLocalizations( localizationObject( (strings) => strings.bot.commands.research.options.starting_tank.name, undefined, - true - ) + true, + ), ) .setDescription( - strings.bot.commands.research.options.starting_tank.description + strings.bot.commands.research.options.starting_tank.description, ) .setDescriptionLocalizations( localizationObject( (strings) => - strings.bot.commands.research.options.starting_tank.description - ) + strings.bot.commands.research.options.starting_tank.description, + ), ) .setAutocomplete(true) - .setRequired(false) + .setRequired(false), ) .addStringOption(addUsernameChoices), @@ -87,7 +87,7 @@ export const researchCommand = new Promise((resolve) => { const targetTankId = await resolveTankId( interaction.options.getString("target-tank", true), interaction.locale, - true + true, ); const startingTankRaw = interaction.options.getString("starting-tank"); const targetTank = awaitedTankDefinitions.tanks[targetTankId]; @@ -99,13 +99,13 @@ export const researchCommand = new Promise((resolve) => { startingTankId = await resolveTankId( startingTankRaw, interaction.locale, - true + true, ); if (targetTankId === startingTankId) { return literals( strings.bot.commands.research.errors.start_end_equal, - { tank: escapeMarkdown(unwrap(targetTank.name)) } + { tank: escapeMarkdown(unwrap(targettank.name!)) }, ); } @@ -113,8 +113,8 @@ export const researchCommand = new Promise((resolve) => { if (startingTank.tier > targetTank.tier) { return literals(strings.bot.commands.research.errors.unordered, { - tank_1: escapeMarkdown(unwrap(startingTank.name)), - tank_2: escapeMarkdown(unwrap(targetTank.name)), + tank_1: escapeMarkdown(unwrap(startingtank.name!)), + tank_2: escapeMarkdown(unwrap(targettank.name!)), }); } @@ -122,21 +122,21 @@ export const researchCommand = new Promise((resolve) => { return literals( strings.bot.commands.research.errors.tanks_not_on_line, { - tank_1: escapeMarkdown(unwrap(targetTank.name)), - tank_2: escapeMarkdown(unwrap(startingTank.name)), - } + tank_1: escapeMarkdown(unwrap(targettank.name!)), + tank_2: escapeMarkdown(unwrap(startingtank.name!)), + }, ); } } else { - if (targetTank.type !== TankType.RESEARCHABLE) { + if (targetTank.type !== TankType.TANK_TYPE_RESEARCHABLE) { return literals(strings.bot.commands.research.errors.non_tech_tree, { - tank: escapeMarkdown(unwrap(targetTank.name)), + tank: escapeMarkdown(unwrap(targettank.name!)), }); } if (targetTank.tier === 1) { return literals(strings.bot.commands.research.errors.tier_1, { - tank: escapeMarkdown(unwrap(targetTank.name)), + tank: escapeMarkdown(unwrap(targettank.name!)), }); } @@ -149,14 +149,14 @@ export const researchCommand = new Promise((resolve) => { if (tankStats.some(({ tank_id }) => tank_id === targetTankId)) { return literals( strings.bot.commands.research.errors.already_researched, - { tank: escapeMarkdown(unwrap(targetTank.name)) } + { tank: escapeMarkdown(unwrap(targettank.name!)) }, ); } const foundAncestor = targetTankAncestry.find( (id) => awaitedTankDefinitions.tanks[id].tier === 1 || - tankStats.some(({ tank_id }) => tank_id === id) + tankStats.some(({ tank_id }) => tank_id === id), ); if (foundAncestor === undefined) { @@ -168,7 +168,7 @@ export const researchCommand = new Promise((resolve) => { const techTreeLine = await buildTechTreeLine( startingTankId, - targetTankId + targetTankId, ); const line = [...techTreeLine, startingTankId].reverse(); @@ -190,7 +190,7 @@ export const researchCommand = new Promise((resolve) => { ) { turretXps.set( turret.id, - turret.research_cost.research_cost_type!.value + turret.research_cost.research_cost_type!.value, ); } @@ -211,7 +211,7 @@ export const researchCommand = new Promise((resolve) => { ) { engineXps.set( engine.id, - engine.research_cost.research_cost_type!.value + engine.research_cost.research_cost_type!.value, ); } }); @@ -223,7 +223,7 @@ export const researchCommand = new Promise((resolve) => { ) { trackXps.set( track.id, - track.research_cost.research_cost_type!.value + track.research_cost.research_cost_type!.value, ); } }); @@ -245,13 +245,13 @@ export const researchCommand = new Promise((resolve) => { return { research: tank.research_cost!.research_cost_type!.value as number, upgrades: moduleXp, - purchase: tank.price.value, + purchase: tank.price!.value, equipment: equipmentPriceMatrix[tank.tier].reduce( (a, b) => a + 3 * b, - 0 + 0, ), }; - }) + }), ); const image = ( @@ -456,7 +456,7 @@ export const researchCommand = new Promise((resolve) => { }} > {unwrap(tank.name)}((resolve) => { color: theme.colors.textHighContrast, }} > - {unwrap(tank.name)} + {unwrap(tank.name!)} @@ -505,9 +505,9 @@ export const researchCommand = new Promise((resolve) => { strings.bot.commands.research.body.research, { cost: costs[index].research?.toLocaleString( - interaction.locale + interaction.locale, ), - } + }, )} @@ -523,7 +523,7 @@ export const researchCommand = new Promise((resolve) => { Free XP icon((resolve) => { > {literals( strings.bot.commands.research.body.upgrades, - { cost: costs[index].upgrades.toLocaleString() } + { cost: costs[index].upgrades.toLocaleString() }, )} @@ -552,7 +552,7 @@ export const researchCommand = new Promise((resolve) => { Silver icon((resolve) => { strings.bot.commands.research.body.purchase, { cost: costs[index].purchase.toLocaleString( - interaction.locale + interaction.locale, ), - } + }, )} @@ -584,7 +584,7 @@ export const researchCommand = new Promise((resolve) => { Silver icon((resolve) => { strings.bot.commands.research.body.equipment, { cost: costs[index].equipment.toLocaleString( - interaction.locale + interaction.locale, ), - } + }, )} ); - }) + }), )} diff --git a/packages/bot/src/components/Breakdown/components/Row.tsx b/packages/bot/src/components/Breakdown/components/Row.tsx index 7ede9b5e5..a5af946d6 100644 --- a/packages/bot/src/components/Breakdown/components/Row.tsx +++ b/packages/bot/src/components/Breakdown/components/Row.tsx @@ -3,14 +3,14 @@ import { TankClass, TankType, TREE_TYPE_ICONS, -} from '@blitzkit/core'; -import { createColors } from 'bepaint'; +} from "@blitzkit/core"; +import { createColors } from "bepaint"; import { type AccentColor, type GrayColor, PALETTES, -} from '../../../core/radix/radixColors'; -import { RowStat } from './RowStat'; +} from "../../../core/radix/radixColors"; +import { RowStat } from "./RowStat"; export interface RowStatItem { title: string; @@ -21,7 +21,7 @@ export interface RowStatItem { } interface RowProps { - displayType?: 'tank' | 'summary'; + displayType?: "tank" | "summary"; naked?: boolean; title: string; minimized?: boolean; @@ -32,7 +32,7 @@ interface RowProps { } export function Row({ - color = 'slate', + color = "slate", stats, title, minimized, @@ -49,20 +49,20 @@ export function Row({ className="session-tracker-row" style={{ maxWidth: naked ? 600 : Infinity, - display: 'flex', - flexDirection: 'column', + display: "flex", + flexDirection: "column", borderRadius: 4, backgroundColor: naked ? `${theme.appBackground2}c0` : theme.appBackground2, - overflow: 'hidden', + overflow: "hidden", }} >
- {displayType === 'tank' && tankClass !== undefined && ( + {displayType === "tank" && tankClass !== undefined && ( {TankClass[tankClass]} )} @@ -81,10 +85,10 @@ export function Row({ diff --git a/packages/bot/src/components/Tanks/components/Item/index.tsx b/packages/bot/src/components/Tanks/components/Item/index.tsx index 5f39f8f1f..f33342c3a 100644 --- a/packages/bot/src/components/Tanks/components/Item/index.tsx +++ b/packages/bot/src/components/Tanks/components/Item/index.tsx @@ -1,5 +1,5 @@ -import { TankClass, TankType, TREE_TYPE_ICONS } from '@blitzkit/core'; -import { theme } from '../../../../stitches.config'; +import { TankClass, TankType, TREE_TYPE_ICONS } from "@blitzkit/core"; +import { theme } from "../../../../stitches.config"; export interface ItemProps { tankClass?: TankClass; @@ -8,9 +8,9 @@ export interface ItemProps { } const TREE_TYPE_COLOR = { - [TankType.RESEARCHABLE]: '', - [TankType.PREMIUM]: '_amber', - [TankType.COLLECTOR]: '_blue', + [TankType.TANK_TYPE_RESEARCHABLE]: "", + [TankType.TANK_TYPE_PREMIUM]: "_amber", + [TankType.TANK_TYPE_COLLECTOR]: "_blue", } as const; export function Item({ @@ -21,12 +21,12 @@ export function Item({ return (
{tankType && ( @@ -52,7 +52,7 @@ export function Item({ diff --git a/packages/bot/src/core/blitzkit/filtersToDescription.ts b/packages/bot/src/core/blitzkit/filtersToDescription.ts index e4a19a3c1..a8c8377cd 100644 --- a/packages/bot/src/core/blitzkit/filtersToDescription.ts +++ b/packages/bot/src/core/blitzkit/filtersToDescription.ts @@ -6,21 +6,21 @@ import { translator } from "../localization/translator"; export async function filtersToDescription( { nation, tier, type, class: tankClass, tank }: StatFilters, - locale: Locale + locale: Locale, ) { const { strings, bkLocale } = translator(locale); const awaitedTankDefinitions = await fetchTankDefinitions(); const info: string[] = []; // TODO: somehow localize tank names? - if (tank) return awaitedTankDefinitions.tanks[tank].name.locales[bkLocale]; + if (tank) return awaitedTankDefinitions.tanks[tank].name!.locales[bkLocale]; if (nation) info.push((strings.common.nations as Record)[nation]); if (tier) { info.push( literals(strings.bot.common.filters.tier, { tier: TIER_ROMAN_NUMERALS[tier], - }) + }), ); } if (tankClass) info.push(strings.common.tank_class_short[tankClass]); diff --git a/packages/bot/src/core/blitzstars/filterStats.ts b/packages/bot/src/core/blitzstars/filterStats.ts index 9f936d87d..2936170a9 100644 --- a/packages/bot/src/core/blitzstars/filterStats.ts +++ b/packages/bot/src/core/blitzstars/filterStats.ts @@ -34,12 +34,12 @@ export async function filterStats( (filters.tier === undefined || entry.tier === filters.tier) && (filters.class === undefined || entry.class === filters.class) && (filters.type === undefined || - (filters.type === TankType.COLLECTOR && - entry.type === TankType.COLLECTOR) || - (filters.type === TankType.PREMIUM && - entry.type === TankType.PREMIUM) || - (filters.type === TankType.RESEARCHABLE && - entry.type === TankType.RESEARCHABLE)) && + (filters.type === TankType.TANK_TYPE_COLLECTOR && + entry.type === TankType.TANK_TYPE_COLLECTOR) || + (filters.type === TankType.TANK_TYPE_PREMIUM && + entry.type === TankType.TANK_TYPE_PREMIUM) || + (filters.type === TankType.TANK_TYPE_RESEARCHABLE && + entry.type === TankType.TANK_TYPE_RESEARCHABLE)) && (filters.tank === undefined || entry.id === filters.tank) ); }); diff --git a/packages/bot/src/core/discord/addTankChoices.ts b/packages/bot/src/core/discord/addTankChoices.ts index 0cfafc6f8..3b38e220b 100644 --- a/packages/bot/src/core/discord/addTankChoices.ts +++ b/packages/bot/src/core/discord/addTankChoices.ts @@ -1,12 +1,12 @@ -import { Locale, SlashCommandStringOption } from 'discord.js'; -import { translator } from '../localization/translator'; -import { localizationObject } from './localizationObject'; +import { Locale, SlashCommandStringOption } from "discord.js"; +import { translator } from "../localization/translator"; +import { localizationObject } from "./localizationObject"; export function addTankChoices(option: SlashCommandStringOption) { const { strings } = translator(Locale.EnglishUS); return option - .setName(strings.bot.common.options.tank.name) + .setName(strings.bot.common.options.tank.name!) .setNameLocalizations( localizationObject( (strings) => strings.bot.common.options.tank.name, diff --git a/packages/bot/src/core/discord/autocompleteTanks.ts b/packages/bot/src/core/discord/autocompleteTanks.ts index 8b55952ac..e43c975fb 100644 --- a/packages/bot/src/core/discord/autocompleteTanks.ts +++ b/packages/bot/src/core/discord/autocompleteTanks.ts @@ -13,13 +13,13 @@ import { } from "./autocompleteClan/constants"; export const tankNamesTechTreeOnly = fetchTankNames().then((names) => - names.filter((tank) => tank.treeType === TankType.RESEARCHABLE) + names.filter((tank) => tank.treeType === TankType.TANK_TYPE_RESEARCHABLE), ); export async function autocompleteTanks( interaction: AutocompleteInteraction, techTreeOnly = false, - fields = ["tank"] + fields = ["tank"], ) { const { unwrap } = translator(interaction.locale); const focusedOption = interaction.options.getFocused(true); @@ -31,7 +31,7 @@ export async function autocompleteTanks( go( focusedOption.value, await (techTreeOnly ? tankNamesTechTreeOnly : tankNames), - { keys: SEARCH_KEYS, limit: 10 } + { keys: SEARCH_KEYS, limit: 10 }, ).map(async (item) => { let name = unwrap(item.obj.searchableName); @@ -42,7 +42,7 @@ export async function autocompleteTanks( 0, unwrap(item.obj.searchableName).length - overSize - - OVERFLOW_SUFFIX.length + OVERFLOW_SUFFIX.length, )}${OVERFLOW_SUFFIX}`; } @@ -50,8 +50,8 @@ export async function autocompleteTanks( name, value: `${item.obj.id}`, } satisfies ApplicationCommandOptionChoiceData; - }) + }), ) - : [] + : [], ); } diff --git a/packages/core/src/blitz/canSplash.ts b/packages/core/src/blitz/canSplash.ts index 61746feb1..c6151665b 100644 --- a/packages/core/src/blitz/canSplash.ts +++ b/packages/core/src/blitz/canSplash.ts @@ -1,5 +1,7 @@ import { ShellDefinition, ShellType } from "../protos"; -export function canSplash(type: ShellDefinition["type"]): type is ShellType.HE { - return type === ShellType.HE; +export function canSplash( + type: ShellDefinition["type"], +): type is ShellType.SHELL_TYPE_HE { + return type === ShellType.SHELL_TYPE_HE; } diff --git a/packages/core/src/blitz/constants.ts b/packages/core/src/blitz/constants.ts index d118c557a..64ec733be 100644 --- a/packages/core/src/blitz/constants.ts +++ b/packages/core/src/blitz/constants.ts @@ -2,22 +2,22 @@ import { TankClass, TankType } from "../protos"; import type { BlitzStats } from "../statistics"; export const TANK_TYPES = [ - TankType.RESEARCHABLE, - TankType.PREMIUM, - TankType.COLLECTOR, + TankType.TANK_TYPE_RESEARCHABLE, + TankType.TANK_TYPE_PREMIUM, + TankType.TANK_TYPE_COLLECTOR, ]; export const TANK_TYPE_COMMAND_NAMES = { - [TankType.RESEARCHABLE]: "researchable", - [TankType.PREMIUM]: "premium", - [TankType.COLLECTOR]: "collector", + [TankType.TANK_TYPE_RESEARCHABLE]: "researchable", + [TankType.TANK_TYPE_PREMIUM]: "premium", + [TankType.TANK_TYPE_COLLECTOR]: "collector", }; export const TANK_CLASSES = [ - TankClass.LIGHT, - TankClass.MEDIUM, - TankClass.HEAVY, - TankClass.TANK_DESTROYER, + TankClass.TANK_CLASS_LIGHT, + TankClass.TANK_CLASS_MEDIUM, + TankClass.TANK_CLASS_HEAVY, + TankClass.TANK_CLASS_TANK_DESTROYER, ]; export const emptyAllStats: BlitzStats = { diff --git a/packages/core/src/blitzkit/checkConsumableProvisionInclusivity.ts b/packages/core/src/blitzkit/checkConsumableProvisionInclusivity.ts index ad1a90ac8..7b942ba94 100644 --- a/packages/core/src/blitzkit/checkConsumableProvisionInclusivity.ts +++ b/packages/core/src/blitzkit/checkConsumableProvisionInclusivity.ts @@ -9,7 +9,7 @@ import { export function checkConsumableProvisionInclusivity( consumableProvision: Consumable | Provision, tank: TankDefinition, - gun: GunDefinition + gun: GunDefinition, ) { const included = consumableProvision.include?.every((rule) => { switch (rule.filter_type!.$case) { @@ -46,7 +46,7 @@ export function checkConsumableProvisionInclusivity( case "categories": return rule.filter_type!.value.categories.some((category) => { switch (category) { - case ConsumableTankCategoryFilterCategory.CLIP: + case ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP: return gun.gun_type!.$case !== "regular"; } }); diff --git a/packages/core/src/blitzkit/isExplosive.ts b/packages/core/src/blitzkit/isExplosive.ts index 8bafa89bf..aae220abe 100644 --- a/packages/core/src/blitzkit/isExplosive.ts +++ b/packages/core/src/blitzkit/isExplosive.ts @@ -1,7 +1,7 @@ import { ShellDefinition, ShellType } from "../protos"; export function isExplosive( - type: ShellDefinition["type"] -): type is ShellType.HEAT | ShellType.HE { - return type === ShellType.HEAT || type === ShellType.HE; + type: ShellDefinition["type"], +): type is ShellType.SHELL_TYPE_HEAT | ShellType.SHELL_TYPE_HE { + return type === ShellType.SHELL_TYPE_HEAT || type === ShellType.SHELL_TYPE_HE; } diff --git a/packages/core/src/blitzkit/metaSortTank.ts b/packages/core/src/blitzkit/metaSortTank.ts index 2ab0f491f..f146915b1 100644 --- a/packages/core/src/blitzkit/metaSortTank.ts +++ b/packages/core/src/blitzkit/metaSortTank.ts @@ -2,27 +2,27 @@ import { TANK_CLASSES } from "../blitz/constants"; import { GameDefinitions, TankDefinition, TankType } from "../protos"; const treeTypeOrder = [ - TankType.RESEARCHABLE, - TankType.PREMIUM, - TankType.COLLECTOR, + TankType.TANK_TYPE_RESEARCHABLE, + TankType.TANK_TYPE_PREMIUM, + TankType.TANK_TYPE_COLLECTOR, ]; export function metaSortTank( tanks: TankDefinition[], - gameDefinitions: GameDefinitions + gameDefinitions: GameDefinitions, ) { return tanks .sort((a, b) => b.tier - a.tier) .sort( - (a, b) => treeTypeOrder.indexOf(b.type) - treeTypeOrder.indexOf(a.type) + (a, b) => treeTypeOrder.indexOf(b.type) - treeTypeOrder.indexOf(a.type), ) .sort( - (a, b) => TANK_CLASSES.indexOf(b.class) - TANK_CLASSES.indexOf(a.class) + (a, b) => TANK_CLASSES.indexOf(b.class) - TANK_CLASSES.indexOf(a.class), ) .sort( (a, b) => gameDefinitions.nations.indexOf(b.nation) - - gameDefinitions.nations.indexOf(a.nation) + gameDefinitions.nations.indexOf(a.nation), ) .sort((a, b) => a.tier - b.tier); } diff --git a/packages/core/src/blitzkit/normalizeBoundingBox.ts b/packages/core/src/blitzkit/normalizeBoundingBox.ts index 90c5ca673..8e95ccd55 100644 --- a/packages/core/src/blitzkit/normalizeBoundingBox.ts +++ b/packages/core/src/blitzkit/normalizeBoundingBox.ts @@ -2,8 +2,8 @@ import { BoundingBox, Vector3 } from "../protos"; export function normalizeBoundingBox(boundingBox: BoundingBox) { return { - x: boundingBox.max.x - boundingBox.min.x, - y: boundingBox.max.y - boundingBox.min.y, - z: boundingBox.max.z - boundingBox.min.z, + x: boundingBox.max!.x - boundingBox.min!.x, + y: boundingBox.max!.y - boundingBox.min!.y, + z: boundingBox.max!.z - boundingBox.min!.z, } satisfies Vector3; } diff --git a/packages/core/src/blitzkit/resolvePenetrationCoefficient.ts b/packages/core/src/blitzkit/resolvePenetrationCoefficient.ts index 1cd746e5f..9b1b5d474 100644 --- a/packages/core/src/blitzkit/resolvePenetrationCoefficient.ts +++ b/packages/core/src/blitzkit/resolvePenetrationCoefficient.ts @@ -1,4 +1,4 @@ -import { ShellType } from '../protos'; +import { ShellType } from "../protos"; export function resolvePenetrationCoefficient( calibratedShells: boolean, @@ -6,11 +6,11 @@ export function resolvePenetrationCoefficient( ) { if (!calibratedShells) return 1; - return type === ShellType.AP + return type === ShellType.SHELL_TYPE_AP ? 1.08 - : type === ShellType.APCR + : type === ShellType.SHELL_TYPE_APCR ? 1.05 - : type === ShellType.HEAT + : type === ShellType.SHELL_TYPE_HEAT ? 1.13 : 1.08; } diff --git a/packages/core/src/blitzkit/tankDefinitions/constants.ts b/packages/core/src/blitzkit/tankDefinitions/constants.ts index d2d70b602..5224cdae7 100644 --- a/packages/core/src/blitzkit/tankDefinitions/constants.ts +++ b/packages/core/src/blitzkit/tankDefinitions/constants.ts @@ -1,74 +1,74 @@ -import { times } from 'lodash-es'; -import { CrewType, ShellType, TankClass, TankType } from '../../protos'; +import { times } from "lodash-es"; +import { CrewType, ShellType, TankClass, TankType } from "../../protos"; export const SHELL_NAMES: Record = { - [ShellType.AP]: 'AP', - [ShellType.APCR]: 'APCR', - [ShellType.HEAT]: 'HEAT', - [ShellType.HE]: 'HE', + [ShellType.SHELL_TYPE_AP]: "AP", + [ShellType.SHELL_TYPE_APCR]: "APCR", + [ShellType.SHELL_TYPE_HEAT]: "HEAT", + [ShellType.SHELL_TYPE_HE]: "HE", }; export const CREW_MEMBER_NAMES = { - [CrewType.COMMANDER]: 'commander', - [CrewType.DRIVER]: 'driver', - [CrewType.GUNNER]: 'gunner', - [CrewType.LOADER]: 'loader', - [CrewType.RADIOMAN]: 'radioman', + [CrewType.CREW_TYPE_COMMANDER]: "commander", + [CrewType.CREW_TYPE_DRIVER]: "driver", + [CrewType.CREW_TYPE_GUNNER]: "gunner", + [CrewType.CREW_TYPE_LOADER]: "loader", + [CrewType.CREW_TYPE_RADIOMAN]: "radioman", } as const; /** * @deprecated use svg */ export const TANK_ICONS: Record = { - [TankClass.TANK_DESTROYER]: 'https://i.imgur.com/BIHSEH0.png', - [TankClass.LIGHT]: 'https://i.imgur.com/CSNha5V.png', - [TankClass.MEDIUM]: 'https://i.imgur.com/wvf3ltm.png', - [TankClass.HEAVY]: 'https://i.imgur.com/ECeqlZa.png', + [TankClass.TANK_CLASS_TANK_DESTROYER]: "https://i.imgur.com/BIHSEH0.png", + [TankClass.TANK_CLASS_LIGHT]: "https://i.imgur.com/CSNha5V.png", + [TankClass.TANK_CLASS_MEDIUM]: "https://i.imgur.com/wvf3ltm.png", + [TankClass.TANK_CLASS_HEAVY]: "https://i.imgur.com/ECeqlZa.png", }; /** * @deprecated use svg */ export const TANK_ICONS_PREMIUM: Record = { - [TankClass.TANK_DESTROYER]: 'https://i.imgur.com/TCu3EdR.png', - [TankClass.LIGHT]: 'https://i.imgur.com/zdkpTRb.png', - [TankClass.MEDIUM]: 'https://i.imgur.com/3z7eHX6.png', - [TankClass.HEAVY]: 'https://i.imgur.com/P3vbmyA.png', + [TankClass.TANK_CLASS_TANK_DESTROYER]: "https://i.imgur.com/TCu3EdR.png", + [TankClass.TANK_CLASS_LIGHT]: "https://i.imgur.com/zdkpTRb.png", + [TankClass.TANK_CLASS_MEDIUM]: "https://i.imgur.com/3z7eHX6.png", + [TankClass.TANK_CLASS_HEAVY]: "https://i.imgur.com/P3vbmyA.png", }; /** * @deprecated use svg */ export const TANK_ICONS_COLLECTOR: Record = { - [TankClass.TANK_DESTROYER]: 'https://i.imgur.com/WTjeirB.png', - [TankClass.LIGHT]: 'https://i.imgur.com/EwhtKkU.png', - [TankClass.MEDIUM]: 'https://i.imgur.com/u8YDMBh.png', - [TankClass.HEAVY]: 'https://i.imgur.com/8xRf3nc.png', + [TankClass.TANK_CLASS_TANK_DESTROYER]: "https://i.imgur.com/WTjeirB.png", + [TankClass.TANK_CLASS_LIGHT]: "https://i.imgur.com/EwhtKkU.png", + [TankClass.TANK_CLASS_MEDIUM]: "https://i.imgur.com/u8YDMBh.png", + [TankClass.TANK_CLASS_HEAVY]: "https://i.imgur.com/8xRf3nc.png", }; export const TIERS = times(10, (index) => index + 1); export const TIER_ROMAN_NUMERALS: Record = { - 1: 'I', - 2: 'II', - 3: 'III', - 4: 'IV', - 5: 'V', - 6: 'VI', - 7: 'VII', - 8: 'VIII', - 9: 'IX', - 10: 'X', + 1: "I", + 2: "II", + 3: "III", + 4: "IV", + 5: "V", + 6: "VI", + 7: "VII", + 8: "VIII", + 9: "IX", + 10: "X", }; export const flags: Record = { - ussr: '<:ussr:1218421042033197197>', - germany: 'πŸ‡©πŸ‡ͺ', - usa: 'πŸ‡ΊπŸ‡Έ', - china: 'πŸ‡¨πŸ‡³', - uk: 'πŸ‡¬πŸ‡§', - france: 'πŸ‡«πŸ‡·', - japan: 'πŸ‡―πŸ‡΅', - european: 'πŸ‡ͺπŸ‡Ί', - other: '<:other:1218421572243558482>', + ussr: "<:ussr:1218421042033197197>", + germany: "πŸ‡©πŸ‡ͺ", + usa: "πŸ‡ΊπŸ‡Έ", + china: "πŸ‡¨πŸ‡³", + uk: "πŸ‡¬πŸ‡§", + france: "πŸ‡«πŸ‡·", + japan: "πŸ‡―πŸ‡΅", + european: "πŸ‡ͺπŸ‡Ί", + other: "<:other:1218421572243558482>", }; export const TREE_TYPE_ICONS: Record> = { - [TankType.RESEARCHABLE]: TANK_ICONS, - [TankType.PREMIUM]: TANK_ICONS_PREMIUM, - [TankType.COLLECTOR]: TANK_ICONS_COLLECTOR, + [TankType.TANK_TYPE_RESEARCHABLE]: TANK_ICONS, + [TankType.TANK_TYPE_PREMIUM]: TANK_ICONS_PREMIUM, + [TankType.TANK_TYPE_COLLECTOR]: TANK_ICONS_COLLECTOR, }; diff --git a/packages/core/src/blitzkit/tankNames.ts b/packages/core/src/blitzkit/tankNames.ts index 57018ee21..d778ed33e 100644 --- a/packages/core/src/blitzkit/tankNames.ts +++ b/packages/core/src/blitzkit/tankNames.ts @@ -15,7 +15,7 @@ export async function fetchTankNames() { tankDefinitionsArray.map(async (tank) => { const searchableNameDeburr: I18nString = { locales: {} }; - Object.entries(tank.name).forEach(([key, value]) => { + Object.entries(tank.name!).forEach(([key, value]) => { searchableNameDeburr.locales[key] = deburr(value); }); @@ -28,8 +28,8 @@ export async function fetchTankNames() { ?.map((id) => locales.supported.map( ({ locale }) => - camouflageDefinitions.camouflages[id]?.name.locales[locale] - ) + camouflageDefinitions.camouflages[id]?.name!.locales[locale], + ), ) .flat() .filter(Boolean) @@ -37,7 +37,7 @@ export async function fetchTankNames() { .join(" "), treeType: tank.type, }; - }) + }), ); } diff --git a/packages/core/src/blitzkit/unionBoundingBox.ts b/packages/core/src/blitzkit/unionBoundingBox.ts index 29964b34a..63abaef21 100644 --- a/packages/core/src/blitzkit/unionBoundingBox.ts +++ b/packages/core/src/blitzkit/unionBoundingBox.ts @@ -3,14 +3,14 @@ import { BoundingBox } from "../protos"; export function unionBoundingBox(a: BoundingBox, b: BoundingBox) { return { min: { - x: Math.min(a.min.x, b.min.x), - y: Math.min(a.min.y, b.min.y), - z: Math.min(a.min.z, b.min.z), + x: Math.min(a.min!.x, b.min!.x), + y: Math.min(a.min!.y, b.min!.y), + z: Math.min(a.min!.z, b.min!.z), }, max: { - x: Math.max(a.max.x, b.max.x), - y: Math.max(a.max.y, b.max.y), - z: Math.max(a.max.z, b.max.z), + x: Math.max(a.max!.x, b.max!.x), + y: Math.max(a.max!.y, b.max!.y), + z: Math.max(a.max!.z, b.max!.z), }, } satisfies BoundingBox; } diff --git a/packages/core/src/protos/model_definitions.ts b/packages/core/src/protos/model_definitions.ts index 7fdd45a7a..b353ae4c3 100644 --- a/packages/core/src/protos/model_definitions.ts +++ b/packages/core/src/protos/model_definitions.ts @@ -115,15 +115,24 @@ function createBaseModelDefinitions(): ModelDefinitions { } export const ModelDefinitions: MessageFns = { - encode(message: ModelDefinitions, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - globalThis.Object.entries(message.models).forEach(([key, value]: [string, ModelDefinition]) => { - ModelDefinitions_ModelsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join(); - }); + encode( + message: ModelDefinitions, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + globalThis.Object.entries(message.models).forEach( + ([key, value]: [string, ModelDefinition]) => { + ModelDefinitions_ModelsEntry.encode( + { key: key as any, value }, + writer.uint32(10).fork(), + ).join(); + }, + ); return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ModelDefinitions { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseModelDefinitions(); while (reader.pos < end) { @@ -134,7 +143,10 @@ export const ModelDefinitions: MessageFns = { break; } - const entry1 = ModelDefinitions_ModelsEntry.decode(reader, reader.uint32()); + const entry1 = ModelDefinitions_ModelsEntry.decode( + reader, + reader.uint32(), + ); if (entry1.value !== undefined) { message.models[entry1.key] = entry1.value; } @@ -153,12 +165,15 @@ export const ModelDefinitions: MessageFns = { return { models: isObject(object.models) ? (globalThis.Object.entries(object.models) as [string, any][]).reduce( - (acc: { [key: number]: ModelDefinition }, [key, value]: [string, any]) => { - acc[globalThis.Number(key)] = ModelDefinition.fromJSON(value); - return acc; - }, - {}, - ) + ( + acc: { [key: number]: ModelDefinition }, + [key, value]: [string, any], + ) => { + acc[globalThis.Number(key)] = ModelDefinition.fromJSON(value); + return acc; + }, + {}, + ) : {}, }; }, @@ -166,7 +181,10 @@ export const ModelDefinitions: MessageFns = { toJSON(message: ModelDefinitions): unknown { const obj: any = {}; if (message.models) { - const entries = globalThis.Object.entries(message.models) as [string, ModelDefinition][]; + const entries = globalThis.Object.entries(message.models) as [ + string, + ModelDefinition, + ][]; if (entries.length > 0) { obj.models = {}; entries.forEach(([k, v]) => { @@ -177,13 +195,25 @@ export const ModelDefinitions: MessageFns = { return obj; }, - create, I>>(base?: I): ModelDefinitions { + create, I>>( + base?: I, + ): ModelDefinitions { return ModelDefinitions.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): ModelDefinitions { + fromPartial, I>>( + object: I, + ): ModelDefinitions { const message = createBaseModelDefinitions(); - message.models = (globalThis.Object.entries(object.models ?? {}) as [string, ModelDefinition][]).reduce( - (acc: { [key: number]: ModelDefinition }, [key, value]: [string, ModelDefinition]) => { + message.models = ( + globalThis.Object.entries(object.models ?? {}) as [ + string, + ModelDefinition, + ][] + ).reduce( + ( + acc: { [key: number]: ModelDefinition }, + [key, value]: [string, ModelDefinition], + ) => { if (value !== undefined) { acc[globalThis.Number(key)] = ModelDefinition.fromPartial(value); } @@ -199,79 +229,94 @@ function createBaseModelDefinitions_ModelsEntry(): ModelDefinitions_ModelsEntry return { key: 0, value: undefined }; } -export const ModelDefinitions_ModelsEntry: MessageFns = { - encode(message: ModelDefinitions_ModelsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.key !== 0) { - writer.uint32(8).uint32(message.key); - } - if (message.value !== undefined) { - ModelDefinition.encode(message.value, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): ModelDefinitions_ModelsEntry { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - const end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseModelDefinitions_ModelsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - if (tag !== 8) { - break; - } - - message.key = reader.uint32(); - continue; - } - case 2: { - if (tag !== 18) { - break; - } - - message.value = ModelDefinition.decode(reader, reader.uint32()); - continue; - } +export const ModelDefinitions_ModelsEntry: MessageFns = + { + encode( + message: ModelDefinitions_ModelsEntry, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.key !== 0) { + writer.uint32(8).uint32(message.key); } - if ((tag & 7) === 4 || tag === 0) { - break; + if (message.value !== undefined) { + ModelDefinition.encode(message.value, writer.uint32(18).fork()).join(); } - reader.skip(tag & 7); - } - return message; - }, + return writer; + }, - fromJSON(object: any): ModelDefinitions_ModelsEntry { - return { - key: isSet(object.key) ? globalThis.Number(object.key) : 0, - value: isSet(object.value) ? ModelDefinition.fromJSON(object.value) : undefined, - }; - }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): ModelDefinitions_ModelsEntry { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModelDefinitions_ModelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break; + } - toJSON(message: ModelDefinitions_ModelsEntry): unknown { - const obj: any = {}; - if (message.key !== 0) { - obj.key = Math.round(message.key); - } - if (message.value !== undefined) { - obj.value = ModelDefinition.toJSON(message.value); - } - return obj; - }, + message.key = reader.uint32(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } - create, I>>(base?: I): ModelDefinitions_ModelsEntry { - return ModelDefinitions_ModelsEntry.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): ModelDefinitions_ModelsEntry { - const message = createBaseModelDefinitions_ModelsEntry(); - message.key = object.key ?? 0; - message.value = (object.value !== undefined && object.value !== null) - ? ModelDefinition.fromPartial(object.value) - : undefined; - return message; - }, -}; + message.value = ModelDefinition.decode(reader, reader.uint32()); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ModelDefinitions_ModelsEntry { + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) + ? ModelDefinition.fromJSON(object.value) + : undefined, + }; + }, + + toJSON(message: ModelDefinitions_ModelsEntry): unknown { + const obj: any = {}; + if (message.key !== 0) { + obj.key = Math.round(message.key); + } + if (message.value !== undefined) { + obj.value = ModelDefinition.toJSON(message.value); + } + return obj; + }, + + create, I>>( + base?: I, + ): ModelDefinitions_ModelsEntry { + return ModelDefinitions_ModelsEntry.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): ModelDefinitions_ModelsEntry { + const message = createBaseModelDefinitions_ModelsEntry(); + message.key = object.key ?? 0; + message.value = + object.value !== undefined && object.value !== null + ? ModelDefinition.fromPartial(object.value) + : undefined; + return message; + }, + }; function createBaseModelDefinition(): ModelDefinition { return { @@ -285,7 +330,10 @@ function createBaseModelDefinition(): ModelDefinition { } export const ModelDefinition: MessageFns = { - encode(message: ModelDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: ModelDefinition, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.armor !== undefined) { Armor.encode(message.armor, writer.uint32(10).fork()).join(); } @@ -293,22 +341,39 @@ export const ModelDefinition: MessageFns = { Vector3.encode(message.turret_origin, writer.uint32(18).fork()).join(); } if (message.initial_turret_rotation !== undefined) { - InitialTurretRotation.encode(message.initial_turret_rotation, writer.uint32(26).fork()).join(); + InitialTurretRotation.encode( + message.initial_turret_rotation, + writer.uint32(26).fork(), + ).join(); } - globalThis.Object.entries(message.turrets).forEach(([key, value]: [string, TurretModelDefinition]) => { - ModelDefinition_TurretsEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).join(); - }); - globalThis.Object.entries(message.tracks).forEach(([key, value]: [string, TrackModelDefinition]) => { - ModelDefinition_TracksEntry.encode({ key: key as any, value }, writer.uint32(42).fork()).join(); - }); + globalThis.Object.entries(message.turrets).forEach( + ([key, value]: [string, TurretModelDefinition]) => { + ModelDefinition_TurretsEntry.encode( + { key: key as any, value }, + writer.uint32(34).fork(), + ).join(); + }, + ); + globalThis.Object.entries(message.tracks).forEach( + ([key, value]: [string, TrackModelDefinition]) => { + ModelDefinition_TracksEntry.encode( + { key: key as any, value }, + writer.uint32(42).fork(), + ).join(); + }, + ); if (message.bounding_box !== undefined) { - BoundingBox.encode(message.bounding_box, writer.uint32(50).fork()).join(); + BoundingBox.encode( + message.bounding_box!, + writer.uint32(50).fork(), + ).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ModelDefinition { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseModelDefinition(); while (reader.pos < end) { @@ -335,7 +400,10 @@ export const ModelDefinition: MessageFns = { break; } - message.initial_turret_rotation = InitialTurretRotation.decode(reader, reader.uint32()); + message.initial_turret_rotation = InitialTurretRotation.decode( + reader, + reader.uint32(), + ); continue; } case 4: { @@ -343,7 +411,10 @@ export const ModelDefinition: MessageFns = { break; } - const entry4 = ModelDefinition_TurretsEntry.decode(reader, reader.uint32()); + const entry4 = ModelDefinition_TurretsEntry.decode( + reader, + reader.uint32(), + ); if (entry4.value !== undefined) { message.turrets[entry4.key] = entry4.value; } @@ -354,7 +425,10 @@ export const ModelDefinition: MessageFns = { break; } - const entry5 = ModelDefinition_TracksEntry.decode(reader, reader.uint32()); + const entry5 = ModelDefinition_TracksEntry.decode( + reader, + reader.uint32(), + ); if (entry5.value !== undefined) { message.tracks[entry5.key] = entry5.value; } @@ -383,36 +457,44 @@ export const ModelDefinition: MessageFns = { turret_origin: isSet(object.turretOrigin) ? Vector3.fromJSON(object.turretOrigin) : isSet(object.turret_origin) - ? Vector3.fromJSON(object.turret_origin) - : undefined, + ? Vector3.fromJSON(object.turret_origin) + : undefined, initial_turret_rotation: isSet(object.initialTurretRotation) ? InitialTurretRotation.fromJSON(object.initialTurretRotation) : isSet(object.initial_turret_rotation) - ? InitialTurretRotation.fromJSON(object.initial_turret_rotation) - : undefined, + ? InitialTurretRotation.fromJSON(object.initial_turret_rotation) + : undefined, turrets: isObject(object.turrets) ? (globalThis.Object.entries(object.turrets) as [string, any][]).reduce( - (acc: { [key: number]: TurretModelDefinition }, [key, value]: [string, any]) => { - acc[globalThis.Number(key)] = TurretModelDefinition.fromJSON(value); - return acc; - }, - {}, - ) + ( + acc: { [key: number]: TurretModelDefinition }, + [key, value]: [string, any], + ) => { + acc[globalThis.Number(key)] = + TurretModelDefinition.fromJSON(value); + return acc; + }, + {}, + ) : {}, tracks: isObject(object.tracks) ? (globalThis.Object.entries(object.tracks) as [string, any][]).reduce( - (acc: { [key: number]: TrackModelDefinition }, [key, value]: [string, any]) => { - acc[globalThis.Number(key)] = TrackModelDefinition.fromJSON(value); - return acc; - }, - {}, - ) + ( + acc: { [key: number]: TrackModelDefinition }, + [key, value]: [string, any], + ) => { + acc[globalThis.Number(key)] = + TrackModelDefinition.fromJSON(value); + return acc; + }, + {}, + ) : {}, bounding_box: isSet(object.boundingBox) ? BoundingBox.fromJSON(object.boundingBox) : isSet(object.bounding_box) - ? BoundingBox.fromJSON(object.bounding_box) - : undefined, + ? BoundingBox.fromJSON(object.bounding_box) + : undefined, }; }, @@ -425,10 +507,15 @@ export const ModelDefinition: MessageFns = { obj.turretOrigin = Vector3.toJSON(message.turret_origin); } if (message.initial_turret_rotation !== undefined) { - obj.initialTurretRotation = InitialTurretRotation.toJSON(message.initial_turret_rotation); + obj.initialTurretRotation = InitialTurretRotation.toJSON( + message.initial_turret_rotation, + ); } if (message.turrets) { - const entries = globalThis.Object.entries(message.turrets) as [string, TurretModelDefinition][]; + const entries = globalThis.Object.entries(message.turrets) as [ + string, + TurretModelDefinition, + ][]; if (entries.length > 0) { obj.turrets = {}; entries.forEach(([k, v]) => { @@ -437,7 +524,10 @@ export const ModelDefinition: MessageFns = { } } if (message.tracks) { - const entries = globalThis.Object.entries(message.tracks) as [string, TrackModelDefinition][]; + const entries = globalThis.Object.entries(message.tracks) as [ + string, + TrackModelDefinition, + ][]; if (entries.length > 0) { obj.tracks = {}; entries.forEach(([k, v]) => { @@ -451,30 +541,56 @@ export const ModelDefinition: MessageFns = { return obj; }, - create, I>>(base?: I): ModelDefinition { + create, I>>( + base?: I, + ): ModelDefinition { return ModelDefinition.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): ModelDefinition { + fromPartial, I>>( + object: I, + ): ModelDefinition { const message = createBaseModelDefinition(); - message.armor = (object.armor !== undefined && object.armor !== null) ? Armor.fromPartial(object.armor) : undefined; - message.turret_origin = (object.turret_origin !== undefined && object.turret_origin !== null) - ? Vector3.fromPartial(object.turret_origin) - : undefined; + message.armor = + object.armor !== undefined && object.armor !== null + ? Armor.fromPartial(object.armor) + : undefined; + message.turret_origin = + object.turret_origin !== undefined && object.turret_origin !== null + ? Vector3.fromPartial(object.turret_origin) + : undefined; message.initial_turret_rotation = - (object.initial_turret_rotation !== undefined && object.initial_turret_rotation !== null) + object.initial_turret_rotation !== undefined && + object.initial_turret_rotation !== null ? InitialTurretRotation.fromPartial(object.initial_turret_rotation) : undefined; - message.turrets = (globalThis.Object.entries(object.turrets ?? {}) as [string, TurretModelDefinition][]).reduce( - (acc: { [key: number]: TurretModelDefinition }, [key, value]: [string, TurretModelDefinition]) => { + message.turrets = ( + globalThis.Object.entries(object.turrets ?? {}) as [ + string, + TurretModelDefinition, + ][] + ).reduce( + ( + acc: { [key: number]: TurretModelDefinition }, + [key, value]: [string, TurretModelDefinition], + ) => { if (value !== undefined) { - acc[globalThis.Number(key)] = TurretModelDefinition.fromPartial(value); + acc[globalThis.Number(key)] = + TurretModelDefinition.fromPartial(value); } return acc; }, {}, ); - message.tracks = (globalThis.Object.entries(object.tracks ?? {}) as [string, TrackModelDefinition][]).reduce( - (acc: { [key: number]: TrackModelDefinition }, [key, value]: [string, TrackModelDefinition]) => { + message.tracks = ( + globalThis.Object.entries(object.tracks ?? {}) as [ + string, + TrackModelDefinition, + ][] + ).reduce( + ( + acc: { [key: number]: TrackModelDefinition }, + [key, value]: [string, TrackModelDefinition], + ) => { if (value !== undefined) { acc[globalThis.Number(key)] = TrackModelDefinition.fromPartial(value); } @@ -482,9 +598,10 @@ export const ModelDefinition: MessageFns = { }, {}, ); - message.bounding_box = (object.bounding_box !== undefined && object.bounding_box !== null) - ? BoundingBox.fromPartial(object.bounding_box) - : undefined; + message.bounding_box = + object.bounding_box !== undefined && object.bounding_box !== null + ? BoundingBox.fromPartial(object.bounding_box) + : undefined; return message; }, }; @@ -493,167 +610,217 @@ function createBaseModelDefinition_TurretsEntry(): ModelDefinition_TurretsEntry return { key: 0, value: undefined }; } -export const ModelDefinition_TurretsEntry: MessageFns = { - encode(message: ModelDefinition_TurretsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.key !== 0) { - writer.uint32(8).uint32(message.key); - } - if (message.value !== undefined) { - TurretModelDefinition.encode(message.value, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): ModelDefinition_TurretsEntry { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - const end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseModelDefinition_TurretsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - if (tag !== 8) { - break; - } - - message.key = reader.uint32(); - continue; - } - case 2: { - if (tag !== 18) { - break; - } - - message.value = TurretModelDefinition.decode(reader, reader.uint32()); - continue; - } +export const ModelDefinition_TurretsEntry: MessageFns = + { + encode( + message: ModelDefinition_TurretsEntry, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.key !== 0) { + writer.uint32(8).uint32(message.key); } - if ((tag & 7) === 4 || tag === 0) { - break; + if (message.value !== undefined) { + TurretModelDefinition.encode( + message.value, + writer.uint32(18).fork(), + ).join(); } - reader.skip(tag & 7); - } - return message; - }, + return writer; + }, - fromJSON(object: any): ModelDefinition_TurretsEntry { - return { - key: isSet(object.key) ? globalThis.Number(object.key) : 0, - value: isSet(object.value) ? TurretModelDefinition.fromJSON(object.value) : undefined, - }; - }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): ModelDefinition_TurretsEntry { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModelDefinition_TurretsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break; + } - toJSON(message: ModelDefinition_TurretsEntry): unknown { - const obj: any = {}; - if (message.key !== 0) { - obj.key = Math.round(message.key); - } - if (message.value !== undefined) { - obj.value = TurretModelDefinition.toJSON(message.value); - } - return obj; - }, + message.key = reader.uint32(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } - create, I>>(base?: I): ModelDefinition_TurretsEntry { - return ModelDefinition_TurretsEntry.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): ModelDefinition_TurretsEntry { - const message = createBaseModelDefinition_TurretsEntry(); - message.key = object.key ?? 0; - message.value = (object.value !== undefined && object.value !== null) - ? TurretModelDefinition.fromPartial(object.value) - : undefined; - return message; - }, -}; + message.value = TurretModelDefinition.decode( + reader, + reader.uint32(), + ); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ModelDefinition_TurretsEntry { + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) + ? TurretModelDefinition.fromJSON(object.value) + : undefined, + }; + }, + + toJSON(message: ModelDefinition_TurretsEntry): unknown { + const obj: any = {}; + if (message.key !== 0) { + obj.key = Math.round(message.key); + } + if (message.value !== undefined) { + obj.value = TurretModelDefinition.toJSON(message.value); + } + return obj; + }, + + create, I>>( + base?: I, + ): ModelDefinition_TurretsEntry { + return ModelDefinition_TurretsEntry.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): ModelDefinition_TurretsEntry { + const message = createBaseModelDefinition_TurretsEntry(); + message.key = object.key ?? 0; + message.value = + object.value !== undefined && object.value !== null + ? TurretModelDefinition.fromPartial(object.value) + : undefined; + return message; + }, + }; function createBaseModelDefinition_TracksEntry(): ModelDefinition_TracksEntry { return { key: 0, value: undefined }; } -export const ModelDefinition_TracksEntry: MessageFns = { - encode(message: ModelDefinition_TracksEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.key !== 0) { - writer.uint32(8).uint32(message.key); - } - if (message.value !== undefined) { - TrackModelDefinition.encode(message.value, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): ModelDefinition_TracksEntry { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - const end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseModelDefinition_TracksEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - if (tag !== 8) { - break; - } - - message.key = reader.uint32(); - continue; - } - case 2: { - if (tag !== 18) { - break; - } - - message.value = TrackModelDefinition.decode(reader, reader.uint32()); - continue; - } +export const ModelDefinition_TracksEntry: MessageFns = + { + encode( + message: ModelDefinition_TracksEntry, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.key !== 0) { + writer.uint32(8).uint32(message.key); } - if ((tag & 7) === 4 || tag === 0) { - break; + if (message.value !== undefined) { + TrackModelDefinition.encode( + message.value, + writer.uint32(18).fork(), + ).join(); } - reader.skip(tag & 7); - } - return message; - }, + return writer; + }, - fromJSON(object: any): ModelDefinition_TracksEntry { - return { - key: isSet(object.key) ? globalThis.Number(object.key) : 0, - value: isSet(object.value) ? TrackModelDefinition.fromJSON(object.value) : undefined, - }; - }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): ModelDefinition_TracksEntry { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModelDefinition_TracksEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break; + } - toJSON(message: ModelDefinition_TracksEntry): unknown { - const obj: any = {}; - if (message.key !== 0) { - obj.key = Math.round(message.key); - } - if (message.value !== undefined) { - obj.value = TrackModelDefinition.toJSON(message.value); - } - return obj; - }, + message.key = reader.uint32(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } - create, I>>(base?: I): ModelDefinition_TracksEntry { - return ModelDefinition_TracksEntry.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>(object: I): ModelDefinition_TracksEntry { - const message = createBaseModelDefinition_TracksEntry(); - message.key = object.key ?? 0; - message.value = (object.value !== undefined && object.value !== null) - ? TrackModelDefinition.fromPartial(object.value) - : undefined; - return message; - }, -}; + message.value = TrackModelDefinition.decode( + reader, + reader.uint32(), + ); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): ModelDefinition_TracksEntry { + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) + ? TrackModelDefinition.fromJSON(object.value) + : undefined, + }; + }, + + toJSON(message: ModelDefinition_TracksEntry): unknown { + const obj: any = {}; + if (message.key !== 0) { + obj.key = Math.round(message.key); + } + if (message.value !== undefined) { + obj.value = TrackModelDefinition.toJSON(message.value); + } + return obj; + }, + + create, I>>( + base?: I, + ): ModelDefinition_TracksEntry { + return ModelDefinition_TracksEntry.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): ModelDefinition_TracksEntry { + const message = createBaseModelDefinition_TracksEntry(); + message.key = object.key ?? 0; + message.value = + object.value !== undefined && object.value !== null + ? TrackModelDefinition.fromPartial(object.value) + : undefined; + return message; + }, + }; function createBaseArmor(): Armor { return { thickness: {}, spaced: [] }; } export const Armor: MessageFns = { - encode(message: Armor, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - globalThis.Object.entries(message.thickness).forEach(([key, value]: [string, number]) => { - Armor_ThicknessEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join(); - }); + encode( + message: Armor, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + globalThis.Object.entries(message.thickness).forEach( + ([key, value]: [string, number]) => { + Armor_ThicknessEntry.encode( + { key: key as any, value }, + writer.uint32(10).fork(), + ).join(); + }, + ); for (const v of message.spaced) { writer.uint32(16).uint32(v!); } @@ -661,7 +828,8 @@ export const Armor: MessageFns = { }, decode(input: BinaryReader | Uint8Array, length?: number): Armor { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseArmor(); while (reader.pos < end) { @@ -708,22 +876,29 @@ export const Armor: MessageFns = { fromJSON(object: any): Armor { return { thickness: isObject(object.thickness) - ? (globalThis.Object.entries(object.thickness) as [string, any][]).reduce( - (acc: { [key: number]: number }, [key, value]: [string, any]) => { - acc[globalThis.Number(key)] = globalThis.Number(value); - return acc; - }, - {}, - ) + ? ( + globalThis.Object.entries(object.thickness) as [string, any][] + ).reduce( + (acc: { [key: number]: number }, [key, value]: [string, any]) => { + acc[globalThis.Number(key)] = globalThis.Number(value); + return acc; + }, + {}, + ) : {}, - spaced: globalThis.Array.isArray(object?.spaced) ? object.spaced.map((e: any) => globalThis.Number(e)) : [], + spaced: globalThis.Array.isArray(object?.spaced) + ? object.spaced.map((e: any) => globalThis.Number(e)) + : [], }; }, toJSON(message: Armor): unknown { const obj: any = {}; if (message.thickness) { - const entries = globalThis.Object.entries(message.thickness) as [string, number][]; + const entries = globalThis.Object.entries(message.thickness) as [ + string, + number, + ][]; if (entries.length > 0) { obj.thickness = {}; entries.forEach(([k, v]) => { @@ -742,7 +917,9 @@ export const Armor: MessageFns = { }, fromPartial, I>>(object: I): Armor { const message = createBaseArmor(); - message.thickness = (globalThis.Object.entries(object.thickness ?? {}) as [string, number][]).reduce( + message.thickness = ( + globalThis.Object.entries(object.thickness ?? {}) as [string, number][] + ).reduce( (acc: { [key: number]: number }, [key, value]: [string, number]) => { if (value !== undefined) { acc[globalThis.Number(key)] = globalThis.Number(value); @@ -761,7 +938,10 @@ function createBaseArmor_ThicknessEntry(): Armor_ThicknessEntry { } export const Armor_ThicknessEntry: MessageFns = { - encode(message: Armor_ThicknessEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: Armor_ThicknessEntry, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.key !== 0) { writer.uint32(8).uint32(message.key); } @@ -771,8 +951,12 @@ export const Armor_ThicknessEntry: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): Armor_ThicknessEntry { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): Armor_ThicknessEntry { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseArmor_ThicknessEntry(); while (reader.pos < end) { @@ -821,10 +1005,14 @@ export const Armor_ThicknessEntry: MessageFns = { return obj; }, - create, I>>(base?: I): Armor_ThicknessEntry { + create, I>>( + base?: I, + ): Armor_ThicknessEntry { return Armor_ThicknessEntry.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): Armor_ThicknessEntry { + fromPartial, I>>( + object: I, + ): Armor_ThicknessEntry { const message = createBaseArmor_ThicknessEntry(); message.key = object.key ?? 0; message.value = object.value ?? 0; @@ -837,7 +1025,10 @@ function createBaseVector3(): Vector3 { } export const Vector3: MessageFns = { - encode(message: Vector3, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: Vector3, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.x !== 0) { writer.uint32(13).float(message.x); } @@ -851,7 +1042,8 @@ export const Vector3: MessageFns = { }, decode(input: BinaryReader | Uint8Array, length?: number): Vector3 { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseVector3(); while (reader.pos < end) { @@ -929,7 +1121,10 @@ function createBaseInitialTurretRotation(): InitialTurretRotation { } export const InitialTurretRotation: MessageFns = { - encode(message: InitialTurretRotation, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: InitialTurretRotation, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.yaw !== 0) { writer.uint32(13).float(message.yaw); } @@ -942,8 +1137,12 @@ export const InitialTurretRotation: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): InitialTurretRotation { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): InitialTurretRotation { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseInitialTurretRotation(); while (reader.pos < end) { @@ -1004,10 +1203,14 @@ export const InitialTurretRotation: MessageFns = { return obj; }, - create, I>>(base?: I): InitialTurretRotation { + create, I>>( + base?: I, + ): InitialTurretRotation { return InitialTurretRotation.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): InitialTurretRotation { + fromPartial, I>>( + object: I, + ): InitialTurretRotation { const message = createBaseInitialTurretRotation(); message.yaw = object.yaw ?? 0; message.pitch = object.pitch ?? 0; @@ -1017,13 +1220,26 @@ export const InitialTurretRotation: MessageFns = { }; function createBaseTurretModelDefinition(): TurretModelDefinition { - return { bounding_box: undefined, armor: undefined, model_id: 0, gun_origin: undefined, guns: {}, yaw: undefined }; + return { + bounding_box: undefined, + armor: undefined, + model_id: 0, + gun_origin: undefined, + guns: {}, + yaw: undefined, + }; } export const TurretModelDefinition: MessageFns = { - encode(message: TurretModelDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: TurretModelDefinition, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.bounding_box !== undefined) { - BoundingBox.encode(message.bounding_box, writer.uint32(10).fork()).join(); + BoundingBox.encode( + message.bounding_box!, + writer.uint32(10).fork(), + ).join(); } if (message.armor !== undefined) { Armor.encode(message.armor, writer.uint32(18).fork()).join(); @@ -1034,17 +1250,26 @@ export const TurretModelDefinition: MessageFns = { if (message.gun_origin !== undefined) { Vector3.encode(message.gun_origin, writer.uint32(34).fork()).join(); } - globalThis.Object.entries(message.guns).forEach(([key, value]: [string, GunModelDefinition]) => { - TurretModelDefinition_GunsEntry.encode({ key: key as any, value }, writer.uint32(42).fork()).join(); - }); + globalThis.Object.entries(message.guns).forEach( + ([key, value]: [string, GunModelDefinition]) => { + TurretModelDefinition_GunsEntry.encode( + { key: key as any, value }, + writer.uint32(42).fork(), + ).join(); + }, + ); if (message.yaw !== undefined) { YawLimits.encode(message.yaw, writer.uint32(50).fork()).join(); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): TurretModelDefinition { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): TurretModelDefinition { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTurretModelDefinition(); while (reader.pos < end) { @@ -1087,7 +1312,10 @@ export const TurretModelDefinition: MessageFns = { break; } - const entry5 = TurretModelDefinition_GunsEntry.decode(reader, reader.uint32()); + const entry5 = TurretModelDefinition_GunsEntry.decode( + reader, + reader.uint32(), + ); if (entry5.value !== undefined) { message.guns[entry5.key] = entry5.value; } @@ -1115,27 +1343,30 @@ export const TurretModelDefinition: MessageFns = { bounding_box: isSet(object.boundingBox) ? BoundingBox.fromJSON(object.boundingBox) : isSet(object.bounding_box) - ? BoundingBox.fromJSON(object.bounding_box) - : undefined, + ? BoundingBox.fromJSON(object.bounding_box) + : undefined, armor: isSet(object.armor) ? Armor.fromJSON(object.armor) : undefined, model_id: isSet(object.modelId) ? globalThis.Number(object.modelId) : isSet(object.model_id) - ? globalThis.Number(object.model_id) - : 0, + ? globalThis.Number(object.model_id) + : 0, gun_origin: isSet(object.gunOrigin) ? Vector3.fromJSON(object.gunOrigin) : isSet(object.gun_origin) - ? Vector3.fromJSON(object.gun_origin) - : undefined, + ? Vector3.fromJSON(object.gun_origin) + : undefined, guns: isObject(object.guns) ? (globalThis.Object.entries(object.guns) as [string, any][]).reduce( - (acc: { [key: number]: GunModelDefinition }, [key, value]: [string, any]) => { - acc[globalThis.Number(key)] = GunModelDefinition.fromJSON(value); - return acc; - }, - {}, - ) + ( + acc: { [key: number]: GunModelDefinition }, + [key, value]: [string, any], + ) => { + acc[globalThis.Number(key)] = GunModelDefinition.fromJSON(value); + return acc; + }, + {}, + ) : {}, yaw: isSet(object.yaw) ? YawLimits.fromJSON(object.yaw) : undefined, }; @@ -1156,7 +1387,10 @@ export const TurretModelDefinition: MessageFns = { obj.gunOrigin = Vector3.toJSON(message.gun_origin); } if (message.guns) { - const entries = globalThis.Object.entries(message.guns) as [string, GunModelDefinition][]; + const entries = globalThis.Object.entries(message.guns) as [ + string, + GunModelDefinition, + ][]; if (entries.length > 0) { obj.guns = {}; entries.forEach(([k, v]) => { @@ -1170,21 +1404,38 @@ export const TurretModelDefinition: MessageFns = { return obj; }, - create, I>>(base?: I): TurretModelDefinition { + create, I>>( + base?: I, + ): TurretModelDefinition { return TurretModelDefinition.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): TurretModelDefinition { + fromPartial, I>>( + object: I, + ): TurretModelDefinition { const message = createBaseTurretModelDefinition(); - message.bounding_box = (object.bounding_box !== undefined && object.bounding_box !== null) - ? BoundingBox.fromPartial(object.bounding_box) - : undefined; - message.armor = (object.armor !== undefined && object.armor !== null) ? Armor.fromPartial(object.armor) : undefined; + message.bounding_box = + object.bounding_box !== undefined && object.bounding_box !== null + ? BoundingBox.fromPartial(object.bounding_box) + : undefined; + message.armor = + object.armor !== undefined && object.armor !== null + ? Armor.fromPartial(object.armor) + : undefined; message.model_id = object.model_id ?? 0; - message.gun_origin = (object.gun_origin !== undefined && object.gun_origin !== null) - ? Vector3.fromPartial(object.gun_origin) - : undefined; - message.guns = (globalThis.Object.entries(object.guns ?? {}) as [string, GunModelDefinition][]).reduce( - (acc: { [key: number]: GunModelDefinition }, [key, value]: [string, GunModelDefinition]) => { + message.gun_origin = + object.gun_origin !== undefined && object.gun_origin !== null + ? Vector3.fromPartial(object.gun_origin) + : undefined; + message.guns = ( + globalThis.Object.entries(object.guns ?? {}) as [ + string, + GunModelDefinition, + ][] + ).reduce( + ( + acc: { [key: number]: GunModelDefinition }, + [key, value]: [string, GunModelDefinition], + ) => { if (value !== undefined) { acc[globalThis.Number(key)] = GunModelDefinition.fromPartial(value); } @@ -1192,7 +1443,10 @@ export const TurretModelDefinition: MessageFns = { }, {}, ); - message.yaw = (object.yaw !== undefined && object.yaw !== null) ? YawLimits.fromPartial(object.yaw) : undefined; + message.yaw = + object.yaw !== undefined && object.yaw !== null + ? YawLimits.fromPartial(object.yaw) + : undefined; return message; }, }; @@ -1201,88 +1455,107 @@ function createBaseTurretModelDefinition_GunsEntry(): TurretModelDefinition_Guns return { key: 0, value: undefined }; } -export const TurretModelDefinition_GunsEntry: MessageFns = { - encode(message: TurretModelDefinition_GunsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - if (message.key !== 0) { - writer.uint32(8).uint32(message.key); - } - if (message.value !== undefined) { - GunModelDefinition.encode(message.value, writer.uint32(18).fork()).join(); - } - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): TurretModelDefinition_GunsEntry { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - const end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseTurretModelDefinition_GunsEntry(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - if (tag !== 8) { - break; - } - - message.key = reader.uint32(); - continue; - } - case 2: { - if (tag !== 18) { - break; - } - - message.value = GunModelDefinition.decode(reader, reader.uint32()); - continue; - } +export const TurretModelDefinition_GunsEntry: MessageFns = + { + encode( + message: TurretModelDefinition_GunsEntry, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { + if (message.key !== 0) { + writer.uint32(8).uint32(message.key); } - if ((tag & 7) === 4 || tag === 0) { - break; + if (message.value !== undefined) { + GunModelDefinition.encode( + message.value, + writer.uint32(18).fork(), + ).join(); } - reader.skip(tag & 7); - } - return message; - }, + return writer; + }, - fromJSON(object: any): TurretModelDefinition_GunsEntry { - return { - key: isSet(object.key) ? globalThis.Number(object.key) : 0, - value: isSet(object.value) ? GunModelDefinition.fromJSON(object.value) : undefined, - }; - }, + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): TurretModelDefinition_GunsEntry { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTurretModelDefinition_GunsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (tag !== 8) { + break; + } - toJSON(message: TurretModelDefinition_GunsEntry): unknown { - const obj: any = {}; - if (message.key !== 0) { - obj.key = Math.round(message.key); - } - if (message.value !== undefined) { - obj.value = GunModelDefinition.toJSON(message.value); - } - return obj; - }, + message.key = reader.uint32(); + continue; + } + case 2: { + if (tag !== 18) { + break; + } - create, I>>(base?: I): TurretModelDefinition_GunsEntry { - return TurretModelDefinition_GunsEntry.fromPartial(base ?? ({} as any)); - }, - fromPartial, I>>( - object: I, - ): TurretModelDefinition_GunsEntry { - const message = createBaseTurretModelDefinition_GunsEntry(); - message.key = object.key ?? 0; - message.value = (object.value !== undefined && object.value !== null) - ? GunModelDefinition.fromPartial(object.value) - : undefined; - return message; - }, -}; + message.value = GunModelDefinition.decode(reader, reader.uint32()); + continue; + } + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + fromJSON(object: any): TurretModelDefinition_GunsEntry { + return { + key: isSet(object.key) ? globalThis.Number(object.key) : 0, + value: isSet(object.value) + ? GunModelDefinition.fromJSON(object.value) + : undefined, + }; + }, + + toJSON(message: TurretModelDefinition_GunsEntry): unknown { + const obj: any = {}; + if (message.key !== 0) { + obj.key = Math.round(message.key); + } + if (message.value !== undefined) { + obj.value = GunModelDefinition.toJSON(message.value); + } + return obj; + }, + + create, I>>( + base?: I, + ): TurretModelDefinition_GunsEntry { + return TurretModelDefinition_GunsEntry.fromPartial(base ?? ({} as any)); + }, + fromPartial< + I extends Exact, I>, + >(object: I): TurretModelDefinition_GunsEntry { + const message = createBaseTurretModelDefinition_GunsEntry(); + message.key = object.key ?? 0; + message.value = + object.value !== undefined && object.value !== null + ? GunModelDefinition.fromPartial(object.value) + : undefined; + return message; + }, + }; function createBaseYawLimits(): YawLimits { return { min: 0, max: 0 }; } export const YawLimits: MessageFns = { - encode(message: YawLimits, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: YawLimits, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.min !== 0) { writer.uint32(13).float(message.min); } @@ -1293,7 +1566,8 @@ export const YawLimits: MessageFns = { }, decode(input: BinaryReader | Uint8Array, length?: number): YawLimits { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseYawLimits(); while (reader.pos < end) { @@ -1345,7 +1619,9 @@ export const YawLimits: MessageFns = { create, I>>(base?: I): YawLimits { return YawLimits.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): YawLimits { + fromPartial, I>>( + object: I, + ): YawLimits { const message = createBaseYawLimits(); message.min = object.min ?? 0; message.max = object.max ?? 0; @@ -1358,7 +1634,10 @@ function createBaseBoundingBox(): BoundingBox { } export const BoundingBox: MessageFns = { - encode(message: BoundingBox, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: BoundingBox, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.min !== undefined) { Vector3.encode(message.min, writer.uint32(10).fork()).join(); } @@ -1369,7 +1648,8 @@ export const BoundingBox: MessageFns = { }, decode(input: BinaryReader | Uint8Array, length?: number): BoundingBox { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseBoundingBox(); while (reader.pos < end) { @@ -1421,10 +1701,18 @@ export const BoundingBox: MessageFns = { create, I>>(base?: I): BoundingBox { return BoundingBox.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): BoundingBox { + fromPartial, I>>( + object: I, + ): BoundingBox { const message = createBaseBoundingBox(); - message.min = (object.min !== undefined && object.min !== null) ? Vector3.fromPartial(object.min) : undefined; - message.max = (object.max !== undefined && object.max !== null) ? Vector3.fromPartial(object.max) : undefined; + message.min = + object.min !== undefined && object.min !== null + ? Vector3.fromPartial(object.min) + : undefined; + message.max = + object.max !== undefined && object.max !== null + ? Vector3.fromPartial(object.max) + : undefined; return message; }, }; @@ -1434,7 +1722,10 @@ function createBaseTrackModelDefinition(): TrackModelDefinition { } export const TrackModelDefinition: MessageFns = { - encode(message: TrackModelDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: TrackModelDefinition, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.thickness !== 0) { writer.uint32(13).float(message.thickness); } @@ -1444,8 +1735,12 @@ export const TrackModelDefinition: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): TrackModelDefinition { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): TrackModelDefinition { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTrackModelDefinition(); while (reader.pos < end) { @@ -1478,8 +1773,12 @@ export const TrackModelDefinition: MessageFns = { fromJSON(object: any): TrackModelDefinition { return { - thickness: isSet(object.thickness) ? globalThis.Number(object.thickness) : 0, - origin: isSet(object.origin) ? Vector3.fromJSON(object.origin) : undefined, + thickness: isSet(object.thickness) + ? globalThis.Number(object.thickness) + : 0, + origin: isSet(object.origin) + ? Vector3.fromJSON(object.origin) + : undefined, }; }, @@ -1494,25 +1793,39 @@ export const TrackModelDefinition: MessageFns = { return obj; }, - create, I>>(base?: I): TrackModelDefinition { + create, I>>( + base?: I, + ): TrackModelDefinition { return TrackModelDefinition.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): TrackModelDefinition { + fromPartial, I>>( + object: I, + ): TrackModelDefinition { const message = createBaseTrackModelDefinition(); message.thickness = object.thickness ?? 0; - message.origin = (object.origin !== undefined && object.origin !== null) - ? Vector3.fromPartial(object.origin) - : undefined; + message.origin = + object.origin !== undefined && object.origin !== null + ? Vector3.fromPartial(object.origin) + : undefined; return message; }, }; function createBaseGunModelDefinition(): GunModelDefinition { - return { armor: undefined, thickness: 0, model_id: 0, pitch: undefined, mask: 0 }; + return { + armor: undefined, + thickness: 0, + model_id: 0, + pitch: undefined, + mask: 0, + }; } export const GunModelDefinition: MessageFns = { - encode(message: GunModelDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: GunModelDefinition, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.armor !== undefined) { Armor.encode(message.armor, writer.uint32(10).fork()).join(); } @@ -1531,8 +1844,12 @@ export const GunModelDefinition: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): GunModelDefinition { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): GunModelDefinition { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGunModelDefinition(); while (reader.pos < end) { @@ -1590,13 +1907,17 @@ export const GunModelDefinition: MessageFns = { fromJSON(object: any): GunModelDefinition { return { armor: isSet(object.armor) ? Armor.fromJSON(object.armor) : undefined, - thickness: isSet(object.thickness) ? globalThis.Number(object.thickness) : 0, + thickness: isSet(object.thickness) + ? globalThis.Number(object.thickness) + : 0, model_id: isSet(object.modelId) ? globalThis.Number(object.modelId) : isSet(object.model_id) - ? globalThis.Number(object.model_id) - : 0, - pitch: isSet(object.pitch) ? PitchLimits.fromJSON(object.pitch) : undefined, + ? globalThis.Number(object.model_id) + : 0, + pitch: isSet(object.pitch) + ? PitchLimits.fromJSON(object.pitch) + : undefined, mask: isSet(object.mask) ? globalThis.Number(object.mask) : 0, }; }, @@ -1621,17 +1942,25 @@ export const GunModelDefinition: MessageFns = { return obj; }, - create, I>>(base?: I): GunModelDefinition { + create, I>>( + base?: I, + ): GunModelDefinition { return GunModelDefinition.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): GunModelDefinition { + fromPartial, I>>( + object: I, + ): GunModelDefinition { const message = createBaseGunModelDefinition(); - message.armor = (object.armor !== undefined && object.armor !== null) ? Armor.fromPartial(object.armor) : undefined; + message.armor = + object.armor !== undefined && object.armor !== null + ? Armor.fromPartial(object.armor) + : undefined; message.thickness = object.thickness ?? 0; message.model_id = object.model_id ?? 0; - message.pitch = (object.pitch !== undefined && object.pitch !== null) - ? PitchLimits.fromPartial(object.pitch) - : undefined; + message.pitch = + object.pitch !== undefined && object.pitch !== null + ? PitchLimits.fromPartial(object.pitch) + : undefined; message.mask = object.mask ?? 0; return message; }, @@ -1642,7 +1971,10 @@ function createBasePitchLimits(): PitchLimits { } export const PitchLimits: MessageFns = { - encode(message: PitchLimits, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: PitchLimits, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.min !== 0) { writer.uint32(13).float(message.min); } @@ -1662,7 +1994,8 @@ export const PitchLimits: MessageFns = { }, decode(input: BinaryReader | Uint8Array, length?: number): PitchLimits { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBasePitchLimits(); while (reader.pos < end) { @@ -1721,9 +2054,15 @@ export const PitchLimits: MessageFns = { return { min: isSet(object.min) ? globalThis.Number(object.min) : 0, max: isSet(object.max) ? globalThis.Number(object.max) : 0, - front: isSet(object.front) ? PitchLimitsExtrema.fromJSON(object.front) : undefined, - back: isSet(object.back) ? PitchLimitsExtrema.fromJSON(object.back) : undefined, - transition: isSet(object.transition) ? globalThis.Number(object.transition) : 0, + front: isSet(object.front) + ? PitchLimitsExtrema.fromJSON(object.front) + : undefined, + back: isSet(object.back) + ? PitchLimitsExtrema.fromJSON(object.back) + : undefined, + transition: isSet(object.transition) + ? globalThis.Number(object.transition) + : 0, }; }, @@ -1750,16 +2089,20 @@ export const PitchLimits: MessageFns = { create, I>>(base?: I): PitchLimits { return PitchLimits.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): PitchLimits { + fromPartial, I>>( + object: I, + ): PitchLimits { const message = createBasePitchLimits(); message.min = object.min ?? 0; message.max = object.max ?? 0; - message.front = (object.front !== undefined && object.front !== null) - ? PitchLimitsExtrema.fromPartial(object.front) - : undefined; - message.back = (object.back !== undefined && object.back !== null) - ? PitchLimitsExtrema.fromPartial(object.back) - : undefined; + message.front = + object.front !== undefined && object.front !== null + ? PitchLimitsExtrema.fromPartial(object.front) + : undefined; + message.back = + object.back !== undefined && object.back !== null + ? PitchLimitsExtrema.fromPartial(object.back) + : undefined; message.transition = object.transition ?? 0; return message; }, @@ -1770,7 +2113,10 @@ function createBasePitchLimitsExtrema(): PitchLimitsExtrema { } export const PitchLimitsExtrema: MessageFns = { - encode(message: PitchLimitsExtrema, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + encode( + message: PitchLimitsExtrema, + writer: BinaryWriter = new BinaryWriter(), + ): BinaryWriter { if (message.min !== 0) { writer.uint32(13).float(message.min); } @@ -1783,8 +2129,12 @@ export const PitchLimitsExtrema: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): PitchLimitsExtrema { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + decode( + input: BinaryReader | Uint8Array, + length?: number, + ): PitchLimitsExtrema { + const reader = + input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBasePitchLimitsExtrema(); while (reader.pos < end) { @@ -1845,10 +2195,14 @@ export const PitchLimitsExtrema: MessageFns = { return obj; }, - create, I>>(base?: I): PitchLimitsExtrema { + create, I>>( + base?: I, + ): PitchLimitsExtrema { return PitchLimitsExtrema.fromPartial(base ?? ({} as any)); }, - fromPartial, I>>(object: I): PitchLimitsExtrema { + fromPartial, I>>( + object: I, + ): PitchLimitsExtrema { const message = createBasePitchLimitsExtrema(); message.min = object.min ?? 0; message.max = object.max ?? 0; @@ -1857,18 +2211,33 @@ export const PitchLimitsExtrema: MessageFns = { }, }; -type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; +type Builtin = + | Date + | Function + | Uint8Array + | string + | number + | boolean + | undefined; -export type DeepPartial = T extends Builtin ? T - : T extends globalThis.Array ? globalThis.Array> - : T extends ReadonlyArray ? ReadonlyArray> - : T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial } - : T extends {} ? { [K in keyof T]?: DeepPartial } - : Partial; +export type DeepPartial = T extends Builtin + ? T + : T extends globalThis.Array + ? globalThis.Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends { $case: string; value: unknown } + ? { $case: T["$case"]; value?: DeepPartial } + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin ? P - : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; +export type Exact = P extends Builtin + ? P + : P & { [K in keyof P]: Exact } & { + [K in Exclude>]: never; + }; function isObject(value: any): boolean { return typeof value === "object" && value !== null; diff --git a/packages/scripts/src/averages.ts b/packages/scripts/src/averages.ts index 38853e1bb..5429544fc 100644 --- a/packages/scripts/src/averages.ts +++ b/packages/scripts/src/averages.ts @@ -1,5 +1,6 @@ import { AverageDefinitions, + AverageDefinitionsAllStats, AverageDefinitionsEntry, type AverageDefinitionsManifest, type IndividualTankStats, @@ -30,9 +31,6 @@ type OptionalSecondLevel = { }; }; -type AverageDefinitionsEntrySubPartial = - OptionalSecondLevel; - const MINUTE = 60 * 1000; const HOUR = 60 * MINUTE; const DAY = 24 * HOUR; @@ -47,15 +45,15 @@ const preDiscoveredIds = await fetchPreDiscoveredIds(); const playerIds: Record = { asia: chunk( preDiscoveredIds.filter((id) => idToRegion(id) === "asia"), - PLAYER_IDS_PER_CALL + PLAYER_IDS_PER_CALL, ), com: chunk( preDiscoveredIds.filter((id) => idToRegion(id) === "com"), - PLAYER_IDS_PER_CALL + PLAYER_IDS_PER_CALL, ), eu: chunk( preDiscoveredIds.filter((id) => idToRegion(id) === "eu"), - PLAYER_IDS_PER_CALL + PLAYER_IDS_PER_CALL, ), }; let regionIndex = 0; @@ -71,7 +69,7 @@ times(THREADS, async () => { const regionIds = playerIds[region]; const [ids] = regionIds.splice( Math.floor(Math.random() * regionIds.length), - 1 + 1, ); const accountInfo = await getAccountInfo(region, ids, undefined, { fields: "last_battle_time,statistics.all.battles", @@ -104,8 +102,8 @@ times(THREADS, async () => { filteredIds.map((id) => getTankStats(region, id, { fields: "last_battle_time,battle_life_time,all,tank_id", - }) - ) + }), + ), ); players.forEach((tanks) => { @@ -114,7 +112,7 @@ times(THREADS, async () => { if (!tankIds.includes(tank.tank_id)) { console.log( - `Found new tank: ${tank.tank_id} (${tankIds.length + 1})` + `Found new tank: ${tank.tank_id} (${tankIds.length + 1})`, ); tankIds.push(tank.tank_id); tanksSorted[tank.tank_id] = []; @@ -140,7 +138,7 @@ async function postWork() { console.log( `Generating statistics based on ${samples.d_120.toLocaleString()} players (${samples.total.toLocaleString()} checked in total) and ${ tankIds.length - } tanks...` + } tanks...`, ); using uploader = new AssetUploader("averages"); @@ -152,7 +150,12 @@ async function postWork() { // (tank) => Date.now() - tank.last_battle_time * 1000 <= MAX_ACTIVITY_TIME, // ); const tanks = tanksSortedEntry; - const entry: AverageDefinitionsEntrySubPartial = { + const entry: { + mu: Partial>; + sigma: Partial>; + r: Partial>; + samples: Samples; + } = { mu: {}, sigma: {}, r: {}, @@ -162,13 +165,13 @@ async function postWork() { tanks.forEach((tank) => { const timeSinceLastActivity = Date.now() - tank.last_battle_time * 1000; - entry.samples.total++; - if (timeSinceLastActivity <= 120 * DAY) entry.samples.d_120++; - if (timeSinceLastActivity <= 90 * DAY) entry.samples.d_90++; - if (timeSinceLastActivity <= 60 * DAY) entry.samples.d_60++; - if (timeSinceLastActivity <= 30 * DAY) entry.samples.d_30++; - if (timeSinceLastActivity <= 7 * DAY) entry.samples.d_7++; - if (timeSinceLastActivity <= 1 * DAY) entry.samples.d_1++; + entry.samples!.total++; + if (timeSinceLastActivity <= 120 * DAY) entry.samples!.d_120++; + if (timeSinceLastActivity <= 90 * DAY) entry.samples!.d_90++; + if (timeSinceLastActivity <= 60 * DAY) entry.samples!.d_60++; + if (timeSinceLastActivity <= 30 * DAY) entry.samples!.d_30++; + if (timeSinceLastActivity <= 7 * DAY) entry.samples!.d_7++; + if (timeSinceLastActivity <= 1 * DAY) entry.samples!.d_1++; }); const dataWY = tanks.map((tank) => ({ @@ -191,7 +194,7 @@ async function postWork() { function sum(slicer: (data: DataPoint) => number) { return data.reduce( (accumulator, data) => accumulator + slicer(data), - 0 + 0, ); } diff --git a/packages/scripts/src/buildAssets/definitions.ts b/packages/scripts/src/buildAssets/definitions.ts index ba83125ae..84355caaf 100644 --- a/packages/scripts/src/buildAssets/definitions.ts +++ b/packages/scripts/src/buildAssets/definitions.ts @@ -81,16 +81,16 @@ const blitzTankFilterDefinitionCategoryToBlitzkit: Record< BlitzTankFilterDefinitionCategory, ConsumableTankCategoryFilterCategory > = { - clip: ConsumableTankCategoryFilterCategory.CLIP, + clip: ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP, }; function vector3TupleToBlitzkit(tuple: Vector3Tuple) { return { x: tuple[0], y: tuple[1], z: tuple[2] } satisfies Vector3; } const blitzTankClassToBlitzkit: Record = { - lightTank: TankClass.LIGHT, - "AT-SPG": TankClass.TANK_DESTROYER, - heavyTank: TankClass.HEAVY, - mediumTank: TankClass.MEDIUM, + lightTank: TankClass.TANK_CLASS_LIGHT, + "AT-SPG": TankClass.TANK_CLASS_TANK_DESTROYER, + heavyTank: TankClass.TANK_CLASS_HEAVY, + mediumTank: TankClass.TANK_CLASS_MEDIUM, }; export interface BlitzStrings { [key: string]: string; @@ -149,18 +149,18 @@ type BlitzModuleType = { type UnlocksListing = BlitzModuleType | undefined; type BlitzCrewType = "commander" | "radioman" | "gunner" | "driver" | "loader"; const blitzCrewTypeToBlitzkit: Record = { - commander: CrewType.COMMANDER, - driver: CrewType.DRIVER, - gunner: CrewType.GUNNER, - loader: CrewType.LOADER, - radioman: CrewType.RADIOMAN, + commander: CrewType.CREW_TYPE_COMMANDER, + driver: CrewType.CREW_TYPE_DRIVER, + gunner: CrewType.CREW_TYPE_GUNNER, + loader: CrewType.CREW_TYPE_LOADER, + radioman: CrewType.CREW_TYPE_RADIOMAN, }; const blitzkitCrewTypeToBlitz: Record = { - [CrewType.COMMANDER]: "commander", - [CrewType.DRIVER]: "driver", - [CrewType.GUNNER]: "gunner", - [CrewType.LOADER]: "loader", - [CrewType.RADIOMAN]: "radioman", + [CrewType.CREW_TYPE_COMMANDER]: "commander", + [CrewType.CREW_TYPE_DRIVER]: "driver", + [CrewType.CREW_TYPE_GUNNER]: "gunner", + [CrewType.CREW_TYPE_LOADER]: "loader", + [CrewType.CREW_TYPE_RADIOMAN]: "radioman", }; interface VehicleDefinitions { invisibility: { @@ -298,7 +298,7 @@ interface VehicleDefinitions { type: "default"; enabled: false; factorsModifiers: ""; - } + }, ]; }; }; @@ -517,18 +517,18 @@ type CombatRolesYaml = Record< >; const blitzShellKindToBlitzkit: Record = { - ARMOR_PIERCING: ShellType.AP, - ARMOR_PIERCING_CR: ShellType.APCR, - HIGH_EXPLOSIVE: ShellType.HE, - HOLLOW_CHARGE: ShellType.HEAT, + ARMOR_PIERCING: ShellType.SHELL_TYPE_AP, + ARMOR_PIERCING_CR: ShellType.SHELL_TYPE_APCR, + HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE, + HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT, }; export const botPattern = /^.+((tutorial_bot(\d+)?)|(TU))$/; const blitzModuleTypeToBlitzkit: Record = { - chassis: ModuleType.TRACKS, - engine: ModuleType.ENGINE, - gun: ModuleType.GUN, - turret: ModuleType.TURRET, - vehicle: ModuleType.VEHICLE, + chassis: ModuleType.MODULE_TYPE_TRACKS, + engine: ModuleType.MODULE_TYPE_ENGINE, + gun: ModuleType.MODULE_TYPE_GUN, + turret: ModuleType.MODULE_TYPE_TURRET, + vehicle: ModuleType.MODULE_TYPE_VEHICLE, }; export async function definitions() { @@ -555,10 +555,10 @@ export async function definitions() { const provisionDefinitions: ProvisionDefinitions = { provisions: {} }; const skillDefinitions: SkillDefinitions = { classes: { - [TankClass.LIGHT]: { skills: [] }, - [TankClass.MEDIUM]: { skills: [] }, - [TankClass.HEAVY]: { skills: [] }, - [TankClass.TANK_DESTROYER]: { skills: [] }, + [TankClass.TANK_CLASS_LIGHT]: { skills: [] }, + [TankClass.TANK_CLASS_MEDIUM]: { skills: [] }, + [TankClass.TANK_CLASS_HEAVY]: { skills: [] }, + [TankClass.TANK_CLASS_TANK_DESTROYER]: { skills: [] }, }, }; const nations = vfs @@ -566,7 +566,7 @@ export async function definitions() { .filter((nation) => nation !== "common"); const tankStringIdMap: Record = {}; const optionalDevices = await vfs.xml<{ root: OptionalDevices }>( - "Data/XML/item_defs/vehicles/common/optional_devices.xml" + "Data/XML/item_defs/vehicles/common/optional_devices.xml", ); const stringsI18n: Record> = {}; @@ -574,12 +574,12 @@ export async function definitions() { locales.supported.map(async ({ locale }) => { const blitzLocale = SUPPORTED_LOCALE_BLITZ_MAP[locale]; const cache = await fetch( - `https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml` + `https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`, ) .then((response) => response.text()) .then((string) => parseYaml(string) as BlitzStrings); const preInstalled = await vfs.yaml( - `Data/Strings/${blitzLocale}.yaml` + `Data/Strings/${blitzLocale}.yaml`, ); stringsI18n[locale] = { @@ -588,7 +588,7 @@ export async function definitions() { }; console.log(`Loaded strings for ${locale}`); - }) + }), ); function getString(name: string) { @@ -627,9 +627,9 @@ export async function definitions() { consumables, ( await vfs.xml<{ root: ConsumablesCommon }>( - `Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml` + `Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`, ) - ).root + ).root, ); } @@ -642,39 +642,39 @@ export async function definitions() { provisions, ( await vfs.xml<{ root: ConsumablesCommon }>( - `Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml` + `Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`, ) - ).root + ).root, ); } const avatar = await vfs.xml<{ root: Avatar }>( - `Data/XML/item_defs/tankmen/avatar.xml` + `Data/XML/item_defs/tankmen/avatar.xml`, ); const maps = await vfs.yaml(`Data/maps.yaml`); const tankXps = new Map(); const camouflagesXml = await vfs.xml<{ root: CamouflagesXML }>( - `Data/XML/item_defs/vehicles/common/camouflages.xml` + `Data/XML/item_defs/vehicles/common/camouflages.xml`, ); const camouflagesYaml = await vfs.yaml( - `Data/camouflages.yaml` + `Data/camouflages.yaml`, ); const camouflagesXmlEntries = Object.entries(camouflagesXml.root.camouflages); const squadBattleTypeStyles = await vfs.yaml( - `Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml` + `Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`, ); const gameTypeSelectorStyles = await vfs.yaml( - `Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml` + `Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`, ); const gameModeNativeNames: Record = {}; const combatRoles = await vfs.yaml( - `Data/XML/item_defs/vehicles/common/combat_roles.yaml` + `Data/XML/item_defs/vehicles/common/combat_roles.yaml`, ); const consumableNativeNames: Record = {}; const provisionNativeNames: Record = {}; for (const match of squadBattleTypeStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll( - /"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g + /"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g, )) { const id = Number(match[1]); const name = getString(match[2]); @@ -686,7 +686,7 @@ export async function definitions() { } for (const match of gameTypeSelectorStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll( - /eGameMode\.([a-zA-Z]+) -> "~res:\/Gfx\/UI\/Hangar\/GameTypes\/battle-type_([^"]+)"/g + /eGameMode\.([a-zA-Z]+) -> "~res:\/Gfx\/UI\/Hangar\/GameTypes\/battle-type_([^"]+)"/g, )) { Object.entries(gameModeNativeNames).forEach(([key, value]) => { if (key.toLowerCase() === match[2].toLowerCase()) { @@ -720,7 +720,7 @@ export async function definitions() { for (const nation of nations) { const tankList = await vfs.xml<{ root: VehicleDefinitionList }>( - `Data/XML/item_defs/vehicles/${nation}/list.xml` + `Data/XML/item_defs/vehicles/${nation}/list.xml`, ); for (const tankKey in tankList.root) { @@ -761,7 +761,7 @@ export async function definitions() { console.warn( `Multiple tanks share slug ${slug}: ${requesters .map(({ key }) => key) - .join(", ")}` + .join(", ")}`, ); if (requesters.length !== 2) { @@ -791,7 +791,7 @@ export async function definitions() { if (canonical === undefined) { throw new Error( - "Two tutorial bots share the same slug? The world is truly broken." + "Two tutorial bots share the same slug? The world is truly broken.", ); } @@ -804,7 +804,7 @@ export async function definitions() { for (const nation of nations) { const tankList = await vfs.xml<{ root: VehicleDefinitionList }>( - `Data/XML/item_defs/vehicles/${nation}/list.xml` + `Data/XML/item_defs/vehicles/${nation}/list.xml`, ); const turretList = await vfs.xml<{ root: TurretDefinitionsList; @@ -857,7 +857,7 @@ export async function definitions() { : Number(item.cost.split(":")[1]), }, } satisfies Unlock; - }) + }), ) .flat(); } @@ -872,10 +872,10 @@ export async function definitions() { const tank = tankList.root[tankKey]; let tankPrice: TankPrice; const tankDefinition = await vfs.xml<{ root: VehicleDefinitions }>( - `Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml` + `Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml`, ); const tankParameters = await vfs.yaml( - `Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml` + `Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`, ); const turretOrigin = tankDefinition.root.hull.turretPositions.turret .split(" ") @@ -890,23 +890,23 @@ export async function definitions() { if (slug === undefined) { throw new Error( - `Could not find slug for ${nation}/${tankKey} (${tankId})` + `Could not find slug for ${nation}/${tankKey} (${tankId})`, ); } if (tank.sellPrice) { tankPrice = { - type: TankPriceType.GOLD, + type: TankPriceType.TANK_PRICE_TYPE_GOLD, value: tank.sellPrice["#text"] * 2, }; } else if (typeof tank.price === "number") { tankPrice = { - type: TankPriceType.CREDITS, + type: TankPriceType.TANK_PRICE_TYPE_CREDITS, value: tank.price, }; } else { tankPrice = { - type: TankPriceType.CREDITS, + type: TankPriceType.TANK_PRICE_TYPE_CREDITS, value: tank.price["#text"] * 400, }; } @@ -938,7 +938,7 @@ export async function definitions() { Object.entries(tankDefinition.root.crew).forEach(([crewKey, value]) => { let entry: Crew; const index = crew.findIndex( - ({ type }) => blitzkitCrewTypeToBlitz[type] === crewKey + ({ type }) => blitzkitCrewTypeToBlitz[type] === crewKey, ); if (index === -1) { if (crewKey === "#text") return; @@ -992,6 +992,7 @@ export async function definitions() { ancestors: [], successors: [], id: tankId, + dev_name: tankKey, roles: {}, camouflages: camouflages, fixed_camouflage: fixedCamouflage, @@ -1011,10 +1012,10 @@ export async function definitions() { slug, nation, type: tankTags.includes("collectible") - ? TankType.COLLECTOR + ? TankType.TANK_TYPE_COLLECTOR : (typeof tank.price === "number" ? false : "gold" in tank.price) - ? TankType.PREMIUM - : TankType.RESEARCHABLE, + ? TankType.TANK_TYPE_PREMIUM + : TankType.TANK_TYPE_RESEARCHABLE, tier: tank.level, class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass], testing: tankTags.includes("testTank"), @@ -1022,7 +1023,7 @@ export async function definitions() { price: tankPrice, camouflage_still: tankDefinition.root.invisibility.still, camouflage_moving: tankDefinition.root.invisibility.moving, - camouflage_onFire: tankDefinition.root.invisibility.firePenalty, + camouflage_on_fire: tankDefinition.root.invisibility.firePenalty, turrets: [], engines: [], tracks: [], @@ -1031,12 +1032,12 @@ export async function definitions() { if (tank.combatRole) { Object.entries(tank.combatRole).forEach(([gameMode, role]) => { const id = Object.entries(gameModeNativeNames).find( - ([key]) => key.toLowerCase() === gameMode.toLowerCase() + ([key]) => key.toLowerCase() === gameMode.toLowerCase(), )?.[1]; if (id === undefined) { throw new Error( - `Unknown game mode in tank ${tankKey}: ${gameMode}` + `Unknown game mode in tank ${tankKey}: ${gameMode}`, ); } @@ -1118,7 +1119,7 @@ export async function definitions() { (turretKey, turretIndex) => { const turret = tankDefinition.root.turrets0[turretKey]; const turretModel = Number( - parsePath(turret.models.undamaged).name.split("_")[1] + parsePath(turret.models.undamaged).name.split("_")[1], ); const turretId = toUniqueId(nation, turretList.root.ids[turretKey]); const turretYaw = ( @@ -1186,12 +1187,12 @@ export async function definitions() { min: vector3TupleToBlitzkit( tankParameters.collision[ parsePath(turret.hitTester.collisionModel).name.toLowerCase() - ].bbox.min + ].bbox.min, ), max: vector3TupleToBlitzkit( tankParameters.collision[ parsePath(turret.hitTester.collisionModel).name.toLowerCase() - ].bbox.max + ].bbox.max, ), }, }; @@ -1209,7 +1210,7 @@ export async function definitions() { .split(" ") .map(Number) as [number, number]; const gunModel = Number( - parsePath(gun.models.undamaged).name.split("_")[1] + parsePath(gun.models.undamaged).name.split("_")[1], ); const gunName = getString(gunListEntry.userString); const gunType = @@ -1332,24 +1333,24 @@ export async function definitions() { }, } : gunType === "autoReloader" - ? { - $case: "auto_reloader", - value: { - intra_clip: 60 / gun.clip!.rate, - shell_count: gunClipCount, - shell_reloads: gun - .pumpGunReloadTimes!.split(" ") - .map(Number), + ? { + $case: "auto_reloader", + value: { + intra_clip: 60 / gun.clip!.rate, + shell_count: gunClipCount, + shell_reloads: gun + .pumpGunReloadTimes!.split(" ") + .map(Number), + }, + } + : { + $case: "auto_loader", + value: { + intra_clip: 60 / gun.clip!.rate, + clip_reload: gun.reloadTime, + shell_count: gunClipCount, + }, }, - } - : { - $case: "auto_loader", - value: { - intra_clip: 60 / gun.clip!.rate, - clip_reload: gun.reloadTime, - shell_count: gunClipCount, - }, - }, } satisfies GunDefinition); modelDefinitions.models[tankId].turrets[turretId].guns[gunId] = { @@ -1360,8 +1361,8 @@ export async function definitions() { gun.armor.gun === undefined ? 0 : typeof gun.armor.gun === "number" - ? gun.armor.gun - : gun.armor.gun["#text"], + ? gun.armor.gun + : gun.armor.gun["#text"], pitch: { min: gunPitch[0], max: gunPitch[1], @@ -1408,7 +1409,7 @@ export async function definitions() { type: blitzShellKindToBlitzkit[shell.kind], explosion_radius: shell.kind === "HIGH_EXPLOSIVE" - ? shell.explosionRadius ?? 0 + ? (shell.explosionRadius ?? 0) : undefined, icon: shell.icon, penetration: { @@ -1419,7 +1420,7 @@ export async function definitions() { }); }); }); - } + }, ); totalUnlocks.forEach((unlocks) => { @@ -1447,7 +1448,7 @@ export async function definitions() { case "gun": { gunXps.set( toUniqueId(nation, gunList.root.ids[vehicle["#text"]]), - parseResearchCost(vehicle.cost) + parseResearchCost(vehicle.cost), ); break; } @@ -1455,7 +1456,7 @@ export async function definitions() { case "turret": { turretXps.set( toUniqueId(nation, turretList.root.ids[vehicle["#text"]]), - parseResearchCost(vehicle.cost) + parseResearchCost(vehicle.cost), ); break; } @@ -1463,7 +1464,7 @@ export async function definitions() { case "engine": { engineXps.set( toUniqueId(nation, enginesList.root.ids[vehicle["#text"]]), - parseResearchCost(vehicle.cost) + parseResearchCost(vehicle.cost), ); break; } @@ -1471,7 +1472,7 @@ export async function definitions() { case "chassis": { trackXps.set( toUniqueId(nation, chassisList.root.ids[vehicle["#text"]]), - parseResearchCost(vehicle.cost) + parseResearchCost(vehicle.cost), ); break; } @@ -1518,7 +1519,7 @@ export async function definitions() { name: getString(optionalDeviceEntry.userString), description: getString(optionalDeviceEntry.description), }; - } + }, ); Object.entries(optionalDeviceSlots.root.presets).forEach( @@ -1537,7 +1538,7 @@ export async function definitions() { }) .flat(), }; - } + }, ); Object.entries(consumables).forEach(([key, consumable]) => { @@ -1620,7 +1621,7 @@ export async function definitions() { (item) => blitzTankFilterDefinitionCategoryToBlitzkit[ item as BlitzTankFilterDefinitionCategory - ] + ], ), }, }, @@ -1718,7 +1719,7 @@ export async function definitions() { (item) => blitzTankFilterDefinitionCategoryToBlitzkit[ item as BlitzTankFilterDefinitionCategory - ] + ], ), }, }, @@ -1749,11 +1750,11 @@ export async function definitions() { value.default_abilities.forEach((ability) => { if (ability in consumableNativeNames) { gameDefinitions.roles[value.id].consumables.push( - consumableNativeNames[ability] + consumableNativeNames[ability], ); } else if (ability in provisionNativeNames) { gameDefinitions.roles[value.id].provisions.push( - provisionNativeNames[ability] + provisionNativeNames[ability], ); } else throw new Error(`Unknown ability ${ability}`); }); diff --git a/packages/scripts/src/buildAssets/glossary.ts b/packages/scripts/src/buildAssets/glossary.ts index 1710f658a..ed3b83cfd 100644 --- a/packages/scripts/src/buildAssets/glossary.ts +++ b/packages/scripts/src/buildAssets/glossary.ts @@ -15,7 +15,7 @@ export async function glossary() { const glossary = await fetchGlossary(supported.blitz ?? supported.locale); console.log( - `Found ${Object.keys(glossary).length} things for ${supported.locale}` + `Found ${Object.keys(glossary).length} things for ${supported.locale}`, ); for (const key in glossary) { @@ -30,7 +30,7 @@ export async function glossary() { } if (key in avatars) { - avatars[key].avatar.name.locales[supported.locale] = + avatars[key].avatar.name!.locales[supported.locale] = glossaryEntry.title; } else { const extension = extname(glossaryEntry.image_url); @@ -45,7 +45,7 @@ export async function glossary() { }; } } - }) + }), ); const gallery: Gallery = { avatars: [] }; @@ -53,12 +53,12 @@ export async function glossary() { const bar = new ProgressBar( `Fetching avatars of ${totalCount} things :bar`, - totalCount + totalCount, ); await Promise.all( Object.entries(avatars).map(async ([key, { url, avatar }]) => { - if (!(locales.default in avatars[key].avatar.name.locales)) { + if (!(locales.default in avatars[key].avatar.name!.locales)) { console.warn(`Avatar ${key} has no ${locales.default} name`); bar.tick(); @@ -77,7 +77,7 @@ export async function glossary() { }); bar.tick(); - }) + }), ); await uploader.add({ diff --git a/packages/scripts/src/core/blitz/writeDVPL.ts b/packages/scripts/src/core/blitz/writeDVPL.ts index 6925f3f4a..140db8dc8 100644 --- a/packages/scripts/src/core/blitz/writeDVPL.ts +++ b/packages/scripts/src/core/blitz/writeDVPL.ts @@ -1,5 +1,5 @@ -import { crc32 } from 'crc'; -import { compressBlock } from 'lz4js'; +import { crc32 } from "crc"; +import { compressBlock } from "lz4js"; /** * Thanks Maddoxkkm! Modernized heavily. @@ -14,7 +14,7 @@ export function writeDVPL(buffer: Buffer) { destination, 0, source.length, - 0, + [0], ); let output = Buffer.from(destination); @@ -58,7 +58,7 @@ function toDVPLFooter( result.writeUInt32LE(compressedSize, 4); result.writeUInt32LE(crc32, 8); result.writeUInt32LE(type, 12); - result.write('DVPL', 16, 4, 'utf8'); + result.write("DVPL", 16, 4, "utf8"); return result; } diff --git a/packages/scripts/src/core/vfs/steam.ts b/packages/scripts/src/core/vfs/steam.ts index a1432d382..f5dfc25e9 100644 --- a/packages/scripts/src/core/vfs/steam.ts +++ b/packages/scripts/src/core/vfs/steam.ts @@ -38,7 +38,7 @@ export class SteamVFS extends AbstractVFS { private username: string, private password: string, private app: number, - private depot: number + private depot: number, ) { super(); } @@ -57,13 +57,14 @@ export class SteamVFS extends AbstractVFS { this.steam.getManifest( this.app, this.depot, + // @ts-expect-error productInfo.apps[this.app].appinfo.depots[this.depot].manifests.public .gid, "public", // @ts-expect-error (_, response) => { resolve(response); - } + }, ); }); diff --git a/packages/scripts/src/patchNotes.ts b/packages/scripts/src/patchNotes.ts index 9f132b3bf..42fe4f190 100644 --- a/packages/scripts/src/patchNotes.ts +++ b/packages/scripts/src/patchNotes.ts @@ -53,7 +53,7 @@ if (newTanks.length > 0) { notes += "## New Tanks\n\n"; for (const tank of newTanks) { - notes += `### [${tank.name.locales.en}](${domain}/tanks/${tank.slug})\n`; + notes += `### [${tank.name!.locales.en}](${domain}/tanks/${tank.slug})\n`; notes += `![](${tankIcon(tank.id)})\n\n`; } @@ -96,49 +96,49 @@ if (changedTanks.length > 0) { const previewTankModel = previewModelDefinitions.models[preview.id]; const currentConsumables = Object.values( - currentConsumableDefinitions.consumables + currentConsumableDefinitions.consumables, ).filter((consumable) => - checkConsumableProvisionInclusivity(consumable, current, currentGun) + checkConsumableProvisionInclusivity(consumable, current, currentGun), ); const previewConsumables = Object.values( - previewConsumableDefinitions.consumables + previewConsumableDefinitions.consumables, ).filter((consumable) => - checkConsumableProvisionInclusivity(consumable, preview, previewGun) + checkConsumableProvisionInclusivity(consumable, preview, previewGun), ); const addedConsumables = previewConsumables.filter( (previewConsumable) => !currentConsumables.some( - (currentConsumable) => currentConsumable.id === previewConsumable.id - ) + (currentConsumable) => currentConsumable.id === previewConsumable.id, + ), ); const removedConsumables = currentConsumables.filter( (currentConsumable) => !previewConsumables.some( - (previewConsumable) => previewConsumable.id === currentConsumable.id - ) + (previewConsumable) => previewConsumable.id === currentConsumable.id, + ), ); const currentProvisions = availableProvisions( current, currentGun, - currentProvisionDefinitions + currentProvisionDefinitions, ); const previewProvisions = availableProvisions( preview, previewGun, - previewProvisionDefinitions + previewProvisionDefinitions, ); const addedProvisions = previewProvisions.filter( (previewProvision) => !currentProvisions.some( - (currentProvision) => currentProvision.id === previewProvision.id - ) + (currentProvision) => currentProvision.id === previewProvision.id, + ), ); const removedProvisions = currentProvisions.filter( (currentProvision) => !previewProvisions.some( - (previewProvision) => previewProvision.id === currentProvision.id - ) + (previewProvision) => previewProvision.id === currentProvision.id, + ), ); const currentEquipment = currentEquipmentDefinitions.presets[ @@ -155,16 +155,16 @@ if (changedTanks.length > 0) { .filter( (previewEquipment) => !currentEquipment.some( - (currentEquipment) => currentEquipment === previewEquipment - ) + (currentEquipment) => currentEquipment === previewEquipment, + ), ) .map((id) => previewEquipmentDefinitions.equipments[id]); const removedEquipment = currentEquipment .filter( (currentEquipment) => !previewEquipment.some( - (previewEquipment) => previewEquipment === currentEquipment - ) + (previewEquipment) => previewEquipment === currentEquipment, + ), ) .map((id) => currentEquipmentDefinitions.equipments[id]); @@ -184,7 +184,7 @@ if (changedTanks.length > 0) { provisions: createDefaultProvisions( current, currentGun, - currentProvisionDefinitions + currentProvisionDefinitions, ), equipmentMatrix: genericDefaultEquipmentMatrix, stockEngine: current.engines[0], @@ -198,7 +198,7 @@ if (changedTanks.length > 0) { equipmentDefinitions: currentEquipmentDefinitions, provisionDefinitions: currentProvisionDefinitions, tankModelDefinition: currentTankModel, - } + }, ); const previewCharacteristics = tankCharacteristics( { @@ -216,7 +216,7 @@ if (changedTanks.length > 0) { provisions: createDefaultProvisions( preview, previewGun, - previewProvisionDefinitions + previewProvisionDefinitions, ), equipmentMatrix: genericDefaultEquipmentMatrix, stockEngine: preview.engines[0], @@ -230,7 +230,7 @@ if (changedTanks.length > 0) { equipmentDefinitions: previewEquipmentDefinitions, provisionDefinitions: previewProvisionDefinitions, tankModelDefinition: previewTankModel, - } + }, ); const changedCharacteristics: string[] = []; @@ -244,17 +244,17 @@ if (changedTanks.length > 0) { } } - notes += `### [${preview.name.locales.en}](${domain}/tanks/${preview.slug})\n`; + notes += `### [${preview.name!.locales.en}](${domain}/tanks/${preview.slug})\n`; notes += `![](${tankIcon(preview.id)})\n\n`; if (addedConsumables.length + removedConsumables.length > 0) { notes += `Consumables: `; notes += [ ...addedConsumables.map( - (consumable) => `🟒 ${consumable.name.locales.en}` + (consumable) => `🟒 ${consumable.name!.locales.en}`, ), ...removedConsumables.map( - (consumable) => `πŸ”΄ ${consumable.name.locales.en}` + (consumable) => `πŸ”΄ ${consumable.name!.locales.en}`, ), ].join(", "); notes += `\n`; @@ -264,10 +264,10 @@ if (changedTanks.length > 0) { notes += `Provisions: `; notes += [ ...addedProvisions.map( - (provision) => `🟒 ${provision.name.locales.en}` + (provision) => `🟒 ${provision.name!.locales.en}`, ), ...removedProvisions.map( - (provision) => `πŸ”΄ ${provision.name.locales.en}` + (provision) => `πŸ”΄ ${provision.name!.locales.en}`, ), ].join(", "); notes += `\n`; @@ -276,9 +276,11 @@ if (changedTanks.length > 0) { if (addedEquipment.length + removedEquipment.length > 0) { notes += `-Equipment: `; notes += [ - ...addedEquipment.map((equipment) => `🟒 ${equipment.name.locales.en}`), + ...addedEquipment.map( + (equipment) => `🟒 ${equipment.name!.locales.en}`, + ), ...removedEquipment.map( - (equipment) => `πŸ”΄ ${equipment.name.locales.en}` + (equipment) => `πŸ”΄ ${equipment.name!.locales.en}`, ), ].join(", "); notes += `\n`; diff --git a/packages/scripts/src/reviews.ts b/packages/scripts/src/reviews.ts index 1eca4395b..0c2a07e55 100644 --- a/packages/scripts/src/reviews.ts +++ b/packages/scripts/src/reviews.ts @@ -43,7 +43,7 @@ for (const tank of tanksSanitized) { } try { - const q = `World of Tanks Blitz ${tank.name.locales[locales.default]}`; + const q = `World of Tanks Blitz ${tank.name!.locales[locales.default]}`; const results = await youtube.search.list({ part: ["snippet"], @@ -74,7 +74,7 @@ for (const tank of tanksSanitized) { }; console.log( - `${++done} done; found ${items.length} for ${tank.name.locales.en}`, + `${++done} done; found ${items.length} for ${tank.name!.locales.en}`, ); await new Promise((resolve) => setTimeout(resolve, 1000 / 5)); diff --git a/packages/website/src/components/Armor/components/ArmorPlateDisplay.tsx b/packages/website/src/components/Armor/components/ArmorPlateDisplay.tsx index 80e54eda4..ab7a7814e 100644 --- a/packages/website/src/components/Armor/components/ArmorPlateDisplay.tsx +++ b/packages/website/src/components/Armor/components/ArmorPlateDisplay.tsx @@ -1,11 +1,5 @@ import { ReloadIcon } from "@radix-ui/react-icons"; -import { - Card, - Flex, - IconButton, - Text, - TextField, -} from "@radix-ui/themes"; +import { Card, Flex, IconButton, Text, TextField } from "@radix-ui/themes"; import { Html } from "@react-three/drei"; import { useRef } from "react"; import { radToDeg } from "three/src/math/MathUtils.js"; @@ -107,12 +101,12 @@ export function ArmorPlateDisplay() { const track = tank.tracks[protagonist.track.id]; if (highlightArmor.name.startsWith("hull_")) { - tank.armor.thickness[index] = thickness; + tank.armor!.thickness[index] = thickness; } else if (highlightArmor.name.startsWith("turret_")) { - turret.armor.thickness[index] = thickness; + turret.armor!.thickness[index] = thickness; } else if (highlightArmor.name.startsWith("gun_")) { if (highlightArmor.name.includes("_armor_")) { - gun.armor.thickness[index] = thickness; + gun.armor!.thickness[index] = thickness; } else { gun.thickness = thickness; } @@ -162,15 +156,15 @@ export function ArmorPlateDisplay() { initialTank.tracks[protagonist.track.id]; if (highlightArmor.name.startsWith("hull_")) { - tank.armor.thickness[index] = - initialTank.armor.thickness[index]; + tank.armor!.thickness[index] = + initialTank.armor!.thickness[index]; } else if (highlightArmor.name.startsWith("turret_")) { - turret.armor.thickness[index] = - initialTurret.armor.thickness[index]; + turret.armor!.thickness[index] = + initialTurret.armor!.thickness[index]; } else if (highlightArmor.name.startsWith("gun_")) { if (highlightArmor.name.includes("_armor_")) { - gun.armor.thickness[index] = - initialGun.armor.thickness[index]; + gun.armor!.thickness[index] = + initialGun.armor!.thickness[index]; } else { gun.thickness = initialGun.thickness; } diff --git a/packages/website/src/components/Armor/components/PrimaryArmorScene.tsx b/packages/website/src/components/Armor/components/PrimaryArmorScene.tsx index acc4b125c..144240a11 100644 --- a/packages/website/src/components/Armor/components/PrimaryArmorScene.tsx +++ b/packages/website/src/components/Armor/components/PrimaryArmorScene.tsx @@ -24,11 +24,11 @@ export const PrimaryArmorScene = memo(() => { const trackModelDefinition = tankModelDefinition.tracks[track.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const gunModelDefinition = turretModelDefinition.guns[gun.id]; - const hullOrigin = correctZYTuple(trackModelDefinition.origin); - const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin); - const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin); + const hullOrigin = correctZYTuple(trackModelDefinition.origin!); + const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!); + const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!); const isDynamicArmorActive = Duel.use((state) => - state.protagonist.consumables.includes(73) + state.protagonist.consumables.includes(73), ); useTankTransform(track, turret, turretContainer, gunContainer); @@ -41,8 +41,8 @@ export const PrimaryArmorScene = memo(() => { const isVisible = isHull; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - tankModelDefinition.armor, - armorId + tankModelDefinition.armor!, + armorId, ); if ( @@ -69,13 +69,13 @@ export const PrimaryArmorScene = memo(() => { const isCurrentTurret = node.name.startsWith( `turret_${turretModelDefinition.model_id .toString() - .padStart(2, "0")}` + .padStart(2, "0")}`, ); const isVisible = isCurrentTurret; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - turretModelDefinition.armor, - armorId + turretModelDefinition.armor!, + armorId, ); if ( @@ -103,13 +103,13 @@ export const PrimaryArmorScene = memo(() => { {armorNodes.map((node) => { const isCurrentGun = node.name.startsWith( - `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}` + `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentGun; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - gunModelDefinition.armor, - armorId + gunModelDefinition.armor!, + armorId, ); if ( diff --git a/packages/website/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx b/packages/website/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx index 866299ec5..3fa4d6509 100644 --- a/packages/website/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx +++ b/packages/website/src/components/Armor/components/PrimaryArmorSceneComponent/index.tsx @@ -88,10 +88,10 @@ export function PrimaryArmorSceneComponent({ material.uniforms.caliber.value = shell.caliber; material.uniforms.ricochet.value = degToRad( - isExplosive(shell.type) ? 90 : shell.ricochet! + isExplosive(shell.type) ? 90 : shell.ricochet!, ); material.uniforms.normalization.value = degToRad( - shell.normalization ?? 0 + shell.normalization ?? 0, ); material.uniforms.isExplosive.value = isExplosive(shell.type); material.uniforms.canSplash.value = canSplash(shell.type); @@ -100,11 +100,11 @@ export function PrimaryArmorSceneComponent({ handleProtagonistEquipmentChange( Duel.state.protagonist.equipmentMatrix, - true + true, ); handleAntagonistEquipmentChange( Duel.state.antagonist.equipmentMatrix, - true + true, ); invalidate(); @@ -124,12 +124,12 @@ export function PrimaryArmorSceneComponent({ } function handleProtagonistEquipmentChange( equipment: EquipmentMatrix, - noInvalidate = false + noInvalidate = false, ) { const hasEnhancedArmor = hasEquipment( 110, Duel.state.protagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.thickness.value = hasEnhancedArmor ? thickness * 1.03 @@ -139,16 +139,16 @@ export function PrimaryArmorSceneComponent({ } function handleAntagonistEquipmentChange( equipment: EquipmentMatrix, - noInvalidate = false + noInvalidate = false, ) { const tankopediaEphemeral = Tankopedia.state; const shell = tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell; - const penetration = shell.penetration.near; + const penetration = shell.penetration!.near; const hasCalibratedShells = hasEquipment( 103, Duel.state.antagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.penetration.value = @@ -165,7 +165,7 @@ export function PrimaryArmorSceneComponent({ handleShellChange(); handleGreenPenetrationChange(TankopediaPersistent.state.greenPenetration); handleAdvancedHighlightingChange( - TankopediaPersistent.state.advancedHighlighting + TankopediaPersistent.state.advancedHighlighting, ); handleOpaqueChange(TankopediaPersistent.state.opaque); handleWireframeChange(TankopediaPersistent.state.wireframe); @@ -179,20 +179,20 @@ export function PrimaryArmorSceneComponent({ Tankopedia.on((state) => state.customShell, handleShellChange), TankopediaPersistent.on( (state) => state.greenPenetration, - handleGreenPenetrationChange + handleGreenPenetrationChange, ), TankopediaPersistent.on( (state) => state.advancedHighlighting, - handleAdvancedHighlightingChange + handleAdvancedHighlightingChange, ), TankopediaPersistent.on((state) => state.opaque, handleOpaqueChange), Duel.on( (state) => state.protagonist.equipmentMatrix, - (equipment) => handleProtagonistEquipmentChange(equipment) + (equipment) => handleProtagonistEquipmentChange(equipment), ), Duel.on( (state) => state.antagonist.equipmentMatrix, - (equipment) => handleAntagonistEquipmentChange(equipment) + (equipment) => handleAntagonistEquipmentChange(equipment), ), () => transitionEvent.off(handleTransitionEvent), ]; @@ -204,7 +204,7 @@ export function PrimaryArmorSceneComponent({ useFrame(({ gl, camera }) => { gl.getSize(material.uniforms.resolution.value).multiplyScalar( - gl.getPixelRatio() + gl.getPixelRatio(), ); material.uniforms.spacedArmorBuffer.value = spacedArmorRenderTarget.texture; material.uniforms.spacedArmorDepth.value = diff --git a/packages/website/src/components/Armor/components/SpacedArmorScene.tsx b/packages/website/src/components/Armor/components/SpacedArmorScene.tsx index 50cc38348..9b4110be7 100644 --- a/packages/website/src/components/Armor/components/SpacedArmorScene.tsx +++ b/packages/website/src/components/Armor/components/SpacedArmorScene.tsx @@ -37,15 +37,15 @@ export const SpacedArmorScene = memo(({ scene }) => { const trackModelDefinition = tankModelDefinition.tracks[track.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const gunModelDefinition = turretModelDefinition.guns[gun.id]; - const hullOrigin = correctZYTuple(trackModelDefinition.origin); - const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin); - const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin); + const hullOrigin = correctZYTuple(trackModelDefinition.origin!); + const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!); + const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!); const maskOrigin = gunModelDefinition.mask === undefined ? undefined : gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y; const isDynamicArmorActive = Duel.use((state) => - state.protagonist.consumables.includes(73) + state.protagonist.consumables.includes(73), ); useTankTransform(track, turret, turretContainer, gunContainer); @@ -58,8 +58,8 @@ export const SpacedArmorScene = memo(({ scene }) => { const isVisible = isHull; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - tankModelDefinition.armor, - armorId + tankModelDefinition.armor!, + armorId, ); if ( @@ -104,13 +104,13 @@ export const SpacedArmorScene = memo(({ scene }) => { {armorNodes.map((node) => { const isCurrentTurret = node.name.startsWith( - `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}` + `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentTurret; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - turretModelDefinition.armor, - armorId + turretModelDefinition.armor!, + armorId, ); if ( @@ -139,13 +139,13 @@ export const SpacedArmorScene = memo(({ scene }) => { {armorNodes.map((node) => { const isCurrentGun = node.name.startsWith( - `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}` + `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentGun; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - gunModelDefinition.armor, - armorId + gunModelDefinition.armor!, + armorId, ); if ( diff --git a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubExternal/index.tsx b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubExternal/index.tsx index 7e1e22390..b7b0e6434 100644 --- a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubExternal/index.tsx +++ b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubExternal/index.tsx @@ -50,13 +50,13 @@ export function SpacedArmorSubExternal({ const tankopediaEphemeral = Tankopedia.state; const shell = tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell; - material.uniforms.penetration.value = shell.penetration.near; + material.uniforms.penetration.value = shell.penetration!.near; } function handleProtagonistEquipmentChange(equipment: EquipmentMatrix) { const hasEnhancedArmor = hasEquipment( 110, Duel.state.protagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.thickness.value = hasEnhancedArmor ? thickness * 1.03 @@ -66,11 +66,11 @@ export function SpacedArmorSubExternal({ const tankopediaEphemeral = Tankopedia.state; const shell = tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell; - const penetration = shell.penetration.near; + const penetration = shell.penetration!.near; const hasCalibratedShells = hasEquipment( 103, Duel.state.antagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.penetration.value = @@ -87,11 +87,11 @@ export function SpacedArmorSubExternal({ Tankopedia.on((state) => state.customShell, handleShellChange), Duel.on( (state) => state.protagonist.equipmentMatrix, - handleProtagonistEquipmentChange + handleProtagonistEquipmentChange, ), Duel.on( (state) => state.antagonist.equipmentMatrix, - handleAntagonistEquipmentChange + handleAntagonistEquipmentChange, ), ]; diff --git a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubSpaced/index.tsx b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubSpaced/index.tsx index 6e451c9e1..f72519b55 100644 --- a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubSpaced/index.tsx +++ b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/components/SpacedArmorSubSpaced/index.tsx @@ -53,20 +53,20 @@ export function SpacedArmorSubSpaced({ const shell = tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell; - material.uniforms.penetration.value = shell.penetration.near; + material.uniforms.penetration.value = shell.penetration!.near; material.uniforms.caliber.value = shell.caliber; material.uniforms.ricochet.value = degToRad( - isExplosive(shell.type) ? 90 : shell.ricochet! + isExplosive(shell.type) ? 90 : shell.ricochet!, ); material.uniforms.normalization.value = degToRad( - shell.normalization ?? 0 + shell.normalization ?? 0, ); } function handleProtagonistEquipmentChange(equipment: EquipmentMatrix) { const hasEnhancedArmor = hasEquipment( 110, Duel.state.protagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.thickness.value = hasEnhancedArmor ? thickness * 1.03 @@ -76,11 +76,11 @@ export function SpacedArmorSubSpaced({ const tankopediaEphemeral = Tankopedia.state; const shell = tankopediaEphemeral.customShell ?? Duel.state.antagonist.shell; - const penetration = shell.penetration.near; + const penetration = shell.penetration!.near; const hasCalibratedShells = hasEquipment( 103, Duel.state.antagonist.tank.equipment_preset, - equipment + equipment, ); material.uniforms.penetration.value = @@ -97,11 +97,11 @@ export function SpacedArmorSubSpaced({ Tankopedia.on((state) => state.customShell, handleShellChange), Duel.on( (state) => state.protagonist.equipmentMatrix, - handleProtagonistEquipmentChange + handleProtagonistEquipmentChange, ), Duel.on( (state) => state.antagonist.equipmentMatrix, - handleAntagonistEquipmentChange + handleAntagonistEquipmentChange, ), ]; diff --git a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx index 4c42180fc..07957a644 100644 --- a/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx +++ b/packages/website/src/components/Armor/components/SpacedArmorSceneComponent/index.tsx @@ -83,16 +83,18 @@ export function SpacedArmorSceneComponent({ point: Vector3, intersections: Intersection[], allowRicochet: boolean, - remainingPenetrationInput?: number + remainingPenetrationInput?: number, ) => { const { customShell } = Tankopedia.state; const shell = customShell ?? Duel.state.antagonist.shell; const cameraNormal = camera.position.clone().sub(point).normalize(); const shot: Shot = { splashRadius: - shell.type === ShellType.HE ? shell.explosion_radius : undefined, + shell.type === ShellType.SHELL_TYPE_HE + ? shell.explosion_radius + : undefined, damage: -1, - containsGaps: shell.type === ShellType.HEAT, + containsGaps: shell.type === ShellType.SHELL_TYPE_HEAT, in: { surfaceNormal: cameraNormal, layers: [], @@ -103,21 +105,21 @@ export function SpacedArmorSceneComponent({ const hasCalibratedShells = hasEquipment( 103, Duel.state.antagonist.tank.equipment_preset, - Duel.state.antagonist.equipmentMatrix + Duel.state.antagonist.equipmentMatrix, ); const hasEnhancedArmor = hasEquipment( 110, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const penetration = - shell.penetration.near * + shell.penetration!.near * resolvePenetrationCoefficient(hasCalibratedShells, shell.type); const thicknessCoefficient = hasEnhancedArmor ? 1.03 : 1; const filteredIntersections = intersections.filter( (intersection) => "type" in intersection.object.userData && - !discardClippingPlane(intersection.object, intersection.point) + !discardClippingPlane(intersection.object, intersection.point), ) as unknown as Intersection[]; const encounteredExternalModuleVariants: ExternalModuleVariant[] = []; const noDuplicateIntersections: typeof filteredIntersections = []; @@ -126,12 +128,12 @@ export function SpacedArmorSceneComponent({ if (intersection.object.userData.type === ArmorType.External) { if ( !encounteredExternalModuleVariants.includes( - intersection.object.userData.variant + intersection.object.userData.variant, ) ) { noDuplicateIntersections.push(intersection); encounteredExternalModuleVariants.push( - intersection.object.userData.variant + intersection.object.userData.variant, ); } } else { @@ -159,10 +161,10 @@ export function SpacedArmorSceneComponent({ const surfaceNormal = intersection .normal!.clone() .applyQuaternion( - intersection.object.getWorldQuaternion(new Quaternion()) + intersection.object.getWorldQuaternion(new Quaternion()), ); - if (shell.type === ShellType.HEAT && index > 0) { + if (shell.type === ShellType.SHELL_TYPE_HEAT && index > 0) { const lastLayer = shot.in.layers.at(-1) as ShotLayerBase; const distance = lastLayer.point.distanceTo(intersection.point); remainingPenetration -= 0.5 * remainingPenetration * distance; @@ -181,7 +183,7 @@ export function SpacedArmorSceneComponent({ const thickness = layer.thickness * thicknessCoefficient; remainingPenetration -= thickness; const blocked = - remainingPenetration <= 0 || shell.type === ShellType.HE; + remainingPenetration <= 0 || shell.type === ShellType.SHELL_TYPE_HE; shot.in.layers.push({ type: ArmorType.External, @@ -190,7 +192,7 @@ export function SpacedArmorSceneComponent({ point: intersection.point, surfaceNormal, status: - shell.type === ShellType.HE + shell.type === ShellType.SHELL_TYPE_HE ? "blocked" : blocked ? "blocked" @@ -200,7 +202,7 @@ export function SpacedArmorSceneComponent({ } else { const thickness = layer.thickness * thicknessCoefficient; const ricochet = degToRad( - isExplosive(shell.type) ? 90 : shell.ricochet! + isExplosive(shell.type) ? 90 : shell.ricochet!, ); const angle = surfaceNormal.angleTo(cameraNormal); @@ -241,7 +243,8 @@ export function SpacedArmorSceneComponent({ point: intersection.point, surfaceNormal: intersection.face!.normal, status: - shell.type === ShellType.HE && layer.type !== ArmorType.Primary + shell.type === ShellType.SHELL_TYPE_HE && + layer.type !== ArmorType.Primary ? "blocked" : blocked ? "blocked" @@ -251,7 +254,10 @@ export function SpacedArmorSceneComponent({ } } - if (shell.type !== ShellType.HE && remainingPenetration <= 0) { + if ( + shell.type !== ShellType.SHELL_TYPE_HE && + remainingPenetration <= 0 + ) { break; } @@ -266,7 +272,7 @@ export function SpacedArmorSceneComponent({ if (!lastLayer || !firstLayer) { return null; } else { - if (shell.type === ShellType.HE) { + if (shell.type === ShellType.SHELL_TYPE_HE) { const totalSpacedArmorThickness = shot.in.layers.reduce( (acc, layer) => { if (layer.type === null || layer.type === ArmorType.Primary) { @@ -279,10 +285,10 @@ export function SpacedArmorSceneComponent({ return acc + layer.thicknessAngled; }, - 0 + 0, ); const distanceFromSpacedArmor = firstLayer.point.distanceTo( - lastLayer.point + lastLayer.point, ); const finalDamage = Math.max( 0, @@ -291,7 +297,7 @@ export function SpacedArmorSceneComponent({ (1 - distanceFromSpacedArmor / shell.explosion_radius!) - 1.1 * (lastLayer.thicknessAngled + - Math.min(penetration, totalSpacedArmorThickness)) + Math.min(penetration, totalSpacedArmorThickness)), ); /** @@ -328,20 +334,20 @@ export function SpacedArmorSceneComponent({ .sub( lastLayer.surfaceNormal .clone() - .multiplyScalar(2 * shellNormal.dot(lastLayer.surfaceNormal)) + .multiplyScalar(2 * shellNormal.dot(lastLayer.surfaceNormal)), ); caster.set(lastLayer.point, ricochetNormal); const ricochetIntersections = caster.intersectObjects( props.scene.children, - true + true, ); const outShot = shoot( lastLayer.point, ricochetIntersections, false, - remainingPenetration + remainingPenetration, ); shot.in.status = "ricochet"; @@ -363,7 +369,7 @@ export function SpacedArmorSceneComponent({ return shot; }, - [camera] + [camera], ); return ( diff --git a/packages/website/src/components/Armor/components/StaticArmor.tsx b/packages/website/src/components/Armor/components/StaticArmor.tsx index 1363cb385..215220e35 100644 --- a/packages/website/src/components/Armor/components/StaticArmor.tsx +++ b/packages/website/src/components/Armor/components/StaticArmor.tsx @@ -43,9 +43,9 @@ export const StaticArmor = memo(({ thicknessRange }) => { const trackModelDefinition = tankModelDefinition.tracks[track.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const gunModelDefinition = turretModelDefinition.guns[gun.id]; - const hullOrigin = correctZYTuple(trackModelDefinition.origin); - const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin); - const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin); + const hullOrigin = correctZYTuple(trackModelDefinition.origin!); + const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!); + const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!); const canvas = useThree((state) => state.gl.domElement); const maskOrigin = @@ -53,16 +53,16 @@ export const StaticArmor = memo(({ thicknessRange }) => { ? undefined : gunModelDefinition.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y; const showPrimaryArmor = TankopediaPersistent.use( - (state) => state.showPrimaryArmor + (state) => state.showPrimaryArmor, ); const showSpacedArmor = TankopediaPersistent.use( - (state) => state.showSpacedArmor + (state) => state.showSpacedArmor, ); const showExternalModules = TankopediaPersistent.use( - (state) => state.showExternalModules + (state) => state.showExternalModules, ); const isDynamicArmorActive = Duel.use((state) => - state.protagonist.consumables.includes(73) + state.protagonist.consumables.includes(73), ); useTankTransform(track, turret, turretContainer, gunContainer); @@ -75,8 +75,8 @@ export const StaticArmor = memo(({ thicknessRange }) => { const isVisible = isHull; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - tankModelDefinition.armor, - armorId + tankModelDefinition.armor!, + armorId, ); if ( @@ -127,13 +127,13 @@ export const StaticArmor = memo(({ thicknessRange }) => { {armorNodes.map((node) => { const isCurrentTurret = node.name.startsWith( - `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}` + `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentTurret; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - turretModelDefinition.armor, - armorId + turretModelDefinition.armor!, + armorId, ); if ( @@ -168,12 +168,12 @@ export const StaticArmor = memo(({ thicknessRange }) => { const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const boundingRect = canvas.getBoundingClientRect(); @@ -184,10 +184,10 @@ export const StaticArmor = memo(({ thicknessRange }) => { modelTransformEvent.last!.pitch, modelTransformEvent.last!.yaw + delta.x * (Math.PI / boundingRect.width), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); } @@ -216,13 +216,13 @@ export const StaticArmor = memo(({ thicknessRange }) => { {armorNodes.map((node) => { const isCurrentGun = node.name.startsWith( - `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}` + `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentGun; const armorId = nameToArmorId(node.name); const { spaced, thickness } = resolveArmor( - gunModelDefinition.armor, - armorId + gunModelDefinition.armor!, + armorId, ); if ( @@ -256,12 +256,12 @@ export const StaticArmor = memo(({ thicknessRange }) => { const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const boundingRect = canvas.getBoundingClientRect(); delta.set(event.clientX, event.clientY).sub(position); @@ -272,10 +272,10 @@ export const StaticArmor = memo(({ thicknessRange }) => { delta.y * (Math.PI / boundingRect.height), modelTransformEvent.last!.yaw + delta.x * (Math.PI / boundingRect.width), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); } @@ -332,12 +332,12 @@ export const StaticArmor = memo(({ thicknessRange }) => { const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const boundingRect = canvas.getBoundingClientRect(); delta.set(event.clientX, event.clientY).sub(position); @@ -348,10 +348,10 @@ export const StaticArmor = memo(({ thicknessRange }) => { delta.y * (Math.PI / boundingRect.height), modelTransformEvent.last!.yaw + delta.x * (Math.PI / boundingRect.width), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); } diff --git a/packages/website/src/components/ClassIcon/index.ts b/packages/website/src/components/ClassIcon/index.ts index 018ee4cde..d21bd0fd2 100644 --- a/packages/website/src/components/ClassIcon/index.ts +++ b/packages/website/src/components/ClassIcon/index.ts @@ -1,16 +1,16 @@ -import { TankClass } from '@blitzkit/core'; -import type { ComponentProps, ReactNode } from 'react'; -import { ClassHeavy } from './components/ClassHeavy'; -import { ClassLight } from './components/ClassLight'; -import { ClassMedium } from './components/ClassMedium'; -import { ClassTankDestroyer } from './components/ClassTankDestroyer'; +import { TankClass } from "@blitzkit/core"; +import type { ComponentProps, ReactNode } from "react"; +import { ClassHeavy } from "./components/ClassHeavy"; +import { ClassLight } from "./components/ClassLight"; +import { ClassMedium } from "./components/ClassMedium"; +import { ClassTankDestroyer } from "./components/ClassTankDestroyer"; export const classIcons: Record< TankClass, - (props: ComponentProps<'svg'>) => ReactNode + (props: ComponentProps<"svg">) => ReactNode > = { - [TankClass.TANK_DESTROYER]: ClassTankDestroyer, - [TankClass.HEAVY]: ClassHeavy, - [TankClass.LIGHT]: ClassLight, - [TankClass.MEDIUM]: ClassMedium, + [TankClass.TANK_CLASS_TANK_DESTROYER]: ClassTankDestroyer, + [TankClass.TANK_CLASS_HEAVY]: ClassHeavy, + [TankClass.TANK_CLASS_LIGHT]: ClassLight, + [TankClass.TANK_CLASS_MEDIUM]: ClassMedium, }; diff --git a/packages/website/src/components/Compare/Body.tsx b/packages/website/src/components/Compare/Body.tsx index 47d8ca7f1..d6bdc5193 100644 --- a/packages/website/src/components/Compare/Body.tsx +++ b/packages/website/src/components/Compare/Body.tsx @@ -15,7 +15,7 @@ interface BodyProps { export function Body({ stats }: BodyProps) { const members = CompareEphemeral.use((state) => state.members); const hasNonRegularGun = members.some( - ({ gun }) => gun.gun_type!.$case !== "regular" + ({ gun }) => gun.gun_type!.$case !== "regular", ); const { unwrap, strings } = useLocale(); @@ -55,7 +55,7 @@ export function Body({ stats }: BodyProps) { }} > {unwrap(thisShell.name)} {unwrap(tank.name)} - {unwrap(tank.name)} + {unwrap(tank.name!)} diff --git a/packages/website/src/components/Embeds/breakdown.tsx b/packages/website/src/components/Embeds/breakdown.tsx index 65da153e2..662762432 100644 --- a/packages/website/src/components/Embeds/breakdown.tsx +++ b/packages/website/src/components/Embeds/breakdown.tsx @@ -55,7 +55,7 @@ export const fakeCompositeStats = compositeStats( wins: 30, xp: 1230 * 50, }, - averageDefinitions.averages[7297].mu + averageDefinitions.averages[7297].mu!, ); export function BreakdownPreview() { @@ -88,9 +88,9 @@ export function BreakdownRenderer() { const diff = useMemo( () => deltaTankStats(tankStatsA, tankStatsB).sort( - (a, b) => b.last_battle_time - a.last_battle_time + (a, b) => b.last_battle_time - a.last_battle_time, ), - [tankStatsB] + [tankStatsB], ); const compositeStats = diff .map((diff) => { @@ -100,14 +100,14 @@ export function BreakdownRenderer() { const compositeStats = calculateCompositeStats( { battle_life_time: diff.battle_life_time, ...diff.all }, - average.mu + average.mu!, ); return { id: diff.tank_id, compositeStats }; }) .filter((stats) => stats !== null); const sum = sumCompositeStats( - compositeStats.map(({ compositeStats }) => compositeStats) + compositeStats.map(({ compositeStats }) => compositeStats), ); useEffect(() => { diff --git a/packages/website/src/components/Gallery/Card.tsx b/packages/website/src/components/Gallery/Card.tsx index 133108d58..8345b5ded 100644 --- a/packages/website/src/components/Gallery/Card.tsx +++ b/packages/website/src/components/Gallery/Card.tsx @@ -19,7 +19,7 @@ type GalleryCardProps = MaybeSkeletonComponentProps<{ export function GalleryCard(props: GalleryCardProps) { const src = asset( - `gallery/avatars/${!props.skeleton && `${props.avatar.id}${props.avatar.extension}`}` + `gallery/avatars/${!props.skeleton && `${props.avatar.id}${props.avatar.extension}`}`, ); const card = useRef(null!); const { unwrap } = useLocale(); @@ -54,11 +54,11 @@ export function GalleryCard(props: GalleryCardProps) { objectFit: "cover", }} src={src} - alt={unwrap(props.avatar.name)} + alt={unwrap(props.avatar.name!)} /> - {unwrap(props.avatar.name)} + {unwrap(props.avatar.name!)} )} @@ -90,12 +90,12 @@ export function GalleryCard(props: GalleryCardProps) { - {unwrap(props.avatar.name)} + {unwrap(props.avatar.name!)} - {unwrap(props.avatar.name)} + {unwrap(props.avatar.name!)} diff --git a/packages/website/src/components/Guesser.tsx b/packages/website/src/components/Guesser.tsx index 6df4ec93b..62ff27553 100644 --- a/packages/website/src/components/Guesser.tsx +++ b/packages/website/src/components/Guesser.tsx @@ -82,10 +82,10 @@ export function Guesser() { }); setResults( - searchResults.map((result) => tankDefinitions.tanks[result.obj.id]) + searchResults.map((result) => tankDefinitions.tanks[result.obj.id]), ); }, 500), - [] + [], ); useEffect(() => { @@ -126,11 +126,11 @@ export function Guesser() { onClick={() => { if (!input.current) return; - input.current.value = unwrap(result.name); + input.current.value = unwrap(result.name!); setSelected(result); setResults(null); }} - text={unwrap(result.name)} + text={unwrap(result.name!)} prefix={ {turretNodes.map((node) => { @@ -160,28 +160,28 @@ export function Model() { ref={gunGroup} rotation={[modelTransformEvent.last!.pitch, 0, 0]} position={[ - turretTankModel.turret_origin.x + - turretTrackModel.origin.x + - turretModel.gun_origin.x, - turretTankModel.turret_origin.z + - turretTrackModel.origin.z + - turretModel.gun_origin.z, - turretTankModel.turret_origin.y + - turretTrackModel.origin.y + - turretModel.gun_origin.y, + turretTankModel.turret_origin!.x + + turretTrackModel.origin!.x + + turretModel.gun_origin!.x, + turretTankModel.turret_origin!.z + + turretTrackModel.origin!.z + + turretModel.gun_origin!.z, + turretTankModel.turret_origin!.y + + turretTrackModel.origin!.y + + turretModel.gun_origin!.y, ]} > {turretNodes.map((node) => { @@ -216,15 +216,15 @@ export function Model() { {gunNodes.map((node) => { diff --git a/packages/website/src/components/ModuleButtons/ConsumableButton.tsx b/packages/website/src/components/ModuleButtons/ConsumableButton.tsx index 278505e33..f6ddf6749 100644 --- a/packages/website/src/components/ModuleButtons/ConsumableButton.tsx +++ b/packages/website/src/components/ModuleButtons/ConsumableButton.tsx @@ -1,11 +1,11 @@ -import { asset } from '@blitzkit/core'; -import { ClockIcon, ReloadIcon } from '@radix-ui/react-icons'; -import { Flex, Text } from '@radix-ui/themes'; -import { awaitableConsumableDefinitions } from '../../core/awaitables/consumableDefinitions'; -import { useDelta } from '../../hooks/useDelta'; -import { useLocale } from '../../hooks/useLocale'; -import { GenericTankComponentButton } from './GenericTankComponentButton'; -import type { TankComponentButtonProps } from './TankComponentButton'; +import { asset } from "@blitzkit/core"; +import { ClockIcon, ReloadIcon } from "@radix-ui/react-icons"; +import { Flex, Text } from "@radix-ui/themes"; +import { awaitableConsumableDefinitions } from "../../core/awaitables/consumableDefinitions"; +import { useDelta } from "../../hooks/useDelta"; +import { useLocale } from "../../hooks/useLocale"; +import { GenericTankComponentButton } from "./GenericTankComponentButton"; +import type { TankComponentButtonProps } from "./TankComponentButton"; interface ConsumableButtonProps extends TankComponentButtonProps { consumable: number; @@ -27,8 +27,8 @@ export function ConsumableButton({ return ( @@ -39,9 +39,9 @@ export function ConsumableButton({ size="1" color={ durationDelta > 0 - ? 'green' + ? "green" : durationDelta < 0 - ? 'tomato' + ? "tomato" : undefined } > @@ -56,9 +56,9 @@ export function ConsumableButton({ size="1" color={ cooldownDelta < 0 - ? 'green' + ? "green" : cooldownDelta > 0 - ? 'tomato' + ? "tomato" : undefined } > diff --git a/packages/website/src/components/ModuleButtons/EquipmentButton.tsx b/packages/website/src/components/ModuleButtons/EquipmentButton.tsx index 93014bd16..337937832 100644 --- a/packages/website/src/components/ModuleButtons/EquipmentButton.tsx +++ b/packages/website/src/components/ModuleButtons/EquipmentButton.tsx @@ -1,8 +1,8 @@ -import { asset } from '@blitzkit/core'; -import { awaitableEquipmentDefinitions } from '../../core/awaitables/equipmentDefinitions'; -import { useLocale } from '../../hooks/useLocale'; -import { GenericTankComponentButton } from './GenericTankComponentButton'; -import type { TankComponentButtonProps } from './TankComponentButton'; +import { asset } from "@blitzkit/core"; +import { awaitableEquipmentDefinitions } from "../../core/awaitables/equipmentDefinitions"; +import { useLocale } from "../../hooks/useLocale"; +import { GenericTankComponentButton } from "./GenericTankComponentButton"; +import type { TankComponentButtonProps } from "./TankComponentButton"; interface EquipmentButtonProps extends TankComponentButtonProps { equipment: number; @@ -15,7 +15,7 @@ export function EquipmentButton({ equipment, ...props }: EquipmentButtonProps) { return ( diff --git a/packages/website/src/components/ModuleButtons/ProvisionButton.tsx b/packages/website/src/components/ModuleButtons/ProvisionButton.tsx index c42c0493b..a3876df40 100644 --- a/packages/website/src/components/ModuleButtons/ProvisionButton.tsx +++ b/packages/website/src/components/ModuleButtons/ProvisionButton.tsx @@ -1,8 +1,8 @@ -import { asset } from '@blitzkit/core'; -import { awaitableProvisionDefinitions } from '../../core/awaitables/provisionDefinitions'; -import { useLocale } from '../../hooks/useLocale'; -import { GenericTankComponentButton } from './GenericTankComponentButton'; -import type { TankComponentButtonProps } from './TankComponentButton'; +import { asset } from "@blitzkit/core"; +import { awaitableProvisionDefinitions } from "../../core/awaitables/provisionDefinitions"; +import { useLocale } from "../../hooks/useLocale"; +import { GenericTankComponentButton } from "./GenericTankComponentButton"; +import type { TankComponentButtonProps } from "./TankComponentButton"; interface ProvisionButtonProps extends TankComponentButtonProps { provision: number; @@ -15,7 +15,7 @@ export function ProvisionButton({ provision, ...props }: ProvisionButtonProps) { return ( diff --git a/packages/website/src/components/ModuleManager.tsx b/packages/website/src/components/ModuleManager.tsx index f30506821..30d63a161 100644 --- a/packages/website/src/components/ModuleManager.tsx +++ b/packages/website/src/components/ModuleManager.tsx @@ -6,11 +6,11 @@ import { type TankDefinition, type TrackDefinition, type TurretDefinition, -} from '@blitzkit/core'; -import { DropdownMenu, Flex } from '@radix-ui/themes'; -import { useState } from 'react'; -import { useLocale } from '../hooks/useLocale'; -import { ModuleButton } from './ModuleButtons/ModuleButton'; +} from "@blitzkit/core"; +import { DropdownMenu, Flex } from "@radix-ui/themes"; +import { useState } from "react"; +import { useLocale } from "../hooks/useLocale"; +import { ModuleButton } from "./ModuleButtons/ModuleButton"; interface ModuleManagerProps { tank: TankDefinition; @@ -72,8 +72,8 @@ export function ModuleManager({ variant="ghost" module="turret" discriminator={TIER_ROMAN_NUMERALS[turret.tier]} - />{' '} - {unwrap(turret.name)} + />{" "} + {unwrap(turret.name!)} ); })} @@ -112,8 +112,8 @@ export function ModuleManager({ variant="ghost" module="gun" discriminator={TIER_ROMAN_NUMERALS[gun.tier]} - />{' '} - {unwrap(gun.name)} + />{" "} + {unwrap(gun.name!)} ); })} @@ -151,8 +151,8 @@ export function ModuleManager({ variant="ghost" module="engine" discriminator={TIER_ROMAN_NUMERALS[engine.tier]} - />{' '} - {unwrap(engine.name)} + />{" "} + {unwrap(engine.name!)} ); })} @@ -190,8 +190,8 @@ export function ModuleManager({ variant="ghost" module="chassis" discriminator={TIER_ROMAN_NUMERALS[track.tier]} - />{' '} - {unwrap(track.name)} + />{" "} + {unwrap(track.name!)} ); })} diff --git a/packages/website/src/components/Performance/TankRow.tsx b/packages/website/src/components/Performance/TankRow.tsx index 6ceb47392..8bdf77fb6 100644 --- a/packages/website/src/components/Performance/TankRow.tsx +++ b/packages/website/src/components/Performance/TankRow.tsx @@ -20,7 +20,7 @@ export const TankRow = memo( const averages = averageDefinitions.averages[tank.id]; const ratio = useAveragesExclusionRatio(); const playerCountPeriod = Performance.use( - (state) => state.playerCountPeriod + (state) => state.playerCountPeriod, ); const { locale } = useLocale(); @@ -29,107 +29,109 @@ export const TankRow = memo( - {((averages.mu.wins / averages.mu.battles) * 100).toFixed(1)}% + {((averages.mu!.wins / averages.mu!.battles) * 100).toFixed(1)}% {formatCompact( locale, - Math.round(ratio * averages.samples[playerCountPeriod]) + Math.round(ratio * averages.samples![playerCountPeriod]), )} {Math.round( - averages.mu.damage_dealt / averages.mu.battles + averages.mu!.damage_dealt / averages.mu!.battles, ).toLocaleString(locale)} {Math.round( - (averages.mu.survived_battles / averages.mu.battles) * 100 + (averages.mu!.survived_battles / averages.mu!.battles) * 100, )} % - {Math.round(averages.mu.xp / averages.mu.battles).toLocaleString( - locale + {Math.round(averages.mu!.xp / averages.mu!.battles).toLocaleString( + locale, )} - {(averages.mu.frags / averages.mu.battles).toFixed(2)} + {(averages.mu!.frags / averages.mu!.battles).toFixed(2)} - {(averages.mu.spotted / averages.mu.battles).toFixed(2)} + {(averages.mu!.spotted / averages.mu!.battles).toFixed(2)} - {Math.round((averages.mu.hits / averages.mu.shots) * 100)}% + {Math.round((averages.mu!.hits / averages.mu!.shots) * 100)}% - {(averages.mu.shots / averages.mu.battles).toFixed(1)} + {(averages.mu!.shots / averages.mu!.battles).toFixed(1)} - {(averages.mu.hits / averages.mu.battles).toFixed(1)} + {(averages.mu!.hits / averages.mu!.battles).toFixed(1)} - {(averages.mu.damage_dealt / averages.mu.damage_received).toFixed(2)} + {(averages.mu!.damage_dealt / averages.mu!.damage_received).toFixed( + 2, + )} {Math.round( - averages.mu.damage_received / averages.mu.battles + averages.mu!.damage_received / averages.mu!.battles, ).toLocaleString(locale)} - {(averages.mu.capture_points / averages.mu.battles).toFixed(2)} + {(averages.mu!.capture_points / averages.mu!.battles).toFixed(2)} ); }, - (prev, next) => prev.tank.id === next.tank.id + (prev, next) => prev.tank.id === next.tank.id, ); diff --git a/packages/website/src/components/Performance/Tanks.tsx b/packages/website/src/components/Performance/Tanks.tsx index 8e67de851..5496e1e5c 100644 --- a/packages/website/src/components/Performance/Tanks.tsx +++ b/packages/website/src/components/Performance/Tanks.tsx @@ -49,10 +49,10 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { const filteredTanks = usePromise( () => filterTanks(filters, tankList).then((tanks) => - tanks.filter(({ id }) => id in averageDefinitions.averages) + tanks.filter(({ id }) => id in averageDefinitions.averages), ), // react-promise-suspense has awful type annotations - [filters] as any + [filters] as any, ); const tanksMapped = useMemo( () => @@ -60,7 +60,7 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { id, ...averageDefinitions.averages[id], })), - [filters] + [filters], ); const tanksSorted = useMemo(() => { const { playerCountPeriod } = Performance.state; @@ -69,83 +69,85 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { case "accuracy": return tanksMapped.sort( (a, b) => - sort.direction * (a.mu.hits / a.mu.shots - b.mu.hits / b.mu.shots) + sort.direction * + (a.mu!.hits / a.mu!.shots - b.mu!.hits / b.mu!.shots), ); case "capture_points": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.capture_points / a.mu.battles - - b.mu.capture_points / b.mu.battles) + (a.mu!.capture_points / a.mu!.battles - + b.mu!.capture_points / b.mu!.battles), ); case "damage": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.damage_dealt / a.mu.battles - - b.mu.damage_dealt / b.mu.battles) + (a.mu!.damage_dealt / a.mu!.battles - + b.mu!.damage_dealt / b.mu!.battles), ); case "damage_ratio": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.damage_dealt / a.mu.damage_received - - b.mu.damage_dealt / b.mu.damage_received) + (a.mu!.damage_dealt / a.mu!.damage_received - + b.mu!.damage_dealt / b.mu!.damage_received), ); case "damage_taken": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.damage_received / a.mu.battles - - b.mu.damage_received / b.mu.battles) + (a.mu!.damage_received / a.mu!.battles - + b.mu!.damage_received / b.mu!.battles), ); case "hits": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.hits / a.mu.battles - b.mu.hits / b.mu.battles) + (a.mu!.hits / a.mu!.battles - b.mu!.hits / b.mu!.battles), ); case "kills": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.frags / a.mu.battles - b.mu.frags / b.mu.battles) + (a.mu!.frags / a.mu!.battles - b.mu!.frags / b.mu!.battles), ); case "shots": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.shots / a.mu.battles - b.mu.shots / b.mu.battles) + (a.mu!.shots / a.mu!.battles - b.mu!.shots / b.mu!.battles), ); case "players": return tanksMapped.sort( (a, b) => sort.direction * - (a.samples[playerCountPeriod] - b.samples[playerCountPeriod]) + (a.samples![playerCountPeriod] - b.samples![playerCountPeriod]), ); case "spots": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.spotted / a.mu.battles - b.mu.spotted / b.mu.battles) + (a.mu!.spotted / a.mu!.battles - b.mu!.spotted / b.mu!.battles), ); case "survival": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.survived_battles / a.mu.battles - - b.mu.survived_battles / b.mu.battles) + (a.mu!.survived_battles / a.mu!.battles - + b.mu!.survived_battles / b.mu!.battles), ); case "winrate": return tanksMapped.sort( (a, b) => sort.direction * - (a.mu.wins / a.mu.battles - b.mu.wins / b.mu.battles) + (a.mu!.wins / a.mu!.battles - b.mu!.wins / b.mu!.battles), ); case "xp": return tanksMapped.sort( (a, b) => - sort.direction * (a.mu.xp / a.mu.battles - b.mu.xp / b.mu.battles) + sort.direction * + (a.mu!.xp / a.mu!.battles - b.mu!.xp / b.mu!.battles), ); } }, [filters, sort]); @@ -161,11 +163,11 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { const sum = useCallback( (slice: (tank: BlitzkitStats) => number) => { return tanksSorted.reduce( - (acc, tank) => acc + tank.samples[playerCountPeriod] * slice(tank.mu), - 0 + (acc, tank) => acc + tank.samples![playerCountPeriod] * slice(tank.mu!), + 0, ); }, - [tanksSorted] + [tanksSorted], ); const battles = sum(({ battles }) => battles); @@ -209,7 +211,7 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { {formatCompact( locale, - ratio * averageDefinitions.samples[playerCountPeriod] + ratio * averageDefinitions.samples![playerCountPeriod], )} @@ -255,12 +257,12 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) { key={index} onIntersection={() => { setLoadedRows((state) => - Math.min(state + 2, tanksSorted.length) + Math.min(state + 2, tanksSorted.length), ); }} /> ); - } + }, )} ); diff --git a/packages/website/src/components/TankCard/index.tsx b/packages/website/src/components/TankCard/index.tsx index d12af6d94..64eece530 100644 --- a/packages/website/src/components/TankCard/index.tsx +++ b/packages/website/src/components/TankCard/index.tsx @@ -33,7 +33,7 @@ export const TankCard = forwardRef( style, ...props }: TankCardProps, - ref + ref, ) => { const { unwrap, locale } = useLocale(); const provideLink = !noLink && onSelect === undefined; @@ -46,13 +46,13 @@ export const TankCard = forwardRef( tabIndex={onSelect ? 0 : undefined} size="2" color={ - tank.type === TankType.COLLECTOR + tank.type === TankType.TANK_TYPE_COLLECTOR ? "blue" - : tank.type === TankType.PREMIUM + : tank.type === TankType.TANK_TYPE_PREMIUM ? "amber" : "gray" } - highContrast={tank.type === TankType.RESEARCHABLE} + highContrast={tank.type === TankType.TANK_TYPE_RESEARCHABLE} onClick={() => { onSelect?.(tank); TankopediaPersistent.mutate((draft) => { @@ -79,7 +79,7 @@ export const TankCard = forwardRef( }} > {unwrap(tank.name)}( > - {unwrap(tank.name)} + {unwrap(tank.name!)} @@ -115,5 +115,5 @@ export const TankCard = forwardRef( ); - } + }, ); diff --git a/packages/website/src/components/TankRowHeaderCell.tsx b/packages/website/src/components/TankRowHeaderCell.tsx index 1286db36a..75cf846de 100644 --- a/packages/website/src/components/TankRowHeaderCell.tsx +++ b/packages/website/src/components/TankRowHeaderCell.tsx @@ -19,13 +19,13 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) { )} - {unwrap(tank.name)} + {unwrap(tank.name!)} diff --git a/packages/website/src/components/TankSearch/components/Card.tsx b/packages/website/src/components/TankSearch/components/Card.tsx index cad5fe664..8eb75f918 100644 --- a/packages/website/src/components/TankSearch/components/Card.tsx +++ b/packages/website/src/components/TankSearch/components/Card.tsx @@ -53,11 +53,11 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) { case "fire.reload": return resolveReload(gun).toFixed(2); case "fire.standardPenetration": - return shell0?.penetration.near.toFixed(0); + return shell0?.penetration!.near.toFixed(0); case "fire.premiumPenetration": - return shell1 ? shell1?.penetration.near.toFixed(0) : "--"; + return shell1 ? shell1?.penetration!.near.toFixed(0) : "--"; case "fire.tertiaryPenetration": - return shell1 ? shell2?.penetration.near.toFixed(0) : "--"; + return shell1 ? shell2?.penetration!.near.toFixed(0) : "--"; case "fire.shellVelocity": return shell0.velocity.toFixed(0); case "fire.shellCapacity": @@ -66,12 +66,12 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) { return shell0.range.toFixed(0); case "fire.gunDepression": return ( - gunModelDefinition.pitch.max + + gunModelDefinition.pitch!.max + (tankModelDefinition.initial_turret_rotation?.pitch ?? 0) ).toFixed(1); case "fire.gunElevation": return ( - -gunModelDefinition.pitch.min - + -gunModelDefinition.pitch!.min - (tankModelDefinition.initial_turret_rotation?.pitch ?? 0) ).toFixed(1); case "maneuverability.forwardsSpeed": @@ -113,8 +113,8 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) { case "survivability.volume": { const dimensions = normalizeBoundingBox( unionBoundingBox( - tankModelDefinition.bounding_box, - turretModelDefinition.bounding_box, + tankModelDefinition.bounding_box!, + turretModelDefinition.bounding_box!, ), ); @@ -124,8 +124,8 @@ export function TankSearchCard({ tank, onSelect }: TankSearchCardProps) { case "survivability.length": { const bounds = normalizeBoundingBox( unionBoundingBox( - tankModelDefinition.bounding_box, - turretModelDefinition.bounding_box, + tankModelDefinition.bounding_box!, + turretModelDefinition.bounding_box!, ), ); diff --git a/packages/website/src/components/TankSearch/components/FilterControl.tsx b/packages/website/src/components/TankSearch/components/FilterControl.tsx index 1678a4ad2..645e8f73c 100644 --- a/packages/website/src/components/TankSearch/components/FilterControl.tsx +++ b/packages/website/src/components/TankSearch/components/FilterControl.tsx @@ -85,11 +85,11 @@ for (const gameModeIdString in gameModeRoleSets) { outerLoop: for (const id of role.consumables) { const name = - consumableDefinitions.consumables[id].name.locales[locales.default]; + consumableDefinitions.consumables[id].name!.locales[locales.default]; for (const otherConsumable of consumables.values()) { const otherName = - consumableDefinitions.consumables[otherConsumable].name.locales[ + consumableDefinitions.consumables[otherConsumable].name!.locales[ locales.default ]; @@ -102,11 +102,11 @@ for (const gameModeIdString in gameModeRoleSets) { outerLoop: for (const id of role.provisions) { const name = - provisionDefinitions.provisions[id].name.locales[locales.default]; + provisionDefinitions.provisions[id].name!.locales[locales.default]; for (const otherProvision of provisions.values()) { const otherName = - provisionDefinitions.provisions[otherProvision].name.locales[ + provisionDefinitions.provisions[otherProvision].name!.locales[ locales.default ]; @@ -129,7 +129,7 @@ const consumablesArray = Object.values(consumableDefinitions.consumables) .filter( (consumable) => !consumable.game_mode_exclusive && - consumable.name.locales[locales.default], + consumable.name!.locales[locales.default], ) .map((consumable) => consumable.id); const provisionsArray = Array.from( @@ -137,11 +137,11 @@ const provisionsArray = Array.from( .filter( (provision) => !provision.game_mode_exclusive && - provision.name.locales[locales.default], + provision.name!.locales[locales.default], ) .reduce((uniqueMap, consumable) => { - if (!uniqueMap.has(consumable.name.locales[locales.default])) { - uniqueMap.set(consumable.name.locales[locales.default], consumable.id); + if (!uniqueMap.has(consumable.name!.locales[locales.default])) { + uniqueMap.set(consumable.name!.locales[locales.default], consumable.id); } return uniqueMap; @@ -149,10 +149,10 @@ const provisionsArray = Array.from( .values(), ); const shellTypeIcons: Record = { - [ShellType.AP]: "ap", - [ShellType.APCR]: "ap_cr", - [ShellType.HE]: "he", - [ShellType.HEAT]: "hc", + [ShellType.SHELL_TYPE_AP]: "ap", + [ShellType.SHELL_TYPE_APCR]: "ap_cr", + [ShellType.SHELL_TYPE_HE]: "he", + [ShellType.SHELL_TYPE_HEAT]: "hc", }; const GUN_TYPE_ICONS: Record< @@ -165,9 +165,9 @@ const GUN_TYPE_ICONS: Record< }; const TANK_TYPE_COLORS: Record = { - [TankType.RESEARCHABLE]: "gray", - [TankType.PREMIUM]: "amber", - [TankType.COLLECTOR]: "blue", + [TankType.TANK_TYPE_RESEARCHABLE]: "gray", + [TankType.TANK_TYPE_PREMIUM]: "amber", + [TankType.TANK_TYPE_COLLECTOR]: "blue", }; const GUN_TYPES = Object.keys( @@ -566,12 +566,12 @@ function TypeFilter() { diff --git a/packages/website/src/components/TankSearch/index.tsx b/packages/website/src/components/TankSearch/index.tsx index 4008e0366..6a6513145 100644 --- a/packages/website/src/components/TankSearch/index.tsx +++ b/packages/website/src/components/TankSearch/index.tsx @@ -67,7 +67,7 @@ export const TankSearch = memo( return filterTanks( tankFilters, awaitedTanksDefinitionsArray, - wargaming?.id + wargaming?.id, ); } else { return Promise.resolve( @@ -75,12 +75,12 @@ export const TankSearch = memo( .go(tankFilters.search, tankNames, { keys: SEARCH_KEYS, }) - .map((result) => tankDefinitions.tanks[result.obj.id]) + .map((result) => tankDefinitions.tanks[result.obj.id]), ); } }, // react-promise-suspense has awful type annotations - [tankFilters] as any + [tankFilters] as any, ); const sorted = useMemo(() => { if (tankFilters.search === null) { @@ -104,19 +104,19 @@ export const TankSearch = memo( case "survivability.viewRange": sorted = filtered.sort( (a, b) => - a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range + a.turrets.at(-1)!.view_range - b.turrets.at(-1)!.view_range, ); break; case "survivability.camouflageStill": sorted = filtered.sort( - (a, b) => a.camouflage_still - b.camouflage_still + (a, b) => a.camouflage_still - b.camouflage_still, ); break; case "survivability.camouflageMoving": sorted = filtered.sort( - (a, b) => a.camouflage_moving - b.camouflage_moving + (a, b) => a.camouflage_moving - b.camouflage_moving, ); break; @@ -126,7 +126,7 @@ export const TankSearch = memo( a.camouflage_still * a.turrets.at(-1)!.guns.at(-1)!.camouflage_loss - b.camouflage_still * - b.turrets.at(-1)!.guns.at(-1)!.camouflage_loss + b.turrets.at(-1)!.guns.at(-1)!.camouflage_loss, ); break; @@ -140,15 +140,15 @@ export const TankSearch = memo( bTankModelDefinition.turrets[b.turrets.at(-1)!.id]; const aSize = normalizeBoundingBox( unionBoundingBox( - aTankModelDefinition.bounding_box, - aTurretModelDefinition.bounding_box - ) + aTankModelDefinition.bounding_box!, + aTurretModelDefinition.bounding_box!, + ), ); const bSize = normalizeBoundingBox( unionBoundingBox( - bTankModelDefinition.bounding_box, - bTurretModelDefinition.bounding_box - ) + bTankModelDefinition.bounding_box!, + bTurretModelDefinition.bounding_box!, + ), ); const aVolume = aSize.x * aSize.y * aSize.z; const bVolume = bSize.x * bSize.y * bSize.z; @@ -167,15 +167,15 @@ export const TankSearch = memo( bTankModelDefinition.turrets[b.turrets.at(-1)!.id]; const aSize = normalizeBoundingBox( unionBoundingBox( - aTankModelDefinition.bounding_box, - aTurretModelDefinition.bounding_box - ) + aTankModelDefinition.bounding_box!, + aTurretModelDefinition.bounding_box!, + ), ); const bSize = normalizeBoundingBox( unionBoundingBox( - bTankModelDefinition.bounding_box, - bTurretModelDefinition.bounding_box - ) + bTankModelDefinition.bounding_box!, + bTurretModelDefinition.bounding_box!, + ), ); const aLength = Math.max(aSize.x, aSize.y, aSize.z); const bLength = Math.max(bSize.x, bSize.y, bSize.z); @@ -189,12 +189,12 @@ export const TankSearch = memo( (a, b) => resolveDpm( a.turrets.at(-1)!.guns.at(-1)!, - a.turrets.at(-1)!.guns.at(-1)!.shells[0] + a.turrets.at(-1)!.guns.at(-1)!.shells[0], ) - resolveDpm( b.turrets.at(-1)!.guns.at(-1)!, - b.turrets.at(-1)!.guns.at(-1)!.shells[0] - ) + b.turrets.at(-1)!.guns.at(-1)!.shells[0], + ), ); break; @@ -204,15 +204,15 @@ export const TankSearch = memo( (a.turrets.at(-1)!.guns.at(-1)!.shells[1] ? resolveDpm( a.turrets.at(-1)!.guns.at(-1)!, - a.turrets.at(-1)!.guns.at(-1)!.shells[1] + a.turrets.at(-1)!.guns.at(-1)!.shells[1], ) : 0) - (b.turrets.at(-1)!.guns.at(-1)!.shells[1] ? resolveDpm( b.turrets.at(-1)!.guns.at(-1)!, - b.turrets.at(-1)!.guns.at(-1)!.shells[1] + b.turrets.at(-1)!.guns.at(-1)!.shells[1], ) - : 0) + : 0), ); break; @@ -220,7 +220,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => resolveReload(a.turrets.at(-1)!.guns.at(-1)!) - - resolveReload(b.turrets.at(-1)!.guns.at(-1)!) + resolveReload(b.turrets.at(-1)!.guns.at(-1)!), ); break; @@ -228,35 +228,35 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber + b.turrets.at(-1)!.guns.at(-1)!.shells[0].caliber, ); break; case "fire.standardPenetration": sorted = filtered.sort( (a, b) => - a.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration.near - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration.near + a.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near - + b.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near, ); break; case "fire.premiumPenetration": sorted = filtered.sort( (a, b) => - (a.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration.near ?? + (a.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration!.near ?? 0) - - (b.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration.near ?? - 0) + (b.turrets.at(-1)!.guns.at(-1)!.shells[1]?.penetration!.near ?? + 0), ); break; case "fire.tertiaryPenetration": sorted = filtered.sort( (a, b) => - (a.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration.near ?? + (a.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration!.near ?? 0) - - (b.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration.near ?? - 0) + (b.turrets.at(-1)!.guns.at(-1)!.shells[2]?.penetration!.near ?? + 0), ); break; @@ -264,7 +264,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shells[0].armor_damage - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].armor_damage + b.turrets.at(-1)!.guns.at(-1)!.shells[0].armor_damage, ); break; @@ -272,7 +272,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shells[0].module_damage - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].module_damage + b.turrets.at(-1)!.guns.at(-1)!.shells[0].module_damage, ); break; @@ -280,7 +280,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shells[0].velocity - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].velocity + b.turrets.at(-1)!.guns.at(-1)!.shells[0].velocity, ); break; @@ -288,7 +288,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shells[0].range - - b.turrets.at(-1)!.guns.at(-1)!.shells[0].range + b.turrets.at(-1)!.guns.at(-1)!.shells[0].range, ); break; @@ -296,7 +296,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.shell_capacity - - b.turrets.at(-1)!.guns.at(-1)!.shell_capacity + b.turrets.at(-1)!.guns.at(-1)!.shell_capacity, ); break; @@ -304,7 +304,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.aim_time - - b.turrets.at(-1)!.guns.at(-1)!.aim_time + b.turrets.at(-1)!.guns.at(-1)!.aim_time, ); break; @@ -312,7 +312,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.turrets.at(-1)!.guns.at(-1)!.dispersion_base - - b.turrets.at(-1)!.guns.at(-1)!.dispersion_base + b.turrets.at(-1)!.guns.at(-1)!.dispersion_base, ); break; @@ -320,7 +320,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.tracks.at(-1)!.dispersion_move - - b.tracks.at(-1)!.dispersion_move + b.tracks.at(-1)!.dispersion_move, ); break; @@ -328,13 +328,13 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id] - .guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch.max + + .guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch!.max + (modelDefinitions.models[a.id].initial_turret_rotation?.pitch ?? 0) - modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id] - .guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch.max - + .guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch!.max - (modelDefinitions.models[b.id].initial_turret_rotation?.pitch ?? - 0) + 0), ); break; @@ -342,31 +342,31 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => modelDefinitions.models[b.id].turrets[b.turrets.at(-1)!.id] - .guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch.min + + .guns[b.turrets.at(-1)!.guns.at(-1)!.id].pitch!.min + (modelDefinitions.models[b.id].initial_turret_rotation?.pitch ?? 0) - modelDefinitions.models[a.id].turrets[a.turrets.at(-1)!.id] - .guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch.min - + .guns[a.turrets.at(-1)!.guns.at(-1)!.id].pitch!.min - (modelDefinitions.models[a.id].initial_turret_rotation?.pitch ?? - 0) + 0), ); break; case "maneuverability.forwardsSpeed": sorted = filtered.sort( - (a, b) => a.speed_forwards - b.speed_forwards + (a, b) => a.speed_forwards - b.speed_forwards, ); break; case "maneuverability.backwardsSpeed": sorted = filtered.sort( - (a, b) => a.speed_backwards - b.speed_backwards + (a, b) => a.speed_backwards - b.speed_backwards, ); break; case "maneuverability.power": sorted = filtered.sort( - (a, b) => a.engines.at(-1)!.power - b.engines.at(-1)!.power + (a, b) => a.engines.at(-1)!.power - b.engines.at(-1)!.power, ); break; @@ -384,7 +384,7 @@ export const TankSearch = memo( b.engines.at(-1)!.weight + b.tracks.at(-1)!.weight + b.turrets.at(-1)!.weight + - b.turrets.at(-1)!.guns.at(-1)!.weight) + b.turrets.at(-1)!.guns.at(-1)!.weight), ); break; @@ -400,7 +400,7 @@ export const TankSearch = memo( b.engines.at(-1)!.weight + b.tracks.at(-1)!.weight + b.turrets.at(-1)!.weight + - b.turrets.at(-1)!.guns.at(-1)!.weight) + b.turrets.at(-1)!.guns.at(-1)!.weight), ); break; @@ -408,7 +408,7 @@ export const TankSearch = memo( sorted = filtered.sort( (a, b) => a.tracks.at(-1)!.traverse_speed - - b.tracks.at(-1)!.traverse_speed + b.tracks.at(-1)!.traverse_speed, ); break; } @@ -520,12 +520,12 @@ export const TankSearch = memo( key={index} onIntersection={() => { setLoadedCards((state) => - Math.min(state + 2, sorted.length) + Math.min(state + 2, sorted.length), ); }} /> ); - } + }, )} )} @@ -538,15 +538,15 @@ export const TankSearch = memo( {times( Math.round( - skeleton ? DEFAULT_LOADED_CARDS : 10 + 10 * Math.random() + skeleton ? DEFAULT_LOADED_CARDS : 10 + 10 * Math.random(), ), (index) => ( - ) + ), )} )} ); - } + }, ); diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Crew.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Crew.tsx index 4c5bc6afb..471b27da0 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Crew.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Crew.tsx @@ -24,7 +24,7 @@ export function Crew({ stats }: StatsAcceptorProps) { provisionDefinitions.provisions[provision].crew ? total + provisionDefinitions.provisions[provision].crew! / 100 : total, - 0 + 0, ) + (hasImprovedVentilation ? 0.08 : 0); const commanderMastery = 1 + provisionCrewBonus; @@ -71,7 +71,7 @@ export function Crew({ stats }: StatsAcceptorProps) { decimals={0} noRanking value={() => - (member.type === CrewType.COMMANDER + (member.type === CrewType.CREW_TYPE_COMMANDER ? commanderMastery : commanderMastery * 1.1) * 100 } @@ -93,7 +93,7 @@ export function Crew({ stats }: StatsAcceptorProps) { ? strings.website.tools.tankopedia.crew[ CREW_MEMBER_NAMES[sub] ] - : sub + : sub, ) .join(", ")} diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx index f9127d261..4fc066c22 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx @@ -38,7 +38,7 @@ export function Firepower({ const selected = thisShell.id === shell.id; return ( - + {unwrap(thisShell.name)} - {gunModelDefinition.pitch.front && ( + {gunModelDefinition.pitch!.front && ( <> )} - {gunModelDefinition.pitch.back && ( + {gunModelDefinition.pitch!.back && ( <> - - + + diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/components/ModelChunk.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/components/ModelChunk.tsx index 9759babeb..366971625 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/components/ModelChunk.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/components/ModelChunk.tsx @@ -1,13 +1,13 @@ -import { mauveDark } from '@radix-ui/colors'; -import { LineBasicMaterial, MeshBasicMaterial } from 'three'; -import { awaitableModelDefinitions } from '../../../../../../../../core/awaitables/modelDefinitions'; -import { jsxTree } from '../../../../../../../../core/blitzkit/jsxTree'; -import { useModel } from '../../../../../../../../hooks/useModel'; -import { Duel } from '../../../../../../../../stores/duel'; +import { mauveDark } from "@radix-ui/colors"; +import { LineBasicMaterial, MeshBasicMaterial } from "three"; +import { awaitableModelDefinitions } from "../../../../../../../../core/awaitables/modelDefinitions"; +import { jsxTree } from "../../../../../../../../core/blitzkit/jsxTree"; +import { useModel } from "../../../../../../../../hooks/useModel"; +import { Duel } from "../../../../../../../../stores/duel"; const modelDefinitions = await awaitableModelDefinitions; -const surfaceMaterial: Record = { +const surfaceMaterial: Record = { gun: new MeshBasicMaterial({ color: mauveDark.mauve8, toneMapped: false, @@ -23,7 +23,7 @@ const surfaceMaterial: Record = { opacity: 0.5, }), }; -const outlineMaterial: Record = { +const outlineMaterial: Record = { gun: new LineBasicMaterial({ color: mauveDark.mauve11, toneMapped: false, @@ -41,7 +41,7 @@ const outlineMaterial: Record = { }; interface Props { - only: 'gun' | 'turret' | 'body'; + only: "gun" | "turret" | "body"; } export function ModelChunk({ only }: Props) { @@ -53,8 +53,8 @@ export function ModelChunk({ only }: Props) { const turretModel = tankModel.turrets[turret.id]; const gunModel = turretModel.guns[gun.id]; - const originZ = tankModel.turret_origin.z + turretModel.gun_origin.z; - const originY = tankModel.turret_origin.y + turretModel.gun_origin.y; + const originZ = tankModel.turret_origin!.z + turretModel.gun_origin!.z; + const originY = tankModel.turret_origin!.y + turretModel.gun_origin!.y; const { gltf } = useModel(tank.id); const nodes = Object.values(gltf.nodes); @@ -64,25 +64,25 @@ export function ModelChunk({ only }: Props) { {nodes.map((node) => { const isCurrentMantlet = node.name === - `gun_${gunModel.model_id.toString().padStart(2, '0')}_mask`; + `gun_${gunModel.model_id.toString().padStart(2, "0")}_mask`; const isCurrentGun = - node.name === `gun_${gunModel.model_id.toString().padStart(2, '0')}`; + node.name === `gun_${gunModel.model_id.toString().padStart(2, "0")}`; const isGun = isCurrentGun || isCurrentMantlet; const isCurrentTurret = node.name === - `turret_${turretModel.model_id.toString().padStart(2, '0')}`; + `turret_${turretModel.model_id.toString().padStart(2, "0")}`; const isTurret = isCurrentTurret; - const isHull = node.name === 'hull'; - const isWheel = node.name.startsWith('chassis_wheel_'); - const isTrack = node.name.startsWith('chassis_track_'); + const isHull = node.name === "hull"; + const isWheel = node.name.startsWith("chassis_wheel_"); + const isTrack = node.name.startsWith("chassis_track_"); const isBody = isHull || isWheel || isTrack; if ( - (only === 'gun' && !isGun) || - (only === 'turret' && !isTurret) || - (only === 'body' && !isBody) + (only === "gun" && !isGun) || + (only === "turret" && !isTurret) || + (only === "body" && !isBody) ) { return null; } diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/index.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/index.tsx index e2e3922fb..a278a230a 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/index.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/GunFlexibilityVisualizer/index.tsx @@ -51,21 +51,21 @@ export function GunFlexibilityVisualizer({ const [yaw, setYaw] = useState(0); const [pitch, setPitch] = useState(0); const [minPitch, setMinPitch] = useState( - -degToRad(gunModel.pitch.front?.max ?? gunModel.pitch.max) + -degToRad(gunModel.pitch!.front?.max ?? gunModel.pitch!.max), ); const [maxPitch, setMaxPitch] = useState( - -degToRad(gunModel.pitch.front?.min ?? gunModel.pitch.min) + -degToRad(gunModel.pitch!.front?.min ?? gunModel.pitch!.min), ); const container = useRef(null); const highlighter = useRef(null); const pointer = useRef(null); - const p = gunModel.pitch; + const p = gunModel.pitch!; const y = turretModel.yaw; const f = p.front; const b = p.back; - const t = gunModel.pitch.transition ?? DEFAULT_PITCH_TRANSITION; + const t = gunModel.pitch!.transition ?? DEFAULT_PITCH_TRANSITION; let d = ""; @@ -223,12 +223,12 @@ export function GunFlexibilityVisualizer({ const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const min = applyPitchYawLimits( @@ -237,7 +237,7 @@ export function GunFlexibilityVisualizer({ p, y, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); const max = applyPitchYawLimits( Math.PI, @@ -245,7 +245,7 @@ export function GunFlexibilityVisualizer({ p, y, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); yaw = min[1]; diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/RicochetVisualizer/components/ShellSwitcher.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/RicochetVisualizer/components/ShellSwitcher.tsx index 23bf28f29..52d3b431d 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/RicochetVisualizer/components/ShellSwitcher.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/RicochetVisualizer/components/ShellSwitcher.tsx @@ -15,7 +15,7 @@ export function ShellSwitcher() { const selected = thisShell.id === shell.id; return ( - + {unwrap(thisShell.name)} diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx index e79b92713..c52a01214 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/index.tsx @@ -26,13 +26,13 @@ export function Characteristics({ skeleton }: MaybeSkeletonComponentProps) { const consumables = Duel.use((state) => state.protagonist.consumables); const camouflage = Duel.use((state) => state.protagonist.camouflage); const assaultDistance = Duel.use( - (state) => state.protagonist.assaultDistance + (state) => state.protagonist.assaultDistance, ); const equipmentMatrix = Duel.use( - (state) => state.protagonist.equipmentMatrix + (state) => state.protagonist.equipmentMatrix, ); const { tank, turret, gun, engine, track, shell } = Duel.use( - (state) => state.protagonist + (state) => state.protagonist, ); const stockEngine = tank.engines[0]; const stockTrack = tank.tracks[0]; @@ -67,7 +67,7 @@ export function Characteristics({ skeleton }: MaybeSkeletonComponentProps) { tankModelDefinition, equipmentDefinitions: equipmentDefinitions, provisionDefinitions: provisionDefinitions, - } + }, ); const hasImprovedVerticalStabilizer = useEquipment(122); @@ -77,10 +77,10 @@ export function Characteristics({ skeleton }: MaybeSkeletonComponentProps) { const [pitch, yaw] = applyPitchYawLimits( modelTransformEvent.last!.pitch, modelTransformEvent.last!.yaw, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Modules.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Modules.tsx index 55703da90..937c216d3 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Modules.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Modules.tsx @@ -43,11 +43,11 @@ interface ModuleWithUnlocks { } const moduleTypeTypeIconName: Record = { - [ModuleType.VEHICLE]: "", - [ModuleType.ENGINE]: "engine", - [ModuleType.TRACKS]: "chassis", - [ModuleType.TURRET]: "turret", - [ModuleType.GUN]: "gun", + [ModuleType.MODULE_TYPE_VEHICLE]: "", + [ModuleType.MODULE_TYPE_ENGINE]: "engine", + [ModuleType.MODULE_TYPE_TRACKS]: "chassis", + [ModuleType.MODULE_TYPE_TURRET]: "turret", + [ModuleType.MODULE_TYPE_GUN]: "gun", }; function ModuleButton({ @@ -63,7 +63,7 @@ function ModuleButton({ top: boolean; onClick: () => void; }) { - const isTank = unlock.type === ModuleType.VEHICLE; + const isTank = unlock.type === ModuleType.MODULE_TYPE_VEHICLE; const { locale } = useLocale(); const button = ( @@ -91,7 +91,7 @@ function ModuleButton({ {TIER_ROMAN_NUMERALS[tier]} - {unlock.cost.value > 0 && ( + {unlock.cost!.value > 0 && ( - {formatCompact(locale, unlock.cost.value)} + {formatCompact(locale, unlock.cost!.value)} {unlock.cost.type} { - if (unlock.type === ModuleType.TURRET) { + if (unlock.type === ModuleType.MODULE_TYPE_TURRET) { draft.protagonist.turret = draft.protagonist.tank.turrets.find( - (turret) => turret.id === unlock.id + (turret) => turret.id === unlock.id, )!; // Check if current gun exists in new turret const gunInNewTurret = draft.protagonist.turret.guns.find( - (gun) => gun.id === draft.protagonist.gun.id + (gun) => gun.id === draft.protagonist.gun.id, ); - + if (gunInNewTurret) { // Gun exists - get it FROM this turret draft.protagonist.gun = gunInNewTurret; @@ -190,9 +190,9 @@ export function Modules() { draft.protagonist.gun = draft.protagonist.turret.guns.at(-1)!; draft.protagonist.shell = draft.protagonist.gun.shells[0]; } - } else if (unlock.type === ModuleType.GUN) { + } else if (unlock.type === ModuleType.MODULE_TYPE_GUN) { const gunInTurret = draft.protagonist.turret.guns.find( - (gun) => gun.id === unlock.id + (gun) => gun.id === unlock.id, ); if (gunInTurret) { draft.protagonist.gun = gunInTurret; @@ -200,23 +200,23 @@ export function Modules() { } else { // TODO: warn somehow? const suitableTurret = draft.protagonist.tank.turrets.find((turret) => - turret.guns.some((gun) => gun.id === unlock.id) + turret.guns.some((gun) => gun.id === unlock.id), )!; const gunInSuitableTurret = suitableTurret.guns.find( - (gun) => gun.id === unlock.id + (gun) => gun.id === unlock.id, )!; draft.protagonist.turret = suitableTurret; draft.protagonist.gun = gunInSuitableTurret; draft.protagonist.shell = gunInSuitableTurret.shells[0]; } - } else if (unlock.type === ModuleType.ENGINE) { + } else if (unlock.type === ModuleType.MODULE_TYPE_ENGINE) { draft.protagonist.engine = draft.protagonist.tank.engines.find( - (engine) => engine.id === unlock.id + (engine) => engine.id === unlock.id, )!; - } else if (unlock.type === ModuleType.TRACKS) { + } else if (unlock.type === ModuleType.MODULE_TYPE_TRACKS) { draft.protagonist.track = draft.protagonist.tank.tracks.find( - (track) => track.id === unlock.id + (track) => track.id === unlock.id, )!; } }); @@ -231,19 +231,19 @@ export function Modules() { const central = !first && !last; let module: ModuleDefinition | TankDefinition | undefined = undefined; - if (unlock.type === ModuleType.TRACKS) { + if (unlock.type === ModuleType.MODULE_TYPE_TRACKS) { module = tank.tracks.find((track) => track.id === unlock.id)!; - } else if (unlock.type === ModuleType.ENGINE) { + } else if (unlock.type === ModuleType.MODULE_TYPE_ENGINE) { module = tank.engines.find((engine) => engine.id === unlock.id)!; - } else if (unlock.type === ModuleType.TURRET) { + } else if (unlock.type === ModuleType.MODULE_TYPE_TURRET) { module = tank.turrets.find((turret) => turret.id === unlock.id)!; - } else if (unlock.type === ModuleType.GUN) { + } else if (unlock.type === ModuleType.MODULE_TYPE_GUN) { module = tank.turrets .find((turret) => - turret.guns.some((gun) => gun.id === unlock.id) + turret.guns.some((gun) => gun.id === unlock.id), )! .guns.find((gun) => gun.id === unlock.id)!; - } else if (unlock.type === ModuleType.VEHICLE) { + } else if (unlock.type === ModuleType.MODULE_TYPE_VEHICLE) { module = tankDefinitions.tanks[unlock.id]; } @@ -257,7 +257,7 @@ export function Modules() { gap="2" position="relative" > - {unlock.cost.value > 0 && ( + {unlock.cost!.value > 0 && ( <> {unlocks.length > 1 && (
); @@ -397,32 +397,32 @@ export function Modules() { - {tree(ModuleType.ENGINE, [ + {tree(ModuleType.MODULE_TYPE_ENGINE, [ { cost: { type: "xp", value: 0 }, id: engine0.id, - type: ModuleType.ENGINE, + type: ModuleType.MODULE_TYPE_ENGINE, }, ])} - {tree(ModuleType.TRACKS, [ + {tree(ModuleType.MODULE_TYPE_TRACKS, [ { cost: { type: "xp", value: 0 }, id: track0.id, - type: ModuleType.TRACKS, + type: ModuleType.MODULE_TYPE_TRACKS, }, ])} - {tree(ModuleType.TURRET, [ + {tree(ModuleType.MODULE_TYPE_TURRET, [ { cost: { type: "xp", value: 0 }, id: turret0.id, - type: ModuleType.TURRET, + type: ModuleType.MODULE_TYPE_TURRET, }, ])} - {tree(ModuleType.GUN, [ + {tree(ModuleType.MODULE_TYPE_GUN, [ { cost: { type: "xp", value: 0 }, id: gun0.id, - type: ModuleType.GUN, + type: ModuleType.MODULE_TYPE_GUN, }, ])} diff --git a/packages/website/src/components/Tankopedia/GameModeSection.tsx b/packages/website/src/components/Tankopedia/GameModeSection.tsx index b45b5b2aa..a43a3fb94 100644 --- a/packages/website/src/components/Tankopedia/GameModeSection.tsx +++ b/packages/website/src/components/Tankopedia/GameModeSection.tsx @@ -41,7 +41,7 @@ export function GameModeSection() { style={{ borderRadius: "var(--radius-3)", background: `url(${asset( - `icons/game_mode_banners/${id}.webp` + `icons/game_mode_banners/${id}.webp`, )})`, backgroundSize: "cover", backgroundPosition: "center", @@ -51,7 +51,7 @@ export function GameModeSection() { flexGrow="1" style={{ background: `url(${asset( - `icons/game_mode_banners/${id}.webp` + `icons/game_mode_banners/${id}.webp`, )})`, backgroundSize: "cover", backgroundPosition: "center", @@ -71,7 +71,7 @@ export function GameModeSection() { justify="center" > - {unwrap(gameMode.name)} + {unwrap(gameMode.name!)} @@ -88,9 +88,9 @@ export function GameModeSection() { objectFit: "contain", }} src={asset(`icons/provisions/${id}.webp`)} - alt={unwrap(provisions.name)} + alt={unwrap(provisions.name!)} /> - {unwrap(provisions.name)} + {unwrap(provisions.name!)} ); @@ -109,9 +109,9 @@ export function GameModeSection() { objectFit: "contain", }} src={asset(`icons/consumables/${id}.webp`)} - alt={unwrap(consumable.name)} + alt={unwrap(consumable.name!)} /> - {unwrap(consumable.name)} + {unwrap(consumable.name!)} ); diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/CustomShellButton.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/CustomShellButton.tsx index 4a02f6a3b..95a04c441 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/CustomShellButton.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/Options/components/CustomShellButton.tsx @@ -68,29 +68,29 @@ export function CustomShellButton() { const modified = { ...customShell, type }; switch (type) { - case ShellType.AP: { + case ShellType.SHELL_TYPE_AP: { modified.normalization = 5; modified.ricochet = 70; modified.explosion_radius = undefined; break; } - case ShellType.APCR: { + case ShellType.SHELL_TYPE_APCR: { modified.normalization = 2; modified.ricochet = 70; modified.explosion_radius = undefined; break; } - case ShellType.HEAT: { + case ShellType.SHELL_TYPE_HEAT: { modified.normalization = undefined; modified.ricochet = undefined; modified.explosion_radius = undefined; } - case ShellType.HE: { + case ShellType.SHELL_TYPE_HE: { modified.normalization = undefined; modified.ricochet = undefined; modified.explosion_radius = gun.shells.find( - (shell) => shell.type === ShellType.HE + (shell) => shell.type === ShellType.SHELL_TYPE_HE, )?.explosion_radius ?? 1; break; } @@ -104,16 +104,16 @@ export function CustomShellButton() { - + {strings.common.shells.ap} - + {strings.common.shells.ap_cr} - + {strings.common.shells.hc} - + {strings.common.shells.he} @@ -166,11 +166,11 @@ export function CustomShellButton() { ) => { Tankopedia.mutate((draft) => { - draft.customShell!.penetration.near = + draft.customShell!.penetration!.near = event.target.valueAsNumber; }); }} @@ -182,7 +182,7 @@ export function CustomShellButton() { (event.target as HTMLInputElement).blur(); } else if (event.key === "Escape") { (event.target as HTMLInputElement).valueAsNumber = - customShell.penetration.near; + customShell.penetration!.near; (event.target as HTMLInputElement).blur(); } }} @@ -193,8 +193,8 @@ export function CustomShellButton() { - {(customShell.type === ShellType.AP || - customShell.type === ShellType.APCR) && ( + {(customShell.type === ShellType.SHELL_TYPE_AP || + customShell.type === ShellType.SHELL_TYPE_APCR) && ( <> @@ -264,7 +264,7 @@ export function CustomShellButton() { )} - {customShell.type === ShellType.HE && ( + {customShell.type === ShellType.SHELL_TYPE_HE && ( Explosion radius + event: QuicklimeEvent, ) { syncInputValues(event.data); } @@ -77,7 +77,7 @@ export function QuickInputs() { if (isNaN(value)) { yawInput.current!.value = radToDeg( - modelTransformEvent.last!.yaw + modelTransformEvent.last!.yaw, ).toFixed(1); return; } @@ -85,15 +85,15 @@ export function QuickInputs() { const [pitch, yaw] = applyPitchYawLimits( modelTransformEvent.last!.pitch, degToRad(value), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); yawInput.current!.value = radToDeg( - modelTransformEvent.last!.yaw + modelTransformEvent.last!.yaw, ).toFixed(1); }} onKeyDown={(event) => { @@ -129,10 +129,10 @@ export function QuickInputs() { const [pitch, yaw] = applyPitchYawLimits( degToRad(value + initialGunPitch), modelTransformEvent.last!.yaw, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); pitchInput.current!.value = ( diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/Options/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/Options/index.tsx index 02becaed7..15133b1f1 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/Options/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/Options/index.tsx @@ -54,12 +54,12 @@ type OptionsProps = MaybeSkeletonComponentProps & { export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) { const hasCustomShell = Tankopedia.use( - (state) => state.customShell !== undefined + (state) => state.customShell !== undefined, ); const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay); const isFullScreen = useFullScreen(); const advancedHighlighting = TankopediaPersistent.use( - (state) => state.advancedHighlighting + (state) => state.advancedHighlighting, ); const fullScreenAvailable = useFullscreenAvailability(true); const protagonistTank = Duel.use((state) => state.protagonist.tank); @@ -102,8 +102,8 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) { value: ( resolvePenetrationCoefficient( hasCalibratedShells, - antagonistShell.type - ) * antagonistShell.penetration.near + antagonistShell.type, + ) * antagonistShell.penetration!.near ).toFixed(0), })} @@ -203,7 +203,7 @@ export function Options({ thicknessRange, canvas, skeleton }: OptionsProps) { }} > {unwrap(thisShell.name)} diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/Title/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/Title/index.tsx index aec46a961..694d24f12 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/Title/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/Title/index.tsx @@ -9,7 +9,7 @@ export function Title() { const protagonist = Duel.use((state) => state.protagonist.tank); const revealed = Tankopedia.use((state) => state.revealed); const disturbed = Tankopedia.use((state) => state.disturbed); - const name = unwrap(protagonist.name); + const name = unwrap(protagonist.name!); const fontSize = revealed ? disturbed ? "1.5rem" diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx index 20bfd72e6..191745600 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx @@ -53,24 +53,24 @@ export function Controls({ const protagonistGunModelDefinition = protagonistTurretModelDefinition.guns[protagonistGun.id]; const protagonistHullOrigin = new Vector3( - protagonistTrackModelDefinition.origin.x, - protagonistTrackModelDefinition.origin.y, - -protagonistTrackModelDefinition.origin.z, + protagonistTrackModelDefinition.origin!.x, + protagonistTrackModelDefinition.origin!.y, + -protagonistTrackModelDefinition.origin!.z, ); const protagonistTurretOrigin = new Vector3( - protagonistModelDefinition.turret_origin.x, - protagonistModelDefinition.turret_origin.y, - -protagonistModelDefinition.turret_origin.z, + protagonistModelDefinition.turret_origin!.x, + protagonistModelDefinition.turret_origin!.y, + -protagonistModelDefinition.turret_origin!.z, ); const protagonistGunOrigin = new Vector3( - protagonistTurretModelDefinition.gun_origin.x, - protagonistTurretModelDefinition.gun_origin.y, - -protagonistTurretModelDefinition.gun_origin.z, + protagonistTurretModelDefinition.gun_origin!.x, + protagonistTurretModelDefinition.gun_origin!.y, + -protagonistTurretModelDefinition.gun_origin!.z, ); const antagonistGunHeight = - protagonistTrackModelDefinition.origin.y + - antagonistModelDefinition.turret_origin.y + - antagonistTurretModelDefinition.gun_origin.y; + protagonistTrackModelDefinition.origin!.y + + antagonistModelDefinition.turret_origin!.y + + antagonistTurretModelDefinition.gun_origin!.y; const disturbed = Tankopedia.use((state) => state.disturbed); const doAutoRotate = autoRotate && !disturbed; const gunHeight = @@ -119,7 +119,7 @@ export function Controls({ const [pitch] = applyPitchYawLimits( -Infinity, 0, - protagonistGunModelDefinition.pitch, + protagonistGunModelDefinition.pitch!, protagonistTurretModelDefinition.yaw, hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer, @@ -152,7 +152,7 @@ export function Controls({ const [pitch] = applyPitchYawLimits( 0, 0, - protagonistGunModelDefinition.pitch, + protagonistGunModelDefinition.pitch!, protagonistTurretModelDefinition.yaw, hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer, diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/InitialAligner.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/InitialAligner.tsx index d10570756..26eb65286 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/InitialAligner.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/InitialAligner.tsx @@ -1,9 +1,9 @@ -import { useEffect } from 'react'; -import { degToRad } from 'three/src/math/MathUtils.js'; -import { awaitableModelDefinitions } from '../../../../../../core/awaitables/modelDefinitions'; -import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits'; -import { modelTransformEvent } from '../../../../../../core/blitzkit/modelTransform'; -import { Duel } from '../../../../../../stores/duel'; +import { useEffect } from "react"; +import { degToRad } from "three/src/math/MathUtils.js"; +import { awaitableModelDefinitions } from "../../../../../../core/awaitables/modelDefinitions"; +import { applyPitchYawLimits } from "../../../../../../core/blitz/applyPitchYawLimits"; +import { modelTransformEvent } from "../../../../../../core/blitzkit/modelTransform"; +import { Duel } from "../../../../../../stores/duel"; const modelDefinitions = await awaitableModelDefinitions; @@ -20,7 +20,7 @@ export function InitialAligner() { const [pitch, yaw] = applyPitchYawLimits( degToRad(8), degToRad(25), - gunModel.pitch, + gunModel.pitch!, turretModel.yaw, ); diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx index 54835be29..ded24bba1 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx @@ -134,12 +134,12 @@ export function TankModel() { const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const boundingRect = canvas.getBoundingClientRect(); @@ -150,10 +150,10 @@ export function TankModel() { modelTransformEvent.last!.pitch, modelTransformEvent.last!.yaw + delta.x * (Math.PI / boundingRect.width), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); } @@ -217,12 +217,12 @@ export function TankModel() { const hasImprovedVerticalStabilizer = hasEquipment( 122, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const hasDownImprovedVerticalStabilizer = hasEquipment( 124, Duel.state.protagonist.tank.equipment_preset, - Duel.state.protagonist.equipmentMatrix + Duel.state.protagonist.equipmentMatrix, ); const boundingRect = canvas.getBoundingClientRect(); delta.set(event.clientX, event.clientY).sub(position); @@ -231,10 +231,10 @@ export function TankModel() { [pitch, yaw] = applyPitchYawLimits( pitch - delta.y * (Math.PI / boundingRect.height), yaw + delta.x * (Math.PI / boundingRect.width), - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer + hasDownImprovedVerticalStabilizer, ); modelTransformEvent.dispatch({ pitch, yaw }); } diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TransitionSkeleton/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TransitionSkeleton/index.tsx index 17bb58fa6..5171f6258 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TransitionSkeleton/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TransitionSkeleton/index.tsx @@ -37,9 +37,9 @@ export function TransitionSkeleton() { const gunModelDefinition = turretModelDefinition.guns[gun.id]; const trackModelDefinition = tankModelDefinition.tracks[track.id]; const wrapper = useRef(null); - const hullOrigin = correctZYTuple(trackModelDefinition.origin); - const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin); - const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin); + const hullOrigin = correctZYTuple(trackModelDefinition.origin!); + const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!); + const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!); useTankTransform(track, turret, turretContainer, gunContainer); @@ -77,7 +77,7 @@ export function TransitionSkeleton() { {armorNodes.map((node) => { const isCurrentTurret = node.name.startsWith( - `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}` + `turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentTurret; if (!isVisible) { @@ -102,7 +102,7 @@ export function TransitionSkeleton() { {armorNodes.map((node) => { const isCurrentGun = node.name.startsWith( - `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}` + `gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`, ); const isVisible = isCurrentGun; diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx index 591889a9b..b8b7dcdfa 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx @@ -73,7 +73,7 @@ export const TankSandbox = forwardRef( const [pitch, yaw] = applyPitchYawLimits( -Infinity, 0, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer, @@ -88,7 +88,7 @@ export const TankSandbox = forwardRef( const [pitch, yaw] = applyPitchYawLimits( Infinity, 0, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, ); @@ -102,7 +102,7 @@ export const TankSandbox = forwardRef( const [pitch, yaw] = applyPitchYawLimits( 0, 0, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, ); @@ -124,7 +124,7 @@ export const TankSandbox = forwardRef( const [pitch, yaw] = applyPitchYawLimits( modelTransformEvent.last!.pitch, modelTransformEvent.last!.yaw, - gunModelDefinition.pitch, + gunModelDefinition.pitch!, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, ); diff --git a/packages/website/src/components/Tankopedia/HeroSection/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/index.tsx index d40a25583..6202b7451 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/index.tsx @@ -22,13 +22,13 @@ export function HeroSection({ skeleton }: MaybeSkeletonComponentProps) { const thicknessRange = useMemo(() => { const entries = Object.values(tankDefinitions.tanks); const filtered = entries.filter( - (thisTank) => thisTank.tier === protagonist.tier + (thisTank) => thisTank.tier === protagonist.tier, ); const value = (filtered.reduce((accumulator, thisTank) => { return ( accumulator + - thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration.near + thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near ); }, 0) / filtered.length) * @@ -99,11 +99,11 @@ export function HeroSection({ skeleton }: MaybeSkeletonComponentProps) { isFullScreen ? "100vh" : disturbed - ? "calc(100svh - 8rem)" - : { - initial: "28rem", - md: "calc(100svh - 14rem)", - } + ? "calc(100svh - 8rem)" + : { + initial: "28rem", + md: "calc(100svh - 14rem)", + } } maxWidth={isFullScreen ? undefined : "120rem"} flexGrow="1" diff --git a/packages/website/src/components/Tankopedia/MetaSection/components/Votes/components/VoteCaster.tsx b/packages/website/src/components/Tankopedia/MetaSection/components/Votes/components/VoteCaster.tsx index 0c4b767c3..a036259cb 100644 --- a/packages/website/src/components/Tankopedia/MetaSection/components/Votes/components/VoteCaster.tsx +++ b/packages/website/src/components/Tankopedia/MetaSection/components/Votes/components/VoteCaster.tsx @@ -36,7 +36,7 @@ export function VoteCaster() { - Voting for {unwrap(tank.name)} + Voting for {unwrap(tank.name!)} @@ -118,10 +118,10 @@ export function VoteCaster() { survivability === null ? "" : `survivability=${survivability}&` - }player=${wargaming.id}&token=${wargaming.token}` + }player=${wargaming.id}&token=${wargaming.token}`, ) .then( - (response) => response.json() as Promise + (response) => response.json() as Promise, ) .then((json) => { setShowDialogue(false); diff --git a/packages/website/src/components/Tankopedia/MetaSection/index.tsx b/packages/website/src/components/Tankopedia/MetaSection/index.tsx index 03e15e7bc..d795d1926 100644 --- a/packages/website/src/components/Tankopedia/MetaSection/index.tsx +++ b/packages/website/src/components/Tankopedia/MetaSection/index.tsx @@ -3,20 +3,20 @@ import { TankPriceType, TankType, TIER_ROMAN_NUMERALS, -} from '@blitzkit/core'; -import { Box, Flex } from '@radix-ui/themes'; -import { Var } from '../../../core/radix/var'; -import { useLocale } from '../../../hooks/useLocale'; -import { App } from '../../../stores/app'; -import { Duel } from '../../../stores/duel'; -import { classIcons } from '../../ClassIcon'; -import { CopyableCode } from '../../CopyableCode'; -import { Listing } from './components/Listing'; +} from "@blitzkit/core"; +import { Box, Flex } from "@radix-ui/themes"; +import { Var } from "../../../core/radix/var"; +import { useLocale } from "../../../hooks/useLocale"; +import { App } from "../../../stores/app"; +import { Duel } from "../../../stores/duel"; +import { classIcons } from "../../ClassIcon"; +import { CopyableCode } from "../../CopyableCode"; +import { Listing } from "./components/Listing"; const NATIONAL_BANNER_POSITION_OVERRIDES: Record = { - germany: '50% 35%', - france: '50% 35%', - other: '50% 35%', + germany: "50% 35%", + france: "50% 35%", + other: "50% 35%", }; export function MetaSection() { @@ -30,10 +30,10 @@ export function MetaSection() { {protagonist.nation} @@ -86,10 +86,10 @@ export function MetaSection() { @@ -117,7 +117,7 @@ export function MetaSection() { label={strings.website.tools.tankopedia.meta.dev_name} > )} - {protagonist.type === TankType.PREMIUM && ( + {protagonist.type === TankType.TANK_TYPE_PREMIUM && ( - {protagonist.price.value / 400} + {protagonist.price!.value / 400} gold )} - {protagonist.price.value.toLocaleString(locale)} + {protagonist.price!.value.toLocaleString(locale)} {TankPriceType[protagonist.price.type]} @@ -164,15 +165,16 @@ export function MetaSection() { - {(protagonist.price.value / 2).toLocaleString(locale)} + {(protagonist.price!.value / 2).toLocaleString(locale)} {TankPriceType[protagonist.price.type]} @@ -188,9 +190,9 @@ export function MetaSection() { .value as number ).toLocaleString(locale)} xp diff --git a/packages/website/src/components/Tankopedia/TechTreeSection/components/Node.tsx b/packages/website/src/components/Tankopedia/TechTreeSection/components/Node.tsx index 3c2205e06..9a6ceb7f7 100644 --- a/packages/website/src/components/Tankopedia/TechTreeSection/components/Node.tsx +++ b/packages/website/src/components/Tankopedia/TechTreeSection/components/Node.tsx @@ -36,7 +36,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) { ? 0 : (tank.research_cost.research_cost_type!.value as number) / xpMultiplier), - 0 + 0, ); const averages = averageDefinitions.averages[tank.id]?.mu; const averageXp = averages ? averages.xp / averages.battles : undefined; @@ -78,7 +78,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) { }} > {unwrap(tank.name)} {TIER_ROMAN_NUMERALS[tank.tier]} - {unwrap(tank.name)} + {unwrap(tank.name!)} @@ -122,7 +122,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) { objectPosition: "center", }} /> - {formatCompact(locale, tank.price.value)} + {formatCompact(locale, tank.price!.value)} @@ -135,7 +135,7 @@ export function Node({ id, highlight, nextIds, skeleton }: NodeProps) { ? strings.website.tools.tankopedia.tech_tree.battle : literals( strings.website.tools.tankopedia.tech_tree.battles, - { count: games } + { count: games }, ))} )} diff --git a/packages/website/src/components/Tankopedia/TechTreeSection/index.tsx b/packages/website/src/components/Tankopedia/TechTreeSection/index.tsx index 2f83cb9ac..8c7a906f2 100644 --- a/packages/website/src/components/Tankopedia/TechTreeSection/index.tsx +++ b/packages/website/src/components/Tankopedia/TechTreeSection/index.tsx @@ -26,14 +26,18 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) { function extend(line: Line): Line[] { const root = tankDefinitions.tanks[line.at(-1)!]; - if (root.ancestors === undefined || root.ancestors.length === 0 || root.tier === 1) { + if ( + root.ancestors === undefined || + root.ancestors.length === 0 || + root.tier === 1 + ) { return [line]; } else { if (root.ancestors.length === 1 || root.tier === 2) { line.push( root.ancestors.find( - (ancestor) => !tankDefinitions.tanks[ancestor].deprecated - ) ?? root.ancestors[0] + (ancestor) => !tankDefinitions.tanks[ancestor].deprecated, + ) ?? root.ancestors[0], ); return extend(line); } else { @@ -52,7 +56,7 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) { const [lineIndex, setLineIndex] = useState(0); const line = useMemo( () => (lines.length === 0 ? [master.id] : [...lines[lineIndex]].reverse()), - [master, lineIndex] + [master, lineIndex], ); const totalXp = line.reduce( (xp, id) => @@ -62,11 +66,11 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) { ? 0 : (tankDefinitions.tanks[id].research_cost.research_cost_type! .value as number)), - 0 + 0, ); const totalCredits = line.reduce( - (credits, id) => credits + tankDefinitions.tanks[id].price.value, - 0 + (credits, id) => credits + tankDefinitions.tanks[id].price!.value, + 0, ); useEffect(() => { @@ -75,7 +79,7 @@ export function TechTreeSection({ skeleton }: MaybeSkeletonComponentProps) { }); if ( - master.type !== TankType.RESEARCHABLE || + master.type !== TankType.TANK_TYPE_RESEARCHABLE || master.ancestors === undefined || master.ancestors.length === 0 ) { diff --git a/packages/website/src/components/TanksEmbed.tsx b/packages/website/src/components/TanksEmbed.tsx index 6172801d7..a68d4b57e 100644 --- a/packages/website/src/components/TanksEmbed.tsx +++ b/packages/website/src/components/TanksEmbed.tsx @@ -5,20 +5,20 @@ import { TankType, type CompositeStats, type CompositeStatsKey, -} from '@blitzkit/core'; -import strings from '@blitzkit/i18n/strings/en.json'; -import { amberDark, blueDark } from '@radix-ui/colors'; -import { Flex, Text, type FlexProps } from '@radix-ui/themes'; -import { times } from 'lodash-es'; -import type { ReactNode } from 'react'; -import { breakdownConfig } from '../constants/embeds'; -import { toRadiusVar } from '../core/radix/utils'; -import { useLocale } from '../hooks/useLocale'; -import { useEmbedStateCurry } from '../stores/embedState/utilities'; -import { ClassHeavy } from './ClassIcon/components/ClassHeavy'; -import { ClassLight } from './ClassIcon/components/ClassLight'; -import { ClassMedium } from './ClassIcon/components/ClassMedium'; -import { ClassTankDestroyer } from './ClassIcon/components/ClassTankDestroyer'; +} from "@blitzkit/core"; +import strings from "@blitzkit/i18n/strings/en.json"; +import { amberDark, blueDark } from "@radix-ui/colors"; +import { Flex, Text, type FlexProps } from "@radix-ui/themes"; +import { times } from "lodash-es"; +import type { ReactNode } from "react"; +import { breakdownConfig } from "../constants/embeds"; +import { toRadiusVar } from "../core/radix/utils"; +import { useLocale } from "../hooks/useLocale"; +import { useEmbedStateCurry } from "../stores/embedState/utilities"; +import { ClassHeavy } from "./ClassIcon/components/ClassHeavy"; +import { ClassLight } from "./ClassIcon/components/ClassLight"; +import { ClassMedium } from "./ClassIcon/components/ClassMedium"; +import { ClassTankDestroyer } from "./ClassIcon/components/ClassTankDestroyer"; type BreakdownEmbedWrapperProps = FlexProps & { children: ReactNode; @@ -33,7 +33,7 @@ export function BreakdownEmbedWrapper({ return ( @@ -60,65 +60,65 @@ export function BreakdownEmbedCard({ flexShrink="0" direction="column" style={{ - borderRadius: toRadiusVar(useEmbedState('cardRadius')), - overflow: 'hidden', - backgroundColor: useEmbedState('cardBodyBackgroundColor'), + borderRadius: toRadiusVar(useEmbedState("cardRadius")), + overflow: "hidden", + backgroundColor: useEmbedState("cardBodyBackgroundColor"), }} > - {useEmbedState('cardTitleClassIcon') && + {useEmbedState("cardTitleClassIcon") && tank !== null && tank !== undefined && ( <> - {tank.class === TankClass.LIGHT && ( + {tank.class === TankClass.TANK_CLASS_LIGHT && ( )} - {tank.class === TankClass.MEDIUM && ( + {tank.class === TankClass.TANK_CLASS_MEDIUM && ( )} - {tank.class === TankClass.HEAVY && ( + {tank.class === TankClass.TANK_CLASS_HEAVY && ( )} - {tank.class === TankClass.TANK_DESTROYER && ( + {tank.class === TankClass.TANK_CLASS_TANK_DESTROYER && ( )} - )}{' '} + )}{" "} {tank === null - ? 'Total' + ? "Total" : tank === undefined ? `Unknown tank` - : unwrap(tank.name)} + : unwrap(tank.name!)} - + {times(4, (index) => { const column = (index + 1) as 1 | 2 | 3 | 4; const statKey = useEmbedState(`column${column}`) as CompositeStatsKey; @@ -129,13 +129,13 @@ export function BreakdownEmbedCard({ key={column} direction="column" align="center" - gap={useEmbedState('columnGap')} + gap={useEmbedState("columnGap")} flexGrow="1" > - + {formatCompositeStat(composite[statKey], statKey, composite)} - + {customLabel.length === 0 ? strings.common.composite_stats[statKey] : customLabel} diff --git a/packages/website/src/core/blitzkit/tankCharacteristics.ts b/packages/website/src/core/blitzkit/tankCharacteristics.ts index ccff1c836..a45d01fbf 100644 --- a/packages/website/src/core/blitzkit/tankCharacteristics.ts +++ b/packages/website/src/core/blitzkit/tankCharacteristics.ts @@ -143,22 +143,28 @@ export function tankCharacteristics( const commanderMastery = 1 + provisionCrewBonus; const loaderMastery = commanderMastery * - (tank.crew.some(({ type }) => type === CrewType.LOADER) ? 1.1 : 1.05); + (tank.crew.some(({ type }) => type === CrewType.CREW_TYPE_LOADER) + ? 1.1 + : 1.05); const gunnerMastery = commanderMastery * - (tank.crew.some(({ type }) => type === CrewType.GUNNER) ? 1.1 : 1.05); + (tank.crew.some(({ type }) => type === CrewType.CREW_TYPE_GUNNER) + ? 1.1 + : 1.05); const driverMastery = commanderMastery * - (tank.crew.some(({ type }) => type === CrewType.DRIVER) ? 1.1 : 1.05); + (tank.crew.some(({ type }) => type === CrewType.CREW_TYPE_DRIVER) + ? 1.1 + : 1.05); const intraClipCoefficient = coefficient([hasShellReloadBoost, -0.3]); const burstShells = gun.burst?.count ?? 1; const burstInterShell = gun.burst?.interval; const armorDamageCoefficient = coefficient([hasTungsten, 0.15]) * coefficient( - [applyReactiveArmor && shell.type !== ShellType.HE, -0.27], + [applyReactiveArmor && shell.type !== ShellType.SHELL_TYPE_HE, -0.27], [applyDynamicArmor, -0.1], - [applySpallLiner && shell.type === ShellType.HE, -0.2], + [applySpallLiner && shell.type === ShellType.SHELL_TYPE_HE, -0.2], ); const assaultDamageCoefficient = gun.assault_ranges && gun.assault_ranges.types.includes(shell.type) @@ -215,7 +221,8 @@ export function tankCharacteristics( const enginePowerCoefficient = coefficient( [ hasEngineAccelerator, - tank.class === TankClass.HEAVY || tank.class === TankClass.TANK_DESTROYER + tank.class === TankClass.TANK_CLASS_HEAVY || + tank.class === TankClass.TANK_CLASS_TANK_DESTROYER ? 0.05 : 0.04, ], @@ -250,11 +257,11 @@ export function tankCharacteristics( const viewRangeCoefficient = coefficient([ hasImprovedOptics, - tank.class === TankClass.HEAVY + tank.class === TankClass.TANK_CLASS_HEAVY ? 0.06 - : tank.class === TankClass.MEDIUM + : tank.class === TankClass.TANK_CLASS_MEDIUM ? 0.08 - : tank.class === TankClass.LIGHT + : tank.class === TankClass.TANK_CLASS_LIGHT ? 0.11 : 0.04, ]) * coefficient([true, progressiveStat(commanderMastery)]); @@ -275,20 +282,20 @@ export function tankCharacteristics( true, coefficient([ camouflage, - tank.class === TankClass.TANK_DESTROYER + tank.class === TankClass.TANK_CLASS_TANK_DESTROYER ? 0.04 - : tank.class === TankClass.HEAVY + : tank.class === TankClass.TANK_CLASS_HEAVY ? 0.03 : 0.02, ]), ], [ hasCamouflageNet, - tank.class === TankClass.HEAVY + tank.class === TankClass.TANK_CLASS_HEAVY ? 0.02 - : tank.class === TankClass.MEDIUM + : tank.class === TankClass.TANK_CLASS_MEDIUM ? 0.04 - : tank.class === TankClass.LIGHT + : tank.class === TankClass.TANK_CLASS_LIGHT ? 0.07 : 0.1, ], @@ -299,9 +306,9 @@ export function tankCharacteristics( coefficient( [ camouflage, - tank.class === TankClass.TANK_DESTROYER + tank.class === TankClass.TANK_CLASS_TANK_DESTROYER ? 0.04 - : tank.class === TankClass.HEAVY + : tank.class === TankClass.TANK_CLASS_HEAVY ? 0.03 : 0.02, ], @@ -310,11 +317,11 @@ export function tankCharacteristics( ], [ hasCamouflageNet, - tank.class === TankClass.HEAVY + tank.class === TankClass.TANK_CLASS_HEAVY ? 0.04 - : tank.class === TankClass.MEDIUM + : tank.class === TankClass.TANK_CLASS_MEDIUM ? 0.08 - : tank.class === TankClass.LIGHT + : tank.class === TankClass.TANK_CLASS_LIGHT ? 0.14 : 0.2, ], @@ -322,8 +329,8 @@ export function tankCharacteristics( const size = normalizeBoundingBox( unionBoundingBox( - tankModelDefinition.bounding_box, - turretModelDefinition.bounding_box, + tankModelDefinition.bounding_box!, + turretModelDefinition.bounding_box!, ), ); const weightKg = @@ -408,7 +415,7 @@ export function tankCharacteristics( ? gun.gun_type!.value.reload : gun.gun_type!.value.clip_reload) * reloadCoefficient; const caliber = shell.caliber; - const penetration = shell.penetration.near * penetrationCoefficient; + const penetration = shell.penetration!.near * penetrationCoefficient; const clipDamage = gun.gun_type!.$case === "regular" ? undefined @@ -428,21 +435,21 @@ export function tankCharacteristics( const dispersionGunDamaged = gun.dispersion_damaged * dispersionDamagedCoefficient; const gunDepression = - gunModelDefinition.pitch.max + + gunModelDefinition.pitch!.max + gunDefaultPitch + (hasImprovedVerticalStabilizer ? 3 : 0) + (hasDownImprovedVerticalStabilizer ? 3 : 0); const gunElevation = - -gunModelDefinition.pitch.min - + -gunModelDefinition.pitch!.min - gunDefaultPitch + (hasImprovedVerticalStabilizer ? 4 : 0); - const gunFrontalDepression = gunModelDefinition.pitch.front?.max; - const gunFrontalElevation = gunModelDefinition.pitch.front - ? -gunModelDefinition.pitch.front.min + const gunFrontalDepression = gunModelDefinition.pitch!.front?.max; + const gunFrontalElevation = gunModelDefinition.pitch!.front + ? -gunModelDefinition.pitch!.front.min : undefined; - const gunRearDepression = gunModelDefinition.pitch.back?.max; - const gunRearElevation = gunModelDefinition.pitch.back - ? -gunModelDefinition.pitch.back.min + const gunRearDepression = gunModelDefinition.pitch!.back?.max; + const gunRearElevation = gunModelDefinition.pitch!.back + ? -gunModelDefinition.pitch!.back.min : undefined; const azimuthLeft = turretModelDefinition.yaw ? -turretModelDefinition.yaw.min @@ -496,18 +503,20 @@ export function tankCharacteristics( const viewRange = turret.view_range * viewRangeCoefficient; const camouflageStill = tank.camouflage_still * camouflageCoefficientStill; const camouflageMoving = - tank.class === TankClass.LIGHT + tank.class === TankClass.TANK_CLASS_LIGHT ? tank.camouflage_still * camouflageCoefficientStill : tank.camouflage_moving * camouflageCoefficientMoving; const camouflageShootingStill = tank.camouflage_still * gun.camouflage_loss * camouflageCoefficientStill; const camouflageShootingMoving = - (tank.class === TankClass.LIGHT + (tank.class === TankClass.TANK_CLASS_LIGHT ? tank.camouflage_still * camouflageCoefficientStill : tank.camouflage_moving * camouflageCoefficientMoving) * gun.camouflage_loss; const camouflageCaughtOnFire = - tank.camouflage_onFire * tank.camouflage_still * camouflageCoefficientStill; + tank.camouflage_on_fire * + tank.camouflage_still * + camouflageCoefficientStill; const width = size.z; const height = size.x; const length = size.y; @@ -518,7 +527,7 @@ export function tankCharacteristics( const shellRange = shell.range; const shellCapacity = gun.shell_capacity; const gunType = gun.gun_type!.$case; - const penetrationAt250m = shell.penetration.far; + const penetrationAt250m = shell.penetration!.far; return { crewCount, diff --git a/packages/website/src/hooks/useAveragesExclusionRatio.ts b/packages/website/src/hooks/useAveragesExclusionRatio.ts index 265925d4a..e5fd5ba84 100644 --- a/packages/website/src/hooks/useAveragesExclusionRatio.ts +++ b/packages/website/src/hooks/useAveragesExclusionRatio.ts @@ -1,5 +1,5 @@ -import { awaitableAverageDefinitions } from '../core/awaitables/averageDefinitions'; -import { awaitableDiscoveredIdsDefinitions } from '../core/awaitables/discoveredIdsDefinitions'; +import { awaitableAverageDefinitions } from "../core/awaitables/averageDefinitions"; +import { awaitableDiscoveredIdsDefinitions } from "../core/awaitables/discoveredIdsDefinitions"; const [discoveredIdsDefinitions, averageDefinitions] = await Promise.all([ awaitableDiscoveredIdsDefinitions, @@ -7,5 +7,5 @@ const [discoveredIdsDefinitions, averageDefinitions] = await Promise.all([ ]); export function useAveragesExclusionRatio() { - return discoveredIdsDefinitions.count / averageDefinitions.samples.total; + return discoveredIdsDefinitions.count / averageDefinitions.samples!.total; } diff --git a/packages/website/src/hooks/useTankTransform.ts b/packages/website/src/hooks/useTankTransform.ts index 2f68b8e3a..be26cb6be 100644 --- a/packages/website/src/hooks/useTankTransform.ts +++ b/packages/website/src/hooks/useTankTransform.ts @@ -21,23 +21,23 @@ export function useTankTransform( track: TrackDefinition, turret: TurretDefinition, turretContainer: RefObject, - gunContainer: RefObject + gunContainer: RefObject, ) { const tankModelDefinition = useTankModelDefinition(); useEffect(() => { const trackModelDefinition = tankModelDefinition.tracks[track.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; - const hullOrigin = correctZYTuple(trackModelDefinition.origin); - const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin); - const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin); + const hullOrigin = correctZYTuple(trackModelDefinition.origin!); + const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!); + const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!); const turretPosition = new Vector3(); const turretRotation = new Euler(); const gunPosition = new Vector3(); const gunRotation = new Euler(); function handleModelTransform( - event: QuicklimeEvent + event: QuicklimeEvent, ) { handleModelTransformInner(event.data); } @@ -70,13 +70,13 @@ export function useTankTransform( if (tankModelDefinition.initial_turret_rotation) { const initialPitch = -degToRad( - tankModelDefinition.initial_turret_rotation.pitch + tankModelDefinition.initial_turret_rotation.pitch, ); const initialYaw = -degToRad( - tankModelDefinition.initial_turret_rotation.yaw + tankModelDefinition.initial_turret_rotation.yaw, ); const initialRoll = -degToRad( - tankModelDefinition.initial_turret_rotation.roll + tankModelDefinition.initial_turret_rotation.roll, ); turretPosition diff --git a/packages/website/src/pages/[...locale]/guess/_index.tsx b/packages/website/src/pages/[...locale]/guess/_index.tsx index d172884ff..ac9c88c3b 100644 --- a/packages/website/src/pages/[...locale]/guess/_index.tsx +++ b/packages/website/src/pages/[...locale]/guess/_index.tsx @@ -59,7 +59,7 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) { const tank = Guess.use((state) => state.tank); const guessState = Guess.use((state) => state.guessState); const isRevealed = guessState !== GuessState.NotGuessed; - const name = unwrap(tank.name); + const name = unwrap(tank.name!); const fontSize = `min(48vh, ${55 / name.length}vw)`; const transitionDuration = isRevealed ? "2s" : undefined; const tiers = Guess.use((state) => state.tiers); @@ -77,7 +77,7 @@ function Content({ skeleton }: MaybeSkeletonComponentProps) { if (filteredIds.length === 0) return; const id = Number( - filteredIds[Math.floor(Math.random() * filteredIds.length)] + filteredIds[Math.floor(Math.random() * filteredIds.length)], ); const newTank = tankDefinitions.tanks[id]; diff --git a/packages/website/src/pages/[...locale]/session/_index.tsx b/packages/website/src/pages/[...locale]/session/_index.tsx index 006c8dbc0..05ca5f1b3 100644 --- a/packages/website/src/pages/[...locale]/session/_index.tsx +++ b/packages/website/src/pages/[...locale]/session/_index.tsx @@ -69,7 +69,7 @@ function Content() { const input = useRef(null); const session = Session.use(); const [tankStatsB, setTankStatsB] = useState( - null + null, ); const [accountInfo, setAccountInfo] = useState< IndividualAccountInfo | null | undefined @@ -81,7 +81,7 @@ function Content() { if (!id) return setAccountInfo(null); setAccountInfo( - session.tracking ? await getAccountInfo(idToRegion(id), id) : null + session.tracking ? await getAccountInfo(idToRegion(id), id) : null, ); })(); }, [session.tracking && session.player.id]); @@ -95,20 +95,20 @@ function Content() { const average = averageDefinitions.averages[tank.id]; const composite = compositeStats( { ...entry.all, battle_life_time: entry.battle_life_time }, - average?.mu + average?.mu!, ); return { tank, composite }; }) : undefined, - [session.tracking && session.player, tankStatsB] + [session.tracking && session.player, tankStatsB], ); const total = useMemo( () => delta ? sumCompositeStats(delta.map(({ composite }) => composite)) : undefined, - [delta] + [delta], ); const search = debounce(async () => { if (!input.current) return; @@ -150,7 +150,7 @@ function Content() { const tankStats = await getTankStats( idToRegion(session.player.id), - session.player.id + session.player.id, ); setTankStatsB(tankStats); } @@ -294,7 +294,7 @@ function Content() { onClick={async () => { const stats = await getTankStats( session.player.region, - session.player.id + session.player.id, ); if (stats === null) { @@ -365,7 +365,7 @@ function Content() { onClick={() => { Session.mutate((draft) => { (draft as SessionTracking).columns.unshift( - key + key, ); }); }} @@ -402,7 +402,8 @@ function Content() { {compositeStatsKeys .filter( (item) => - !session.columns.includes(item) || item === column + !session.columns.includes(item) || + item === column, ) .map((key) => ( @@ -452,7 +453,7 @@ function Content() { {formatCompositeStat( composite[column], column, - composite + composite, )} ))} diff --git a/packages/website/src/pages/[...locale]/tanks/[slug]/_index.tsx b/packages/website/src/pages/[...locale]/tanks/[slug]/_index.tsx index 2ff88ed91..78ed0623c 100644 --- a/packages/website/src/pages/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website/src/pages/[...locale]/tanks/[slug]/_index.tsx @@ -43,7 +43,7 @@ export function Page({ id, skeleton, locale, guide }: PageProps) { - {tank.type === TankType.RESEARCHABLE && !tank.deprecated && ( + {tank.type === TankType.TANK_TYPE_RESEARCHABLE && !tank.deprecated && ( )} diff --git a/packages/website/src/pages/[...locale]/tanks/[slug]/index.astro b/packages/website/src/pages/[...locale]/tanks/[slug]/index.astro index 240b9c8be..2a4c2872e 100644 --- a/packages/website/src/pages/[...locale]/tanks/[slug]/index.astro +++ b/packages/website/src/pages/[...locale]/tanks/[slug]/index.astro @@ -50,7 +50,7 @@ const tank = tankDefinitions.tanks[id]; const tankModelDefinition = tankModelDefinitions.models[tank.id]; const unwrap = unwrapper(locale); const title = literals(strings.website.tools.tankopedia.tank_seo_title, { - name: unwrap(tank.name), + name: unwrap(tank.name!), tier: TIER_ROMAN_NUMERALS[tank.tier], nationality: strings.common.nations_adjectives[ @@ -92,7 +92,7 @@ const characteristics = tankCharacteristics( const description = literals( strings.website.tools.tankopedia.tank_seo_description, { - name: unwrap(tank.name), + name: unwrap(tank.name!), dpm: Math.round(characteristics.dpm).toLocaleString(locale), alpha: Math.round(characteristics.damage).toLocaleString(locale), penetration: Math.round(characteristics.penetration).toLocaleString(locale),