mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 20:49:52 +01: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 { Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import { use } from 'react';
|
import { use } from 'react';
|
||||||
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
||||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableInclusivity';
|
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableProvisionInclusivity';
|
||||||
import { consumableDefinitions } from '../../../../../../../core/blitzkrieg/consumableDefinitions';
|
import { consumableDefinitions } from '../../../../../../../core/blitzkrieg/consumableDefinitions';
|
||||||
import { useDuel } from '../../../../../../../stores/duel';
|
import { useDuel } from '../../../../../../../stores/duel';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Flex, Heading, Text } from '@radix-ui/themes';
|
import { Flex, Heading, Text } from '@radix-ui/themes';
|
||||||
import { use } from 'react';
|
import { use } from 'react';
|
||||||
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
import { ModuleButton } from '../../../../../../../components/ModuleButton';
|
||||||
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableInclusivity';
|
import { checkConsumableProvisionInclusivity } from '../../../../../../../core/blitzkrieg/checkConsumableProvisionInclusivity';
|
||||||
import { provisionDefinitions } from '../../../../../../../core/blitzkrieg/provisionDefinitions';
|
import { provisionDefinitions } from '../../../../../../../core/blitzkrieg/provisionDefinitions';
|
||||||
import { useDuel } from '../../../../../../../stores/duel';
|
import { useDuel } from '../../../../../../../stores/duel';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
SHELL_NAMES,
|
SHELL_NAMES,
|
||||||
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
} from '../../../../../../core/blitzkrieg/tankDefinitions';
|
||||||
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
import { unionBoundingBox } from '../../../../../../core/blitzkrieg/unionBoundingBox';
|
||||||
|
import { useEquipment } from '../../../../../../core/blitzkrieg/useEquipmentEquipped';
|
||||||
import { useDuel } from '../../../../../../stores/duel';
|
import { useDuel } from '../../../../../../stores/duel';
|
||||||
import { Info } from './components/Info';
|
import { Info } from './components/Info';
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export function Characteristics() {
|
|||||||
stockTrack.weight +
|
stockTrack.weight +
|
||||||
stockTurret.weight +
|
stockTurret.weight +
|
||||||
stockGun.weight;
|
stockGun.weight;
|
||||||
|
const hasRammer = useEquipment(100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction="column" gap="4" style={{ width: '100%' }}>
|
<Flex direction="column" gap="4" style={{ width: '100%' }}>
|
||||||
@@ -79,7 +81,7 @@ export function Characteristics() {
|
|||||||
<Heading size="5">Fire</Heading>
|
<Heading size="5">Fire</Heading>
|
||||||
<Info name="Gun type">{GUN_TYPE_NAMES[gun.type]}</Info>
|
<Info name="Gun type">{GUN_TYPE_NAMES[gun.type]}</Info>
|
||||||
<Info name="Damage per minute" unit="hp / min">
|
<Info name="Damage per minute" unit="hp / min">
|
||||||
{resolveDpm(gun, shell).toFixed(0)}
|
{resolveDpm(gun, shell, hasRammer).toFixed(0)}
|
||||||
</Info>
|
</Info>
|
||||||
{gun.type === 'autoReloader' && (
|
{gun.type === 'autoReloader' && (
|
||||||
<>
|
<>
|
||||||
@@ -136,7 +138,7 @@ export function Characteristics() {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<Info name="Reload" unit="s">
|
<Info name="Reload" unit="s">
|
||||||
{gun.reload.toFixed(2)}
|
{(gun.reload * (hasRammer ? 0.93 : 1)).toFixed(2)}
|
||||||
</Info>
|
</Info>
|
||||||
)}
|
)}
|
||||||
<Info name="Caliber" unit="mm">
|
<Info name="Caliber" unit="mm">
|
||||||
|
|||||||
File renamed without changes.
@@ -25,3 +25,5 @@ export interface EquipmentDefinitions {
|
|||||||
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
|
export const equipmentDefinitions = fetchCdonLz4<EquipmentDefinitions>(
|
||||||
asset('definitions/equipment.cdon.lz4'),
|
asset('definitions/equipment.cdon.lz4'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
equipmentDefinitions.then(console.log);
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import { GunDefinition, ShellDefinition } from './tankDefinitions';
|
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') {
|
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') {
|
} else if (gun.type === 'autoLoader') {
|
||||||
return (
|
return (
|
||||||
((shell.damage.armor * gun.count) /
|
((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