mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: xp definitions
This commit is contained in:
1 parent
476d8e804a
commit
da02a089b9
3 files changed
+88
-21
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { readdir, writeFile } from 'fs/promises';
|
||||
import { readdir } from 'fs/promises';
|
||||
import { parse as parsePath } from 'path';
|
||||
import { Vector3Tuple } from 'three';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
@@ -368,6 +368,12 @@ export async function definitions(production: boolean) {
|
||||
`${DATA}/${POI.provisionsCommon}.dvpl`,
|
||||
);
|
||||
|
||||
const tankXps = new Map<number, number>();
|
||||
const gunXps = new Map<number, number>();
|
||||
const turretXps = new Map<number, number>();
|
||||
const engineXps = new Map<number, number>();
|
||||
const trackXps = new Map<number, number>();
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
@@ -830,19 +836,57 @@ export async function definitions(production: boolean) {
|
||||
|
||||
totalUnlocks.forEach((unlocks) => {
|
||||
if (unlocks === undefined) return;
|
||||
|
||||
Object.entries(unlocks).forEach(([key, value]) => {
|
||||
if ((key as keyof Unlocks) !== 'vehicle') return;
|
||||
|
||||
(Array.isArray(value) ? value : [value]).forEach((vehicle) => {
|
||||
const tankListEntry = tankList.root[vehicle['#text']];
|
||||
const successorId = toUniqueId(nation, tankListEntry.id);
|
||||
switch (key as keyof Unlocks) {
|
||||
case 'vehicle': {
|
||||
const tankListEntry = tankList.root[vehicle['#text']];
|
||||
const currentTank = tankDefinitions[tankId];
|
||||
const successorId = toUniqueId(nation, tankListEntry.id);
|
||||
|
||||
if (tankDefinitions[tankId].successors === undefined) {
|
||||
tankDefinitions[tankId].successors = [];
|
||||
}
|
||||
tankXps.set(successorId, vehicle.cost);
|
||||
|
||||
if (!tankDefinitions[tankId].successors!.includes(successorId)) {
|
||||
tankDefinitions[tankId].successors!.push(successorId);
|
||||
if (currentTank.successors === undefined) {
|
||||
currentTank.successors = [];
|
||||
}
|
||||
if (!currentTank.successors!.includes(successorId)) {
|
||||
currentTank.successors!.push(successorId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'gun': {
|
||||
gunXps.set(
|
||||
toUniqueId(nation, gunList.root.ids[vehicle['#text']]),
|
||||
vehicle.cost,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'turret': {
|
||||
turretXps.set(
|
||||
toUniqueId(nation, turretList.root.ids[vehicle['#text']]),
|
||||
vehicle.cost,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'engine': {
|
||||
engineXps.set(
|
||||
toUniqueId(nation, enginesList.root.ids[vehicle['#text']]),
|
||||
vehicle.cost,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'chassis': {
|
||||
trackXps.set(
|
||||
toUniqueId(nation, chassisList.root.ids[vehicle['#text']]),
|
||||
vehicle.cost,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -851,6 +895,26 @@ export async function definitions(production: boolean) {
|
||||
}),
|
||||
);
|
||||
|
||||
Object.values(tankDefinitions).forEach((tank) => {
|
||||
tank.xp = tankXps.get(tank.id);
|
||||
|
||||
Object.values(tank.turrets).forEach((turret) => {
|
||||
turret.xp = turretXps.get(turret.id);
|
||||
|
||||
Object.values(turret.guns).forEach((gun) => {
|
||||
gun.xp = gunXps.get(gun.id);
|
||||
});
|
||||
});
|
||||
|
||||
Object.values(tank.engines).forEach((engine) => {
|
||||
engine.xp = engineXps.get(engine.id);
|
||||
});
|
||||
|
||||
Object.values(tank.tracks).forEach((track) => {
|
||||
track.xp = trackXps.get(track.id);
|
||||
});
|
||||
});
|
||||
|
||||
Object.values(tankDefinitions).forEach((tank) => {
|
||||
tank.successors?.forEach((predecessorId) => {
|
||||
if (tankDefinitions[predecessorId].ancestors === undefined) {
|
||||
@@ -1020,8 +1084,6 @@ export async function definitions(production: boolean) {
|
||||
}
|
||||
});
|
||||
|
||||
writeFile('test.json', JSON.stringify(tankDefinitions, null, 2));
|
||||
|
||||
await commitAssets(
|
||||
'definitions',
|
||||
[
|
||||
|
||||
@@ -16,7 +16,7 @@ export default function CommandWrapper({ children, fat }: CommandWrapperProps) {
|
||||
gap: 16,
|
||||
width: 480,
|
||||
color: theme.colors.textHighContrast,
|
||||
backgroundColor: theme.colors.appBackground1,
|
||||
background: theme.colors.appBackground1,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { readFile } from 'fs/promises';
|
||||
import { deburr } from 'lodash';
|
||||
import { Vector2Tuple } from 'three';
|
||||
import { TankClass, TreeType } from '../../../components/Tanks';
|
||||
import { superDecompress } from '../superDecompress';
|
||||
import { asset } from '../asset';
|
||||
import { fetchCdonLz4 } from '../fetchCdonLz4';
|
||||
import { TIERS } from './constants';
|
||||
|
||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||
@@ -39,6 +39,7 @@ export interface TankDefinition {
|
||||
engines: EngineDefinition[];
|
||||
tracks: TrackDefinition[];
|
||||
price: TankDefinitionPrice;
|
||||
xp?: number;
|
||||
speed: {
|
||||
forwards: number;
|
||||
backwards: number;
|
||||
@@ -56,6 +57,7 @@ export interface TrackDefinition {
|
||||
tier: Tier;
|
||||
weight: number;
|
||||
traverseSpeed: number;
|
||||
xp?: number;
|
||||
dispersion: {
|
||||
move: number;
|
||||
traverse: number;
|
||||
@@ -69,6 +71,7 @@ export interface TrackDefinition {
|
||||
export interface EngineDefinition {
|
||||
id: number;
|
||||
name: string;
|
||||
xp?: number;
|
||||
tier: Tier;
|
||||
fireChance: number;
|
||||
power: number;
|
||||
@@ -81,6 +84,7 @@ export interface TurretDefinition {
|
||||
health: number;
|
||||
viewRange: number;
|
||||
traverseSpeed: number;
|
||||
xp?: number;
|
||||
id: number;
|
||||
name: string;
|
||||
tier: Tier;
|
||||
@@ -93,6 +97,7 @@ export type GunDefinition =
|
||||
| GunDefinitionAutoReloader;
|
||||
interface GunDefinitionBase {
|
||||
rotationSpeed: number;
|
||||
xp?: number;
|
||||
weight: number;
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -137,14 +142,14 @@ export type ShellDefinition = {
|
||||
explosionRadius?: number;
|
||||
};
|
||||
|
||||
// export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||
// asset('definitions/tanks.cdon.lz4'),
|
||||
// );
|
||||
|
||||
export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
||||
superDecompress<TankDefinitions>(data.buffer),
|
||||
export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||
asset('definitions/tanks.cdon.lz4'),
|
||||
);
|
||||
|
||||
// export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
||||
// superDecompress<TankDefinitions>(data.buffer),
|
||||
// );
|
||||
|
||||
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
||||
resolve(Object.entries(await tankDefinitions).map(([, entry]) => entry));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user