mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: begenning or equipment
This commit is contained in:
1 parent
543e963d1d
commit
01dc3137d8
7 files changed
+42
-6
No files matched your search
File renamed without changes.
@@ -25,3 +25,5 @@ export interface EquipmentDefinitions {
|
||||
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
|
||||
asset('definitions/equipment.cdon.lz4'),
|
||||
);
|
||||
|
||||
equipmentDefinitions.then(console.log);
|
||||
@@ -1,8 +1,12 @@
|
||||
import { GunDefinition, ShellDefinition } from './tankDefinitions';
|
||||
|
||||
export function resolveDpm(gun: GunDefinition, shell: ShellDefinition) {
|
||||
export function resolveDpm(
|
||||
gun: GunDefinition,
|
||||
shell: ShellDefinition,
|
||||
hasRammer = false,
|
||||
) {
|
||||
if (gun.type === 'regular') {
|
||||
return (shell.damage.armor / gun.reload) * 60;
|
||||
return (shell.damage.armor / ((hasRammer ? 0.93 : 1) * gun.reload)) * 60;
|
||||
} else if (gun.type === 'autoLoader') {
|
||||
return (
|
||||
((shell.damage.armor * gun.count) /
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { use, useMemo } from 'react';
|
||||
import { useDuel } from '../../stores/duel';
|
||||
import { useTankopediaTemporary } from '../../stores/tankopedia';
|
||||
import { equipmentDefinitions } from './equipmentDefinitions';
|
||||
|
||||
export function useEquipment(id: number) {
|
||||
const awaitedEquipmentDefinitions = use(equipmentDefinitions);
|
||||
const protagonist = useDuel((state) => state.protagonist!);
|
||||
const equipmentRows =
|
||||
awaitedEquipmentDefinitions.presets[protagonist.tank.equipment];
|
||||
const equipmentMatrix = useTankopediaTemporary(
|
||||
(state) => state.equipmentMatrix,
|
||||
);
|
||||
const value = useMemo(
|
||||
() =>
|
||||
equipmentRows.some((equipmentRow, rowIndex) => {
|
||||
return equipmentRow.some((equipment, columnIndex) => {
|
||||
const choice = equipmentMatrix[rowIndex][columnIndex];
|
||||
if (choice === 0) return false;
|
||||
const equipped = equipment[choice === -1 ? 0 : 1];
|
||||
return equipped === id;
|
||||
});
|
||||
}),
|
||||
[equipmentMatrix, protagonist.tank],
|
||||
);
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user