fix: hide crew mastery

This commit is contained in:
TrèsAbhi committed 2024-10-24 15:31:01 -05:00
1 parent 3698826ac4
commit 2c0965f437
6 files changed
+6 -98

No files matched your search

@@ -9,8 +9,8 @@ import {
} from '@blitzkit/core';
import { checkConsumableProvisionInclusivity } from '@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity';
import { ComponentPlaceholderIcon } from '@radix-ui/react-icons';
import { Button, Flex, Popover, Slider, Table, Text } from '@radix-ui/themes';
import { debounce, times } from 'lodash-es';
import { Button, Flex, Popover, Table } from '@radix-ui/themes';
import { times } from 'lodash-es';
import type { TankCharacteristics } from '../../core/blitzkit/tankCharacteristics';
import { Var } from '../../core/radix/var';
import { CompareEphemeral } from '../../stores/compareEphemeral';
@@ -167,7 +167,6 @@ export function CompareTable({ stats }: CompareTableProps) {
engine,
track,
consumables,
crewMastery,
},
index,
) => {
@@ -537,23 +536,6 @@ export function CompareTable({ stats }: CompareTableProps) {
</Popover.Content>
</Popover.Root>
</Flex>
<Flex gap="2" width="100%" align="center">
<Text>{Math.round(crewMastery * 100)}%</Text>
<Flex flexGrow="1">
<Slider
defaultValue={[crewMastery]}
min={0.5}
max={1}
step={1 / 100}
onValueChange={debounce(([value]: number[]) => {
mutateCompareEphemeral((draft) => {
draft.members[index].crewMastery = value;
});
}, 500)}
/>
</Flex>
</Flex>
</Flex>
</Table.Cell>
);
@@ -41,7 +41,6 @@ export function Characteristics() {
const crewSkills = TankopediaEphemeral.use((state) => state.skills);
const penetrationDistanceInput = useRef<HTMLInputElement>(null);
const hasImprovedVentilation = useEquipment(102);
const crewMastery = Duel.use((state) => state.protagonist.crewMastery);
const [penetrationDistance, setPenetrationDistance] = useState(250);
const setPenetrationDistanceDebounced = debounce((value: number) => {
setPenetrationDistance(value);
@@ -56,7 +55,7 @@ export function Characteristics() {
: total,
0,
) + (hasImprovedVentilation ? 0.08 : 0);
const commanderMastery = crewMastery + provisionCrewBonus;
const commanderMastery = 1 + provisionCrewBonus;
const consumables = Duel.use((state) => state.protagonist.consumables);
const camouflage = Duel.use((state) => state.protagonist.camouflage);
const equipmentMatrix = Duel.use(
@@ -78,7 +77,6 @@ export function Characteristics() {
tank,
camouflage,
consumables,
crewMastery,
crewSkills,
engine,
equipmentMatrix,
@@ -1,7 +1,5 @@
import { asset, TankType } from '@blitzkit/core';
import { Flex, Heading, Slider, TextField } from '@radix-ui/themes';
import { clamp, debounce } from 'lodash-es';
import { useEffect, useMemo, useRef, useState } from 'react';
import { asset } from '@blitzkit/core';
import { Flex, Heading } from '@radix-ui/themes';
import { Duel } from '../../../../stores/duel';
import { GenericTankComponentButton } from '../../../ModuleButtons/GenericTankComponentButton';
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
@@ -12,27 +10,8 @@ export function Miscellaneous() {
const cooldownBooster = Duel.use(
(state) => state.protagonist.cooldownBooster,
);
const crewMastery = Duel.use((state) => state.protagonist.crewMastery);
const crewInput = useRef<HTMLInputElement>(null);
const [crewMasteryDraft, setCrewMasteryDraft] = useState(crewMastery);
const { tank } = Duel.use((state) => state.protagonist);
const debouncedApplyDraft = useMemo(
() =>
debounce((value) => {
mutateDuel((draft) => {
draft.protagonist.crewMastery = value;
});
}, 500),
[],
);
useEffect(() => {
setCrewMasteryDraft(crewMastery);
if (!crewInput.current) return;
crewInput.current.value = `${Math.round(crewMastery * 100)}`;
}, [crewMastery]);
return (
<ConfigurationChildWrapper>
<Heading size="4">Miscellaneous</Heading>
@@ -77,53 +56,6 @@ export function Miscellaneous() {
});
}}
/>
{tank.type === TankType.RESEARCHABLE && (
<Flex
align="center"
direction="column"
gap="1"
justify="end"
style={{ width: 120 }}
>
<TextField.Root
ref={crewInput}
defaultValue={Math.round(crewMastery * 100)}
style={{ textAlign: 'right' }}
onBlur={() => {
const newValue = Number(crewInput.current!.value) / 100;
if (isNaN(newValue)) {
crewInput.current!.value = `${Math.round(crewMastery * 100)}`;
return;
}
mutateDuel((draft) => {
draft.protagonist.crewMastery = clamp(newValue / 100, 0.5, 1);
});
}}
onKeyUp={(event) => {
if (event.key === 'Enter') {
crewInput.current?.blur();
}
}}
>
<TextField.Slot>Crew</TextField.Slot>
<TextField.Slot>%</TextField.Slot>
</TextField.Root>
<Slider
min={50}
max={100}
value={[crewMasteryDraft * 100]}
style={{ width: '100%' }}
onValueChange={([value]) => {
setCrewMasteryDraft(value / 100);
debouncedApplyDraft(value / 100);
}}
/>
</Flex>
)}
</Flex>
</ConfigurationChildWrapper>
);
@@ -33,7 +33,6 @@ export function tankCharacteristics(
shell,
consumables,
equipmentMatrix,
crewMastery,
provisions,
engine,
crewSkills,
@@ -59,7 +58,6 @@ export function tankCharacteristics(
stockGun: GunDefinition;
consumables: number[];
equipmentMatrix: EquipmentMatrix;
crewMastery: number;
provisions: number[];
crewSkills: Record<string, number>;
camouflage: boolean;
@@ -139,7 +137,7 @@ export function tankCharacteristics(
: total,
0,
) + (hasImprovedVentilation ? 0.08 : 0);
const commanderMastery = crewMastery + provisionCrewBonus;
const commanderMastery = 1 + provisionCrewBonus;
const loaderMastery =
commanderMastery *
(tank.crew.some(({ type }) => type === CrewType.LOADER) ? 1.1 : 1.05);
@@ -29,7 +29,6 @@ export function tankToDuelMember(
consumables: [],
equipmentMatrix: genericDefaultEquipmentMatrix,
cooldownBooster: 0,
crewMastery: 1,
provisions: provisionsList
.sort(
(a, b) =>
@@ -35,7 +35,6 @@ export interface DuelMember {
pitch: number;
yaw: number;
consumables: number[];
crewMastery: number;
provisions: number[];
camouflage: boolean;
cooldownBooster: number;