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'; } from '@blitzkit/core';
import { checkConsumableProvisionInclusivity } from '@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity'; import { checkConsumableProvisionInclusivity } from '@blitzkit/core/src/blitzkit/checkConsumableProvisionInclusivity';
import { ComponentPlaceholderIcon } from '@radix-ui/react-icons'; import { ComponentPlaceholderIcon } from '@radix-ui/react-icons';
import { Button, Flex, Popover, Slider, Table, Text } from '@radix-ui/themes'; import { Button, Flex, Popover, Table } from '@radix-ui/themes';
import { debounce, times } from 'lodash-es'; import { times } from 'lodash-es';
import type { TankCharacteristics } from '../../core/blitzkit/tankCharacteristics'; import type { TankCharacteristics } from '../../core/blitzkit/tankCharacteristics';
import { Var } from '../../core/radix/var'; import { Var } from '../../core/radix/var';
import { CompareEphemeral } from '../../stores/compareEphemeral'; import { CompareEphemeral } from '../../stores/compareEphemeral';
@@ -167,7 +167,6 @@ export function CompareTable({ stats }: CompareTableProps) {
engine, engine,
track, track,
consumables, consumables,
crewMastery,
}, },
index, index,
) => { ) => {
@@ -537,23 +536,6 @@ export function CompareTable({ stats }: CompareTableProps) {
</Popover.Content> </Popover.Content>
</Popover.Root> </Popover.Root>
</Flex> </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> </Flex>
</Table.Cell> </Table.Cell>
); );
@@ -41,7 +41,6 @@ export function Characteristics() {
const crewSkills = TankopediaEphemeral.use((state) => state.skills); const crewSkills = TankopediaEphemeral.use((state) => state.skills);
const penetrationDistanceInput = useRef<HTMLInputElement>(null); const penetrationDistanceInput = useRef<HTMLInputElement>(null);
const hasImprovedVentilation = useEquipment(102); const hasImprovedVentilation = useEquipment(102);
const crewMastery = Duel.use((state) => state.protagonist.crewMastery);
const [penetrationDistance, setPenetrationDistance] = useState(250); const [penetrationDistance, setPenetrationDistance] = useState(250);
const setPenetrationDistanceDebounced = debounce((value: number) => { const setPenetrationDistanceDebounced = debounce((value: number) => {
setPenetrationDistance(value); setPenetrationDistance(value);
@@ -56,7 +55,7 @@ export function Characteristics() {
: total, : total,
0, 0,
) + (hasImprovedVentilation ? 0.08 : 0); ) + (hasImprovedVentilation ? 0.08 : 0);
const commanderMastery = crewMastery + provisionCrewBonus; const commanderMastery = 1 + provisionCrewBonus;
const consumables = Duel.use((state) => state.protagonist.consumables); const consumables = Duel.use((state) => state.protagonist.consumables);
const camouflage = Duel.use((state) => state.protagonist.camouflage); const camouflage = Duel.use((state) => state.protagonist.camouflage);
const equipmentMatrix = Duel.use( const equipmentMatrix = Duel.use(
@@ -78,7 +77,6 @@ export function Characteristics() {
tank, tank,
camouflage, camouflage,
consumables, consumables,
crewMastery,
crewSkills, crewSkills,
engine, engine,
equipmentMatrix, equipmentMatrix,
@@ -1,7 +1,5 @@
import { asset, TankType } from '@blitzkit/core'; import { asset } from '@blitzkit/core';
import { Flex, Heading, Slider, TextField } from '@radix-ui/themes'; import { Flex, Heading } from '@radix-ui/themes';
import { clamp, debounce } from 'lodash-es';
import { useEffect, useMemo, useRef, useState } from 'react';
import { Duel } from '../../../../stores/duel'; import { Duel } from '../../../../stores/duel';
import { GenericTankComponentButton } from '../../../ModuleButtons/GenericTankComponentButton'; import { GenericTankComponentButton } from '../../../ModuleButtons/GenericTankComponentButton';
import { ConfigurationChildWrapper } from './ConfigurationChildWrapper'; import { ConfigurationChildWrapper } from './ConfigurationChildWrapper';
@@ -12,27 +10,8 @@ export function Miscellaneous() {
const cooldownBooster = Duel.use( const cooldownBooster = Duel.use(
(state) => state.protagonist.cooldownBooster, (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 { 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 ( return (
<ConfigurationChildWrapper> <ConfigurationChildWrapper>
<Heading size="4">Miscellaneous</Heading> <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> </Flex>
</ConfigurationChildWrapper> </ConfigurationChildWrapper>
); );
@@ -33,7 +33,6 @@ export function tankCharacteristics(
shell, shell,
consumables, consumables,
equipmentMatrix, equipmentMatrix,
crewMastery,
provisions, provisions,
engine, engine,
crewSkills, crewSkills,
@@ -59,7 +58,6 @@ export function tankCharacteristics(
stockGun: GunDefinition; stockGun: GunDefinition;
consumables: number[]; consumables: number[];
equipmentMatrix: EquipmentMatrix; equipmentMatrix: EquipmentMatrix;
crewMastery: number;
provisions: number[]; provisions: number[];
crewSkills: Record<string, number>; crewSkills: Record<string, number>;
camouflage: boolean; camouflage: boolean;
@@ -139,7 +137,7 @@ export function tankCharacteristics(
: total, : total,
0, 0,
) + (hasImprovedVentilation ? 0.08 : 0); ) + (hasImprovedVentilation ? 0.08 : 0);
const commanderMastery = crewMastery + provisionCrewBonus; const commanderMastery = 1 + provisionCrewBonus;
const loaderMastery = const loaderMastery =
commanderMastery * commanderMastery *
(tank.crew.some(({ type }) => type === CrewType.LOADER) ? 1.1 : 1.05); (tank.crew.some(({ type }) => type === CrewType.LOADER) ? 1.1 : 1.05);
@@ -29,7 +29,6 @@ export function tankToDuelMember(
consumables: [], consumables: [],
equipmentMatrix: genericDefaultEquipmentMatrix, equipmentMatrix: genericDefaultEquipmentMatrix,
cooldownBooster: 0, cooldownBooster: 0,
crewMastery: 1,
provisions: provisionsList provisions: provisionsList
.sort( .sort(
(a, b) => (a, b) =>
@@ -35,7 +35,6 @@ export interface DuelMember {
pitch: number; pitch: number;
yaw: number; yaw: number;
consumables: number[]; consumables: number[];
crewMastery: number;
provisions: number[]; provisions: number[];
camouflage: boolean; camouflage: boolean;
cooldownBooster: number; cooldownBooster: number;