2024-01-22 18:04:13 -06:00
|
|
|
import { produce } from 'immer';
|
|
|
|
|
import { create } from 'zustand';
|
2024-01-22 18:14:09 -06:00
|
|
|
import { subscribeWithSelector } from 'zustand/middleware';
|
2024-02-22 16:41:42 -06:00
|
|
|
import {
|
|
|
|
|
EngineDefinition,
|
|
|
|
|
GunDefinition,
|
|
|
|
|
ShellDefinition,
|
|
|
|
|
TankDefinition,
|
|
|
|
|
TrackDefinition,
|
|
|
|
|
TurretDefinition,
|
|
|
|
|
} from '../core/blitzkrieg/tankDefinitions';
|
|
|
|
|
|
|
|
|
|
type EquipmentMatrixItem = -1 | 0 | 1;
|
|
|
|
|
type EquipmentMatrixRow = [
|
|
|
|
|
EquipmentMatrixItem,
|
|
|
|
|
EquipmentMatrixItem,
|
|
|
|
|
EquipmentMatrixItem,
|
|
|
|
|
];
|
|
|
|
|
export type EquipmentMatrix = [
|
|
|
|
|
EquipmentMatrixRow,
|
|
|
|
|
EquipmentMatrixRow,
|
|
|
|
|
EquipmentMatrixRow,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export interface DuelMember {
|
|
|
|
|
tank: TankDefinition;
|
|
|
|
|
engine: EngineDefinition;
|
|
|
|
|
turret: TurretDefinition;
|
|
|
|
|
gun: GunDefinition;
|
|
|
|
|
shell: ShellDefinition;
|
|
|
|
|
track: TrackDefinition;
|
|
|
|
|
equipment: EquipmentMatrix;
|
|
|
|
|
pitch: number;
|
|
|
|
|
yaw: number;
|
|
|
|
|
consumables: number[];
|
|
|
|
|
crewMastery: number;
|
|
|
|
|
provisions: number[];
|
|
|
|
|
camouflage: boolean;
|
|
|
|
|
cooldownBooster: number;
|
|
|
|
|
}
|
2024-01-22 18:04:13 -06:00
|
|
|
|
|
|
|
|
export interface Duel {
|
|
|
|
|
assigned: boolean;
|
|
|
|
|
protagonist?: DuelMember;
|
|
|
|
|
antagonist?: DuelMember;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-22 18:14:09 -06:00
|
|
|
export const useDuel = create<Duel>()(
|
|
|
|
|
subscribeWithSelector<Duel>(() => ({
|
|
|
|
|
assigned: false,
|
|
|
|
|
})),
|
|
|
|
|
);
|
2024-01-22 18:04:13 -06:00
|
|
|
|
|
|
|
|
export function mutateDuel(recipe: (draft: Duel) => void) {
|
|
|
|
|
useDuel.setState(produce(recipe));
|
|
|
|
|
}
|
2024-02-22 16:41:42 -06:00
|
|
|
|
|
|
|
|
export const genericDefaultEquipmentMatrix: EquipmentMatrix = [
|
|
|
|
|
[1, 1, -1],
|
|
|
|
|
[0, 0, 0],
|
|
|
|
|
[0, 0, 0],
|
|
|
|
|
];
|