mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 06:06:11 +01:00
penetration
This commit is contained in:
1 parent
bf132a7387
commit
4e1219486d
9 files changed
+90
-19
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
|
||||
import { api } from "../api/dynamic";
|
||||
import { characteristics } from "../config/characteristics";
|
||||
import { defaultEqualizer } from "../config/equalizer";
|
||||
import { Tankopedia, type TankEnvironment } from "../stores/tankopedia";
|
||||
import type { TankState } from "../tankopedia/tankState";
|
||||
import type {
|
||||
@@ -10,6 +12,8 @@ import type {
|
||||
import type { DuelSide } from "./useEquipment";
|
||||
|
||||
const tanks = await api.tanks();
|
||||
const scripts = await api.scripts();
|
||||
const equipment = await api.equipment();
|
||||
|
||||
export function useCharacteristics(side: DuelSide) {
|
||||
const state = Tankopedia.use((state) => state[side]);
|
||||
@@ -31,6 +35,27 @@ export function computeCharacteristics(
|
||||
const gun = turret.guns.find((gun) => gun.id === state.gun)!;
|
||||
const shell = gun.shells.find((shell) => shell.id === state.shell)!;
|
||||
|
||||
const equipmentPreset = equipment.presets[tank.equipment_preset];
|
||||
|
||||
const scriptsMap = new Map<string, BlitzEffectScript>();
|
||||
|
||||
for (const id of state.consumables) {
|
||||
if (!(id in scripts.consumables)) continue;
|
||||
|
||||
const script = scripts.consumables[id];
|
||||
scriptsMap.set(script["#text"], script);
|
||||
}
|
||||
|
||||
for (const index in state.equipment) {
|
||||
const choice = state.equipment[index];
|
||||
const id = equipmentPreset.slots[index].options[choice];
|
||||
|
||||
if (!(id in scripts.equipment)) continue;
|
||||
|
||||
const script = scripts.equipment[id];
|
||||
scriptsMap.set(script["#text"], script);
|
||||
}
|
||||
|
||||
function characteristic(name: CharacteristicName) {
|
||||
if (!computed.has(name)) {
|
||||
throw new Error(`Characteristic ${name} not computed yet`);
|
||||
@@ -39,10 +64,19 @@ export function computeCharacteristics(
|
||||
return computed.get(name)!;
|
||||
}
|
||||
|
||||
console.log(scriptsMap);
|
||||
|
||||
function script(name: string, callback: (effect: BlitzEffectScript) => void) {
|
||||
if (!scriptsMap.has(name)) return;
|
||||
callback(scriptsMap.get(name)!);
|
||||
}
|
||||
|
||||
const context = {
|
||||
state,
|
||||
environment,
|
||||
|
||||
equalizer: tank.equalizer ?? defaultEqualizer,
|
||||
|
||||
tank,
|
||||
engine,
|
||||
track,
|
||||
@@ -51,6 +85,7 @@ export function computeCharacteristics(
|
||||
shell,
|
||||
|
||||
characteristic,
|
||||
script,
|
||||
} satisfies CharacteristicContext;
|
||||
|
||||
for (const name in characteristics) {
|
||||
|
||||
Reference in new issue
Block a user