mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 11:39:51 +01: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 { parse as parsePath } from 'path';
|
||||||
import { Vector3Tuple } from 'three';
|
import { Vector3Tuple } from 'three';
|
||||||
import { parse as parseYaml } from 'yaml';
|
import { parse as parseYaml } from 'yaml';
|
||||||
@@ -368,6 +368,12 @@ export async function definitions(production: boolean) {
|
|||||||
`${DATA}/${POI.provisionsCommon}.dvpl`,
|
`${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(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
@@ -830,19 +836,57 @@ export async function definitions(production: boolean) {
|
|||||||
|
|
||||||
totalUnlocks.forEach((unlocks) => {
|
totalUnlocks.forEach((unlocks) => {
|
||||||
if (unlocks === undefined) return;
|
if (unlocks === undefined) return;
|
||||||
|
|
||||||
Object.entries(unlocks).forEach(([key, value]) => {
|
Object.entries(unlocks).forEach(([key, value]) => {
|
||||||
if ((key as keyof Unlocks) !== 'vehicle') return;
|
|
||||||
|
|
||||||
(Array.isArray(value) ? value : [value]).forEach((vehicle) => {
|
(Array.isArray(value) ? value : [value]).forEach((vehicle) => {
|
||||||
const tankListEntry = tankList.root[vehicle['#text']];
|
switch (key as keyof Unlocks) {
|
||||||
const successorId = toUniqueId(nation, tankListEntry.id);
|
case 'vehicle': {
|
||||||
|
const tankListEntry = tankList.root[vehicle['#text']];
|
||||||
|
const currentTank = tankDefinitions[tankId];
|
||||||
|
const successorId = toUniqueId(nation, tankListEntry.id);
|
||||||
|
|
||||||
if (tankDefinitions[tankId].successors === undefined) {
|
tankXps.set(successorId, vehicle.cost);
|
||||||
tankDefinitions[tankId].successors = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tankDefinitions[tankId].successors!.includes(successorId)) {
|
if (currentTank.successors === undefined) {
|
||||||
tankDefinitions[tankId].successors!.push(successorId);
|
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) => {
|
Object.values(tankDefinitions).forEach((tank) => {
|
||||||
tank.successors?.forEach((predecessorId) => {
|
tank.successors?.forEach((predecessorId) => {
|
||||||
if (tankDefinitions[predecessorId].ancestors === undefined) {
|
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(
|
await commitAssets(
|
||||||
'definitions',
|
'definitions',
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default function CommandWrapper({ children, fat }: CommandWrapperProps) {
|
|||||||
gap: 16,
|
gap: 16,
|
||||||
width: 480,
|
width: 480,
|
||||||
color: theme.colors.textHighContrast,
|
color: theme.colors.textHighContrast,
|
||||||
backgroundColor: theme.colors.appBackground1,
|
background: theme.colors.appBackground1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { readFile } from 'fs/promises';
|
|
||||||
import { deburr } from 'lodash';
|
import { deburr } from 'lodash';
|
||||||
import { Vector2Tuple } from 'three';
|
import { Vector2Tuple } from 'three';
|
||||||
import { TankClass, TreeType } from '../../../components/Tanks';
|
import { TankClass, TreeType } from '../../../components/Tanks';
|
||||||
import { superDecompress } from '../superDecompress';
|
import { asset } from '../asset';
|
||||||
|
import { fetchCdonLz4 } from '../fetchCdonLz4';
|
||||||
import { TIERS } from './constants';
|
import { TIERS } from './constants';
|
||||||
|
|
||||||
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
export type ShellType = 'ap' | 'ap_cr' | 'hc' | 'he';
|
||||||
@@ -39,6 +39,7 @@ export interface TankDefinition {
|
|||||||
engines: EngineDefinition[];
|
engines: EngineDefinition[];
|
||||||
tracks: TrackDefinition[];
|
tracks: TrackDefinition[];
|
||||||
price: TankDefinitionPrice;
|
price: TankDefinitionPrice;
|
||||||
|
xp?: number;
|
||||||
speed: {
|
speed: {
|
||||||
forwards: number;
|
forwards: number;
|
||||||
backwards: number;
|
backwards: number;
|
||||||
@@ -56,6 +57,7 @@ export interface TrackDefinition {
|
|||||||
tier: Tier;
|
tier: Tier;
|
||||||
weight: number;
|
weight: number;
|
||||||
traverseSpeed: number;
|
traverseSpeed: number;
|
||||||
|
xp?: number;
|
||||||
dispersion: {
|
dispersion: {
|
||||||
move: number;
|
move: number;
|
||||||
traverse: number;
|
traverse: number;
|
||||||
@@ -69,6 +71,7 @@ export interface TrackDefinition {
|
|||||||
export interface EngineDefinition {
|
export interface EngineDefinition {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
xp?: number;
|
||||||
tier: Tier;
|
tier: Tier;
|
||||||
fireChance: number;
|
fireChance: number;
|
||||||
power: number;
|
power: number;
|
||||||
@@ -81,6 +84,7 @@ export interface TurretDefinition {
|
|||||||
health: number;
|
health: number;
|
||||||
viewRange: number;
|
viewRange: number;
|
||||||
traverseSpeed: number;
|
traverseSpeed: number;
|
||||||
|
xp?: number;
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
tier: Tier;
|
tier: Tier;
|
||||||
@@ -93,6 +97,7 @@ export type GunDefinition =
|
|||||||
| GunDefinitionAutoReloader;
|
| GunDefinitionAutoReloader;
|
||||||
interface GunDefinitionBase {
|
interface GunDefinitionBase {
|
||||||
rotationSpeed: number;
|
rotationSpeed: number;
|
||||||
|
xp?: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -137,14 +142,14 @@ export type ShellDefinition = {
|
|||||||
explosionRadius?: number;
|
explosionRadius?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
export const tankDefinitions = fetchCdonLz4<TankDefinitions>(
|
||||||
// asset('definitions/tanks.cdon.lz4'),
|
asset('definitions/tanks.cdon.lz4'),
|
||||||
// );
|
|
||||||
|
|
||||||
export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
|
||||||
superDecompress<TankDefinitions>(data.buffer),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// export const tankDefinitions = readFile('test.tanks.cdon.lz4').then((data) =>
|
||||||
|
// superDecompress<TankDefinitions>(data.buffer),
|
||||||
|
// );
|
||||||
|
|
||||||
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
const entries = new Promise<TankDefinition[]>(async (resolve) => {
|
||||||
resolve(Object.entries(await tankDefinitions).map(([, entry]) => entry));
|
resolve(Object.entries(await tankDefinitions).map(([, entry]) => entry));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user