2023-12-03 19:45:43 -06:00
|
|
|
import { produce } from 'immer';
|
|
|
|
|
import { create } from 'zustand';
|
2024-01-13 13:44:27 -06:00
|
|
|
import { subscribeWithSelector } from 'zustand/middleware';
|
2023-12-04 12:35:27 -06:00
|
|
|
import { TankType, TreeTypeString } from '../components/Tanks';
|
2024-01-07 13:13:27 -06:00
|
|
|
import {
|
|
|
|
|
GunDefinition,
|
2024-01-10 14:25:48 -06:00
|
|
|
ShellDefinition,
|
2024-01-07 13:13:27 -06:00
|
|
|
TankDefinition,
|
|
|
|
|
Tier,
|
|
|
|
|
TurretDefinition,
|
|
|
|
|
} from '../core/blitzkrieg/tankDefinitions';
|
2023-12-03 19:45:43 -06:00
|
|
|
|
2023-12-04 10:25:54 -06:00
|
|
|
export type TankopediaSortBy = 'tier' | 'name';
|
2023-12-03 19:45:43 -06:00
|
|
|
export type TankopediaSortDirection = 'ascending' | 'descending';
|
2023-12-06 10:34:43 -06:00
|
|
|
export type TankopediaTestTankDisplay = 'include' | 'exclude' | 'only';
|
2024-01-06 18:17:04 -06:00
|
|
|
export type TankopediaMode = 'model' | 'armor';
|
2024-01-15 15:02:04 -06:00
|
|
|
export interface DuelMember {
|
|
|
|
|
tank: TankDefinition;
|
|
|
|
|
turret: TurretDefinition;
|
|
|
|
|
gun: GunDefinition;
|
|
|
|
|
shell: ShellDefinition;
|
|
|
|
|
}
|
|
|
|
|
interface Tankopedia {
|
2023-12-04 11:47:33 -06:00
|
|
|
sort: {
|
|
|
|
|
by: TankopediaSortBy;
|
|
|
|
|
direction: TankopediaSortDirection;
|
|
|
|
|
};
|
|
|
|
|
filters: {
|
|
|
|
|
tiers: Tier[];
|
2023-12-04 12:35:27 -06:00
|
|
|
types: TankType[];
|
|
|
|
|
treeTypes: TreeTypeString[];
|
2023-12-04 19:10:26 -06:00
|
|
|
nations: string[];
|
2023-12-06 10:34:43 -06:00
|
|
|
test: TankopediaTestTankDisplay;
|
2023-12-04 11:47:33 -06:00
|
|
|
};
|
2024-01-04 13:06:40 -06:00
|
|
|
model: {
|
2024-01-13 16:48:20 -06:00
|
|
|
physical: {
|
2024-01-13 18:24:04 -06:00
|
|
|
yaw: number;
|
|
|
|
|
pitch: number;
|
2024-01-13 16:48:20 -06:00
|
|
|
};
|
|
|
|
|
visual: {
|
|
|
|
|
controlsEnabled: boolean;
|
|
|
|
|
showGrid: boolean;
|
2024-01-16 12:22:17 -06:00
|
|
|
greenPenetration: boolean;
|
2024-01-13 16:48:20 -06:00
|
|
|
};
|
2024-01-04 13:06:40 -06:00
|
|
|
};
|
2024-01-06 18:17:04 -06:00
|
|
|
mode: TankopediaMode;
|
2024-01-15 15:02:04 -06:00
|
|
|
}
|
2023-12-03 19:45:43 -06:00
|
|
|
|
2024-01-13 13:44:27 -06:00
|
|
|
export const useTankopedia = create<Tankopedia>()(
|
|
|
|
|
subscribeWithSelector<Tankopedia>(() => ({
|
|
|
|
|
sort: {
|
|
|
|
|
by: 'tier',
|
|
|
|
|
direction: 'descending',
|
|
|
|
|
},
|
|
|
|
|
filters: {
|
|
|
|
|
tiers: [],
|
|
|
|
|
types: [],
|
|
|
|
|
treeTypes: [],
|
|
|
|
|
nations: [],
|
|
|
|
|
test: 'include',
|
|
|
|
|
},
|
|
|
|
|
model: {
|
2024-01-13 16:48:20 -06:00
|
|
|
physical: {
|
2024-01-13 18:24:04 -06:00
|
|
|
yaw: 0,
|
|
|
|
|
pitch: 0,
|
2024-01-13 16:48:20 -06:00
|
|
|
},
|
|
|
|
|
visual: {
|
|
|
|
|
controlsEnabled: true,
|
|
|
|
|
showGrid: true,
|
2024-01-16 12:22:17 -06:00
|
|
|
greenPenetration: false,
|
2024-01-13 16:48:20 -06:00
|
|
|
},
|
2024-01-13 13:44:27 -06:00
|
|
|
},
|
|
|
|
|
areTanksAssigned: false,
|
|
|
|
|
mode: 'model',
|
|
|
|
|
})),
|
|
|
|
|
);
|
2023-12-03 19:45:43 -06:00
|
|
|
|
|
|
|
|
export default function mutateTankopedia(recipe: (draft: Tankopedia) => void) {
|
|
|
|
|
useTankopedia.setState(produce(recipe));
|
|
|
|
|
}
|