mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: ea and cs
This commit is contained in:
1 parent
a0c9895122
commit
9488602f5b
17 files changed
+134
-43
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import { EquipmentPreset } from '../core/blitzkrieg/equipmentDefinitions';
|
||||
import { EquipmentMatrix } from '../stores/tankopedia';
|
||||
|
||||
export function useAppliedEquipments(
|
||||
matrix: EquipmentMatrix,
|
||||
preset: EquipmentPreset,
|
||||
) {
|
||||
const flatMatrix = matrix.flat();
|
||||
return preset.flat().map((options, index) => options[flatMatrix[index]]);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import usePromise from 'react-promise-suspense';
|
||||
|
||||
/**
|
||||
* A more stable alternative to `use` using `usePromise`.
|
||||
*/
|
||||
export function useAwait<Type>(promise: Promise<Type>) {
|
||||
return usePromise(async () => await promise, []);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { equipmentDefinitions } from '../core/blitzkrieg/equipmentDefinitions';
|
||||
import { useAwait } from './useAwait';
|
||||
|
||||
export function useEquipmentPreset(preset: string) {
|
||||
const awaitedEquipmentDefinitions = useAwait(equipmentDefinitions);
|
||||
console.log(awaitedEquipmentDefinitions);
|
||||
return awaitedEquipmentDefinitions.presets[preset];
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import usePromise from 'react-promise-suspense';
|
||||
import { modelDefinitions } from '../core/blitzkrieg/modelDefinitions';
|
||||
import { useAwait } from './useAwait';
|
||||
|
||||
export function useModelDefinitions() {
|
||||
return usePromise(async () => await modelDefinitions, []);
|
||||
return useAwait(modelDefinitions);
|
||||
}
|
||||
Reference in new issue
Block a user