mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +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
@@ -1,7 +1,7 @@
|
||||
import { Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { use } from 'react';
|
||||
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableInclusivity';
|
||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableProvisionInclusivity';
|
||||
import { consumableDefinitions } from '../../../../../../../core/blitzkrieg/consumableDefinitions';
|
||||
import { useDuel } from '../../../../../../../stores/duel';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { use } from 'react';
|
||||
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableInclusivity';
|
||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableProvisionInclusivity';
|
||||
import { provisionDefinitions } from '../../../../../../../core/blitzkrieg/provisionDefinitions';
|
||||
import { useDuel } from '../../../../../../../stores/duel';
|
||||
import {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
SHELL_NAMES,
|
||||
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
||||
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
||||
import { useEquipment } from '../../../../../../core/blitzkrieg/useEquipmentEquipped';
|
||||
import { useDuel } from '../../../../../../stores/duel';
|
||||
import { Info } from './components/Info';
|
||||
|
||||
@@ -40,6 +41,7 @@ export function Characteristics() {
|
||||
stockTrack.weight +
|
||||
stockTurret.weight +
|
||||
stockGun.weight;
|
||||
const hasRammer = useEquipment(100);
|
||||
|
||||
return (
|
||||
<Flex direction="column" gap="4" style={{ width: '100%' }}>
|
||||
@@ -79,7 +81,7 @@ export function Characteristics() {
|
||||
<Heading size="5">Fire</Heading>
|
||||
<Info name="Gun type">{GUN_TYPE_NAMES[gun.type]}</Info>
|
||||
<Info name="Damage per minute" unit="hp / min">
|
||||
{resolveDpm(gun, shell).toFixed(0)}
|
||||
{resolveDpm(gun, shell, hasRammer).toFixed(0)}
|
||||
</Info>
|
||||
{gun.type === 'autoReloader' && (
|
||||
<>
|
||||
@@ -136,7 +138,7 @@ export function Characteristics() {
|
||||
))
|
||||
) : (
|
||||
<Info name="Reload" unit="s">
|
||||
{gun.reload.toFixed(2)}
|
||||
{(gun.reload * (hasRammer ? 0.93 : 1)).toFixed(2)}
|
||||
</Info>
|
||||
)}
|
||||
<Info name="Caliber" unit="mm">
|
||||
|
||||
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