mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 19:49:50 +01:00
feat: unlocks proof of concept
This commit is contained in:
1 parent
e5d109c973
commit
89e97f484b
4 files changed
+118
No files matched your search
@@ -453,6 +453,36 @@ export async function definitions(production: boolean) {
|
|||||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/chassis.xml.dvpl`,
|
`${DATA}/${POI.vehicleDefinitions}/${nation}/components/chassis.xml.dvpl`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function resolveUnlocks(unlocks?: Unlocks) {
|
||||||
|
if (!unlocks) return undefined;
|
||||||
|
|
||||||
|
return Object.entries(unlocks)
|
||||||
|
.map(([type, list]) =>
|
||||||
|
(Array.isArray(list) ? list : [list]).map((item) => {
|
||||||
|
const typeTyped = type as keyof Unlocks;
|
||||||
|
let rawId: number;
|
||||||
|
|
||||||
|
if (typeTyped === 'chassis') {
|
||||||
|
rawId = chassisList.root.ids[item['#text']];
|
||||||
|
} else if (typeTyped === 'engine') {
|
||||||
|
rawId = enginesList.root.ids[item['#text']];
|
||||||
|
} else if (typeTyped === 'gun') {
|
||||||
|
rawId = gunList.root.ids[item['#text']];
|
||||||
|
} else if (typeTyped === 'turret') {
|
||||||
|
rawId = turretList.root.ids[item['#text']];
|
||||||
|
} else if (typeTyped === 'vehicle') {
|
||||||
|
rawId = tankList.root[item['#text']].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: typeTyped,
|
||||||
|
id: toUniqueId(nation, rawId!),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.flat();
|
||||||
|
}
|
||||||
|
|
||||||
for (const tankKey in tankList.root) {
|
for (const tankKey in tankList.root) {
|
||||||
if (botPattern.test(tankKey)) continue;
|
if (botPattern.test(tankKey)) continue;
|
||||||
|
|
||||||
@@ -626,6 +656,7 @@ export async function definitions(production: boolean) {
|
|||||||
soft: terrainResistances[2],
|
soft: terrainResistances[2],
|
||||||
},
|
},
|
||||||
tier: track.level as Tier,
|
tier: track.level as Tier,
|
||||||
|
unlocks: resolveUnlocks(track.unlocks),
|
||||||
});
|
});
|
||||||
|
|
||||||
modelDefinitions[tankId].tracks[trackId] = {
|
modelDefinitions[tankId].tracks[trackId] = {
|
||||||
@@ -650,6 +681,7 @@ export async function definitions(production: boolean) {
|
|||||||
tier: engineListEntry.level as Tier,
|
tier: engineListEntry.level as Tier,
|
||||||
weight: engineListEntry.weight,
|
weight: engineListEntry.weight,
|
||||||
power: engineListEntry.power,
|
power: engineListEntry.power,
|
||||||
|
unlocks: resolveUnlocks(engine.unlocks),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -711,6 +743,7 @@ export async function definitions(production: boolean) {
|
|||||||
health: turret.maxHealth,
|
health: turret.maxHealth,
|
||||||
viewRange: turret.circularVisionRadius,
|
viewRange: turret.circularVisionRadius,
|
||||||
weight: turret.weight,
|
weight: turret.weight,
|
||||||
|
unlocks: resolveUnlocks(turret.unlocks),
|
||||||
});
|
});
|
||||||
|
|
||||||
modelDefinitions[tankId].turrets[turretId] = {
|
modelDefinitions[tankId].turrets[turretId] = {
|
||||||
@@ -829,6 +862,7 @@ export async function definitions(production: boolean) {
|
|||||||
shot: shotDispersionFactors.afterShot,
|
shot: shotDispersionFactors.afterShot,
|
||||||
traverse: shotDispersionFactors.turretRotation,
|
traverse: shotDispersionFactors.turretRotation,
|
||||||
},
|
},
|
||||||
|
unlocks: resolveUnlocks(gun.unlocks),
|
||||||
} as GunDefinition);
|
} as GunDefinition);
|
||||||
|
|
||||||
modelDefinitions[tankId].turrets[turretId].guns[gunId] = {
|
modelDefinitions[tankId].turrets[turretId].guns[gunId] = {
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { Heading } from '@radix-ui/themes';
|
||||||
|
import { use } from 'react';
|
||||||
|
import PageWrapper from '../../../../../../components/PageWrapper';
|
||||||
|
import {
|
||||||
|
EngineDefinition,
|
||||||
|
GunDefinition,
|
||||||
|
ModuleType,
|
||||||
|
tankDefinitions,
|
||||||
|
TrackDefinition,
|
||||||
|
TurretDefinition,
|
||||||
|
Unlock,
|
||||||
|
} from '../../../../../../core/blitzkit/tankDefinitions';
|
||||||
|
import { useDuel } from '../../../../../../stores/duel';
|
||||||
|
|
||||||
|
export function ModulesSection() {
|
||||||
|
const awaitedTankDefinitions = use(tankDefinitions);
|
||||||
|
const tank = useDuel((state) => state.protagonist!.tank);
|
||||||
|
|
||||||
|
function tree(type: ModuleType, unlocks: Unlock[]) {
|
||||||
|
return (
|
||||||
|
<ul>
|
||||||
|
{unlocks.map((unlock) => {
|
||||||
|
let module:
|
||||||
|
| TrackDefinition
|
||||||
|
| EngineDefinition
|
||||||
|
| TurretDefinition
|
||||||
|
| GunDefinition
|
||||||
|
| undefined = undefined;
|
||||||
|
|
||||||
|
if (unlock.type === 'chassis') {
|
||||||
|
module = tank.tracks.find((track) => track.id === unlock.id)!;
|
||||||
|
} else if (unlock.type === 'engine') {
|
||||||
|
module = tank.engines.find((engine) => engine.id === unlock.id)!;
|
||||||
|
} else if (unlock.type === 'turret') {
|
||||||
|
module = tank.turrets.find((turret) => turret.id === unlock.id)!;
|
||||||
|
} else if (unlock.type === 'gun') {
|
||||||
|
module = tank.turrets
|
||||||
|
.find((turret) =>
|
||||||
|
turret.guns.some((gun) => gun.id === unlock.id),
|
||||||
|
)!
|
||||||
|
.guns.find((gun) => gun.id === unlock.id)!;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (module === undefined) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
{unlock.type} {module.name}
|
||||||
|
{module.unlocks && tree(type, module.unlocks)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageWrapper>
|
||||||
|
<Heading>turret0</Heading>
|
||||||
|
{tank.turrets[0].unlocks && tree('turret', tank.turrets[0].unlocks)}
|
||||||
|
|
||||||
|
<Heading>gun0</Heading>
|
||||||
|
{tank.turrets[0].guns[0].unlocks &&
|
||||||
|
tree('gun', tank.turrets[0].guns[0].unlocks)}
|
||||||
|
|
||||||
|
<Heading>engine0</Heading>
|
||||||
|
{tank.engines[0].unlocks && tree('engine', tank.engines[0].unlocks)}
|
||||||
|
|
||||||
|
<Heading>track0</Heading>
|
||||||
|
{tank.tracks[0].unlocks && tree('chassis', tank.tracks[0].unlocks)}
|
||||||
|
</PageWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import { mutateDuel, useDuel } from '../../../../stores/duel';
|
|||||||
import { mutateTankopediaTemporary } from '../../../../stores/tankopedia';
|
import { mutateTankopediaTemporary } from '../../../../stores/tankopedia';
|
||||||
import { HeroSection } from './components/Model/HeroSection';
|
import { HeroSection } from './components/Model/HeroSection';
|
||||||
import { HistoricalSection } from './components/Model/HistoricalSection';
|
import { HistoricalSection } from './components/Model/HistoricalSection';
|
||||||
|
import { ModulesSection } from './components/Model/ModulesSection';
|
||||||
import { TechTreeSection } from './components/Model/TechTreeSection';
|
import { TechTreeSection } from './components/Model/TechTreeSection';
|
||||||
import { Videos } from './components/Videos';
|
import { Videos } from './components/Videos';
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
<HeroSection />
|
<HeroSection />
|
||||||
{/* <TankopediaPlug /> */}
|
{/* <TankopediaPlug /> */}
|
||||||
<TechTreeSection />
|
<TechTreeSection />
|
||||||
|
<ModulesSection />
|
||||||
{/* <CharacteristicsSection />
|
{/* <CharacteristicsSection />
|
||||||
<TankopediaSeparator /> */}
|
<TankopediaSeparator /> */}
|
||||||
<Videos />
|
<Videos />
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ export type CrewMember =
|
|||||||
| 'driver'
|
| 'driver'
|
||||||
| 'loader';
|
| 'loader';
|
||||||
export type TankDefinitions = Record<number, TankDefinition>;
|
export type TankDefinitions = Record<number, TankDefinition>;
|
||||||
|
export type ModuleType = 'vehicle' | 'engine' | 'chassis' | 'turret' | 'gun';
|
||||||
|
export interface Unlock {
|
||||||
|
type: ModuleType;
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
export interface Crew {
|
export interface Crew {
|
||||||
type: CrewMember;
|
type: CrewMember;
|
||||||
count?: number;
|
count?: number;
|
||||||
@@ -69,6 +74,7 @@ export interface TrackDefinition {
|
|||||||
medium: number;
|
medium: number;
|
||||||
soft: number;
|
soft: number;
|
||||||
};
|
};
|
||||||
|
unlocks?: Unlock[];
|
||||||
}
|
}
|
||||||
export interface EngineDefinition {
|
export interface EngineDefinition {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -78,6 +84,7 @@ export interface EngineDefinition {
|
|||||||
fireChance: number;
|
fireChance: number;
|
||||||
power: number;
|
power: number;
|
||||||
weight: number;
|
weight: number;
|
||||||
|
unlocks?: Unlock[];
|
||||||
}
|
}
|
||||||
export type TankDefinitionPrice =
|
export type TankDefinitionPrice =
|
||||||
| { type: 'credits'; value: number }
|
| { type: 'credits'; value: number }
|
||||||
@@ -92,6 +99,7 @@ export interface TurretDefinition {
|
|||||||
tier: Tier;
|
tier: Tier;
|
||||||
guns: GunDefinition[];
|
guns: GunDefinition[];
|
||||||
weight: number;
|
weight: number;
|
||||||
|
unlocks?: Unlock[];
|
||||||
}
|
}
|
||||||
export type GunDefinition =
|
export type GunDefinition =
|
||||||
| GunDefinitionRegular
|
| GunDefinitionRegular
|
||||||
@@ -113,6 +121,7 @@ interface GunDefinitionBase {
|
|||||||
shot: number;
|
shot: number;
|
||||||
damaged: number;
|
damaged: number;
|
||||||
};
|
};
|
||||||
|
unlocks?: Unlock[];
|
||||||
}
|
}
|
||||||
interface GunDefinitionRegular extends GunDefinitionBase {
|
interface GunDefinitionRegular extends GunDefinitionBase {
|
||||||
type: 'regular';
|
type: 'regular';
|
||||||
|
|||||||
Reference in new issue
Block a user