mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: some more imports
This commit is contained in:
1 parent
13927927b3
commit
a149af50fd
11 files changed
+79
-81
No files matched your search
Vendored
+3
-2
@@ -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"]
|
||||
]
|
||||
}
|
||||
@@ -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<TankList>;
|
||||
|
||||
@@ -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<string, string> = {};
|
||||
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<string, string> = {};
|
||||
const parsed = parse(text) as Record<string, string>;
|
||||
const url = `${remoteStorage.url}${remoteStorage.relative_path}/${namespace}/${locale}.yaml`;
|
||||
const response = await fetch(url);
|
||||
const text = await response.text();
|
||||
const namespaceStrings: Record<string, string> = {};
|
||||
const parsed = parse(text) as Record<string, string>;
|
||||
|
||||
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(
|
||||
|
||||
@@ -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.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<ComputedCharacteristics> = {};
|
||||
@@ -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`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TankList } from "@protos/blitzkit/tank_list";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { TankList } from "../../../protos/tank_list";
|
||||
|
||||
/**
|
||||
* List!!
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user