diff --git a/.vscode/settings.json b/.vscode/settings.json index f43bd3f52..b8f63465e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,6 @@ { + "js/ts.experimental.useTsgo": true, + "protobuf.includes": ["${workspaceFolder}/path/to/protos"], "cSpell.words": [ "AABBOX", "Abhi", @@ -262,6 +264,5 @@ "youtuber", "youtubers", "zoomable" - ], - "protobuf.includes": ["${workspaceFolder}/path/to/protos"] + ] } diff --git a/packages/website-ue/src/core/api/abstract.ts b/packages/website-ue/src/core/api/abstract.ts index 82bf8c8fe..d293b5681 100644 --- a/packages/website-ue/src/core/api/abstract.ts +++ b/packages/website-ue/src/core/api/abstract.ts @@ -1,14 +1,14 @@ import type { Strings } from "@blitzkit/i18n"; import locales from "@blitzkit/i18n/locales.json"; -import type { Avatar } from "../../protos/avatar"; -import type { AvatarList } from "../../protos/avatar_list"; -import type { Avatars } from "../../protos/avatars"; -import type { Background } from "../../protos/background"; -import type { Backgrounds } from "../../protos/backgrounds"; -import type { PopularTanks } from "../../protos/popular_tanks"; -import type { Tank } from "../../protos/tank"; -import type { TankList } from "../../protos/tank_list"; -import type { Tanks } from "../../protos/tanks"; +import type { Avatar } from "@protos/blitzkit/avatar"; +import type { AvatarList } from "@protos/blitzkit/avatar_list"; +import type { Avatars } from "@protos/blitzkit/avatars"; +import type { Background } from "@protos/blitzkit/background"; +import type { Backgrounds } from "@protos/blitzkit/backgrounds"; +import type { PopularTanks } from "@protos/blitzkit/popular_tanks"; +import type { Tank } from "@protos/blitzkit/tank"; +import type { TankList } from "@protos/blitzkit/tank_list"; +import type { Tanks } from "@protos/blitzkit/tanks"; export abstract class AbstractAPI { abstract tankList(): Promise; diff --git a/packages/website-ue/src/core/api/server.ts b/packages/website-ue/src/core/api/server.ts index 854be96e7..2a5ebb3b4 100644 --- a/packages/website-ue/src/core/api/server.ts +++ b/packages/website-ue/src/core/api/server.ts @@ -186,7 +186,7 @@ export class ServerAPI extends AbstractAPI { return strings; } - @Cache() + // @Cache() async gameStrings(locale: string) { const group = this.metadata.group("ClientConfigsEntity"); @@ -199,8 +199,6 @@ export class ServerAPI extends AbstractAPI { const clientConfig = this.metadata.item(group[0].id); const localizationResources = clientConfig.LocalizationResources(); - console.log("localizationResources", localizationResources); - if (localizationResources.remote_storages.length !== 1) { throw new RangeError( `Don't know how to handle ${group.length} remote_storages`, @@ -227,7 +225,7 @@ export class ServerAPI extends AbstractAPI { } const strings: Record = {}; - const configPath = `${remoteStorage.url}/${remoteStorage.relative_path}/config.yaml`; + const configPath = `${remoteStorage.url}${remoteStorage.relative_path}/config.yaml`; try { const config = await fetch(configPath) @@ -235,23 +233,21 @@ export class ServerAPI extends AbstractAPI { .then((text) => parse(text) as LocalizationConfig); for (const namespace of config.namespaces) { - Object.assign( - strings, - await fetch( - `${remoteStorage.url}${remoteStorage.relative_path}/${namespace}/${locale}.yaml`, - ) - .then((response) => response.text()) - .then((text) => { - const strings: Record = {}; - const parsed = parse(text) as Record; + const url = `${remoteStorage.url}${remoteStorage.relative_path}/${namespace}/${locale}.yaml`; + const response = await fetch(url); + const text = await response.text(); + const namespaceStrings: Record = {}; + const parsed = parse(text) as Record; - for (const key in parsed) { - strings[key] = parsed[key].replaceAll('\\"', '"'); - } + for (const key in parsed) { + strings[key] = parsed[key].replaceAll('\\"', '"'); + } - return strings; - }), + console.log( + namespaceStrings["ProfileAvatarEntity__1_ct_legendary__DisplayName"], ); + + Object.assign(strings, namespaceStrings); } } catch (error) { console.warn( diff --git a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts index 45ff21489..6366027be 100644 --- a/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts +++ b/packages/website-ue/src/core/tankopedia/aggregateStageParameters.ts @@ -1,16 +1,16 @@ -import { StandardSinglePrice } from "@protos/blitz_static_standard_single_price"; -import { PenetrationGroup } from "@protos/blitz_static_tank_penetration_group"; +import { TankAttributeChange } from "@protos/game/proto/legacy/auto_items"; +import { StandardSinglePrice } from "@protos/game/proto/legacy/blitz_static_standard_single_price"; +import { PenetrationGroup } from "@protos/game/proto/legacy/blitz_static_tank_penetration_group"; import { PenetrationGroupUpgrade, PitchLimit, ShellUpgrade, - ShellUpgrageSingleChange, + ShellUpgradeSingleChange, StageParameters, - TankAttributeChange, TankAttributeChange_AttributeName, TankAttributeChange_Modifier, VisualChanges, -} from "@protos/blitz_static_tank_upgrade_single_stage"; +} from "@protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; function patch(stage0: StageParameters, stage1: StageParameters) { if (stage1.stage_number !== ++stage0.stage_number) { @@ -29,14 +29,14 @@ function patch(stage0: StageParameters, stage1: StageParameters) { case TankAttributeChange_Modifier.MODIFIER_ADD: const attribute0 = stage0.attributes.find( (attribute0) => - attribute0.attribute_name === attribute1.attribute_name + attribute0.attribute_name === attribute1.attribute_name, ); if (!attribute0) { throw new Error( `Missing attribute ${ TankAttributeChange_AttributeName[attribute1.attribute_name] - } (${attribute1.attribute_name}) to modify` + } (${attribute1.attribute_name}) to modify`, ); } @@ -54,7 +54,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { throw new Error( `Unhandled modified ${ TankAttributeChange_Modifier[attribute1.modifier] - }` + }`, ); } @@ -64,7 +64,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { value: value1, }); const index0 = stage0.attributes.findIndex( - (attribute) => attribute.attribute_name === attribute1.attribute_name + (attribute) => attribute.attribute_name === attribute1.attribute_name, ); if (index0 === -1) { @@ -76,7 +76,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { for (const penetrationGroupUpgrade1 of stage1.penetration_groups_upgrades) { const penetrationGroupUpgrade0 = stage0.penetration_groups_upgrades.find( - (group) => group.tank_part === penetrationGroupUpgrade1.tank_part + (group) => group.tank_part === penetrationGroupUpgrade1.tank_part, ); if (penetrationGroupUpgrade0) { @@ -87,7 +87,8 @@ function patch(stage0: StageParameters, stage1: StageParameters) { for (const penetrationGroup1 of penetrationGroupUpgrade1.penetration_groups) { const penetrationGroup0 = penetrationGroupUpgrade0.penetration_groups.find( - (baseGroup) => baseGroup.group_name === penetrationGroup1.group_name + (baseGroup) => + baseGroup.group_name === penetrationGroup1.group_name, ); if (penetrationGroup0) { @@ -95,13 +96,13 @@ function patch(stage0: StageParameters, stage1: StageParameters) { penetrationGroup0.armor = penetrationGroup1.armor; } else { penetrationGroupUpgrade0.penetration_groups.push( - PenetrationGroup.create(penetrationGroup1) + PenetrationGroup.create(penetrationGroup1), ); } } } else { stage0.penetration_groups_upgrades.push( - PenetrationGroupUpgrade.create(penetrationGroupUpgrade1) + PenetrationGroupUpgrade.create(penetrationGroupUpgrade1), ); } } @@ -112,7 +113,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { for (const shellUpgrades1 of stage1.shells_upgrades) { let shellUpgrades0 = stage0.shells_upgrades.find( - (baseShell) => baseShell.shell_id === shellUpgrades1.shell_id + (baseShell) => baseShell.shell_id === shellUpgrades1.shell_id, ); if (shellUpgrades0) { @@ -122,14 +123,14 @@ function patch(stage0: StageParameters, stage1: StageParameters) { const shellUpgrade0 = shellUpgrades0.changes.find( (baseShellUpgrade) => baseShellUpgrade.attribute_name === - changedShellUpgrade.attribute_name + changedShellUpgrade.attribute_name, ); if (shellUpgrade0) { shellUpgrade0.value = changedShellUpgrade.value; } else { shellUpgrades0.changes.push( - ShellUpgrageSingleChange.create(changedShellUpgrade) + ShellUpgradeSingleChange.create(changedShellUpgrade), ); } } @@ -169,7 +170,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { for (const visualChange1 of stage1.visual_changes) { const visualChange0 = stage0.visual_changes.find( (baseVisualChange) => - baseVisualChange.tank_part === visualChange1.tank_part + baseVisualChange.tank_part === visualChange1.tank_part, ); if (visualChange0) { @@ -182,7 +183,7 @@ function patch(stage0: StageParameters, stage1: StageParameters) { export function aggregateStageParameters( base: StageParameters, - stages: StageParameters[] + stages: StageParameters[], ) { const stage0 = StageParameters.create({ ...base, stage_number: 0 }); @@ -195,7 +196,7 @@ export function aggregateStageParameters( if (base.stage_number === 0 && import.meta.env.DEV) { throw new Error( - "Base stats are now stage 0. In-game bug fixed, please remove hack." + "Base stats are now stage 0. In-game bug fixed, please remove hack.", ); } diff --git a/packages/website-ue/src/core/tankopedia/characteristics.ts b/packages/website-ue/src/core/tankopedia/characteristics.ts index 5cca51f62..45a5326bf 100644 --- a/packages/website-ue/src/core/tankopedia/characteristics.ts +++ b/packages/website-ue/src/core/tankopedia/characteristics.ts @@ -1,11 +1,11 @@ -import { TankClass } from "@protos/blitz_static_tank_component"; +import type { Tank } from "@protos/blitzkit/tank"; +import { TankClass } from "@protos/game/proto/legacy/blitz_static_tank_component"; import { - ShellUpgrageSingleChange_AttributeName, + ShellUpgradeSingleChange_AttributeName, StageParameters, TankAttributeChange_AttributeName, -} from "@protos/blitz_static_tank_upgrade_single_stage"; +} from "@protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; import { radToDeg } from "three/src/math/MathUtils.js"; -import type { Tank } from "../../protos/tank"; import { applyPitchYawLimits } from "./applyPitchYawLimits"; import { TerrainHardness, type TankState } from "./tankState"; @@ -15,8 +15,8 @@ type Characteristic = (helpers: { characteristic: (name: CharacteristicName) => CharacteristicOutput; attribute: (name: TankAttributeChange_AttributeName) => number; attributeSafe: (name: TankAttributeChange_AttributeName) => number | null; - shell: (name: ShellUpgrageSingleChange_AttributeName) => number; - shellSafe: (name: ShellUpgrageSingleChange_AttributeName) => number | null; + shell: (name: ShellUpgradeSingleChange_AttributeName) => number; + shellSafe: (name: ShellUpgradeSingleChange_AttributeName) => number | null; state: TankState; tank: Tank; parameters: StageParameters; @@ -60,19 +60,19 @@ export const characteristics = { damage({ shell }) { return shell( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_ARMOR_DAMAGE, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_ARMOR_DAMAGE, ); }, module_damage({ shell }) { return shell( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MODULE_DAMAGE, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_MODULE_DAMAGE, ); }, penetration({ shell }) { return shell( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_PIERCING_POWER, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_PIERCING_POWER, ); }, @@ -168,37 +168,37 @@ export const characteristics = { }, caliber({ shell }) { - return shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_CALIBER); + return shell(ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_CALIBER); }, normalization({ shellSafe }) { return shellSafe( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_NORMALIZATION, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_NORMALIZATION, ); }, ricochet({ shell }) { return shell( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_RICOCHET_ANGLE, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_RICOCHET_ANGLE, ); }, shell_velocity({ shell }) { return ( - shell(ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_SPEED) / 100 + shell(ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_SPEED) / 100 ); }, shell_range({ shellSafe }) { const maxDistance = shellSafe( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_DISTANCE, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_DISTANCE, ); return maxDistance === null ? Infinity : maxDistance / 100; }, shell_capacity({ shellSafe }) { const count = shellSafe( - ShellUpgrageSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_COUNT, + ShellUpgradeSingleChange_AttributeName.ATTRIBUTE_NAME_MAX_COUNT, ); return count === -1 || count === null ? Infinity : count; }, diff --git a/packages/website-ue/src/core/tankopedia/characteristicsOrder.ts b/packages/website-ue/src/core/tankopedia/characteristicsOrder.ts index 00ae51842..1cb2b46d8 100644 --- a/packages/website-ue/src/core/tankopedia/characteristicsOrder.ts +++ b/packages/website-ue/src/core/tankopedia/characteristicsOrder.ts @@ -2,7 +2,7 @@ import { Nation, TankClass, TankType, -} from "@protos/blitz_static_tank_component"; +} from "@protos/game/proto/legacy/blitz_static_tank_component"; import { GunType, type CharacteristicName, diff --git a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts index 099f534e8..1bc34737d 100644 --- a/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts +++ b/packages/website-ue/src/core/tankopedia/computeCharacteristics.ts @@ -1,8 +1,8 @@ +import type { Tank } from "@blitzkit/closed/protos/blitzkit/tank"; import { - ShellUpgrageSingleChange_AttributeName, + ShellUpgradeSingleChange_AttributeName, TankAttributeChange_AttributeName, -} from "@protos/blitz_static_tank_upgrade_single_stage"; -import type { Tank } from "../../protos/tank"; +} from "@protos/game/proto/legacy/blitz_static_tank_upgrade_single_stage"; import { aggregateStageParameters } from "./aggregateStageParameters"; import { characteristics, @@ -19,11 +19,11 @@ export type ComputedCharacteristics = Record< export function computeCharacteristics( id: string, tank: Tank, - state: TankState + state: TankState, ) { const parameters = aggregateStageParameters( tank.tank!.base_stats!, - tank.tank!.upgrade_stages.slice(0, state.stage) + tank.tank!.upgrade_stages.slice(0, state.stage), ); const computed: Partial = {}; @@ -35,7 +35,7 @@ export function computeCharacteristics( function attributeSafe(name: TankAttributeChange_AttributeName) { const attribute = parameters.attributes.find( - (attribute) => attribute.attribute_name === name + (attribute) => attribute.attribute_name === name, ); return attribute ? attribute.value : null; @@ -46,37 +46,37 @@ export function computeCharacteristics( if (attribute === null) { throw new Error( - `Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found` + `Attribute ${TankAttributeChange_AttributeName[name]} (${name}) not found`, ); } return attribute; } - function shellSafe(name: ShellUpgrageSingleChange_AttributeName) { + function shellSafe(name: ShellUpgradeSingleChange_AttributeName) { const shell = parameters.shells_upgrades.find( - (shell) => shell.shell_id === state.shell + (shell) => shell.shell_id === state.shell, ); if (!shell) { throw new Error( - `Shell ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found` + `Shell ${ShellUpgradeSingleChange_AttributeName[name]} (${name}) not found`, ); } const attribute = shell.changes.find( - (change) => change.attribute_name === name + (change) => change.attribute_name === name, ); return attribute ? attribute.value : null; } - function shell(name: ShellUpgrageSingleChange_AttributeName) { + function shell(name: ShellUpgradeSingleChange_AttributeName) { const attribute = shellSafe(name); if (attribute === null) { throw new Error( - `Shell attribute ${ShellUpgrageSingleChange_AttributeName[name]} (${name}) not found` + `Shell attribute ${ShellUpgradeSingleChange_AttributeName[name]} (${name}) not found`, ); } diff --git a/packages/website-ue/src/pages/api/tanks/[id].pb.ts b/packages/website-ue/src/pages/api/tanks/[id].pb.ts index 2acba26cf..dd1d3ef79 100644 --- a/packages/website-ue/src/pages/api/tanks/[id].pb.ts +++ b/packages/website-ue/src/pages/api/tanks/[id].pb.ts @@ -1,6 +1,6 @@ +import { Tank } from "@protos/blitzkit/tank"; import type { APIContext, GetStaticPaths } from "astro"; import { api } from "../../../core/api/dynamic"; -import { Tank } from "../../../protos/tank"; export const getStaticPaths = (async () => { const { list } = await api.tankList(); diff --git a/packages/website-ue/src/pages/api/tanks/all.pb.ts b/packages/website-ue/src/pages/api/tanks/all.pb.ts index 8246d17ee..99a2df802 100644 --- a/packages/website-ue/src/pages/api/tanks/all.pb.ts +++ b/packages/website-ue/src/pages/api/tanks/all.pb.ts @@ -1,5 +1,5 @@ +import { Tanks } from "@protos/blitzkit/tanks"; import { api } from "../../../core/api/dynamic"; -import { Tanks } from "../../../protos/tanks"; /** * Literally all the tanks in one place lmao. diff --git a/packages/website-ue/src/pages/api/tanks/list.pb.ts b/packages/website-ue/src/pages/api/tanks/list.pb.ts index 74949a164..3809ac717 100644 --- a/packages/website-ue/src/pages/api/tanks/list.pb.ts +++ b/packages/website-ue/src/pages/api/tanks/list.pb.ts @@ -1,5 +1,5 @@ +import { TankList } from "@protos/blitzkit/tank_list"; import { api } from "../../../core/api/dynamic"; -import { TankList } from "../../../protos/tank_list"; /** * List!! diff --git a/packages/website-ue/src/pages/api/tanks/popular.pb.ts b/packages/website-ue/src/pages/api/tanks/popular.pb.ts index 1e2a2fcde..acd72e297 100644 --- a/packages/website-ue/src/pages/api/tanks/popular.pb.ts +++ b/packages/website-ue/src/pages/api/tanks/popular.pb.ts @@ -1,5 +1,5 @@ +import { PopularTanks } from "@protos/blitzkit/popular_tanks"; import { api } from "../../../core/api/dynamic"; -import { PopularTanks } from "../../../protos/popular_tanks"; export async function GET() { const popular = await api.popularTanks();