fix: remove shot when swithcing shells

This commit is contained in:
TrèsAbhi committed 2024-02-08 11:26:12 -06:00
1 parent 01e7353ef4
commit 1b9cf8b604
3 files changed
+17 -2

No files matched your search

@@ -18,7 +18,10 @@ import {
TIER_ROMAN_NUMERALS, TIER_ROMAN_NUMERALS,
} from '../../../../../../core/blitzkrieg/tankDefinitions'; } from '../../../../../../core/blitzkrieg/tankDefinitions';
import { mutateDuel, useDuel } from '../../../../../../stores/duel'; import { mutateDuel, useDuel } from '../../../../../../stores/duel';
import { useTankopediaTemporary } from '../../../../../../stores/tankopedia'; import {
mutateTankopediaTemporary,
useTankopediaTemporary,
} from '../../../../../../stores/tankopedia';
import { TankSearch } from '../../../components/TankSearch'; import { TankSearch } from '../../../components/TankSearch';
export function AntagonistBar() { export function AntagonistBar() {
@@ -47,6 +50,9 @@ export function AntagonistBar() {
onClick={() => { onClick={() => {
mutateDuel((draft) => { mutateDuel((draft) => {
draft.antagonist!.shell = shell; draft.antagonist!.shell = shell;
mutateTankopediaTemporary((draft) => {
draft.shot = undefined;
});
}); });
}} }}
/> />
+9
View File
@@ -56,17 +56,26 @@ export default function Page({ params }: { params: { id: string } }) {
function handleKeyDown(event: KeyboardEvent) { function handleKeyDown(event: KeyboardEvent) {
if (document.activeElement instanceof HTMLInputElement) return; if (document.activeElement instanceof HTMLInputElement) return;
function wipeShot() {
mutateTankopediaTemporary((draft) => {
draft.shot = undefined;
});
}
if (event.key === '1') { if (event.key === '1') {
wipeShot();
mutateDuel((draft) => { mutateDuel((draft) => {
draft.antagonist!.shell = draft.antagonist!.gun.shells[0]; draft.antagonist!.shell = draft.antagonist!.gun.shells[0];
}); });
} else if (event.key === '2') { } else if (event.key === '2') {
wipeShot();
mutateDuel((draft) => { mutateDuel((draft) => {
if (draft.antagonist!.gun.shells[1]) { if (draft.antagonist!.gun.shells[1]) {
draft.antagonist!.shell = draft.antagonist!.gun.shells[1]; draft.antagonist!.shell = draft.antagonist!.gun.shells[1];
} }
}); });
} else if (event.key === '3') { } else if (event.key === '3') {
wipeShot();
mutateDuel((draft) => { mutateDuel((draft) => {
if (draft.antagonist!.gun.shells[2]) { if (draft.antagonist!.gun.shells[2]) {
draft.antagonist!.shell = draft.antagonist!.gun.shells[2]; draft.antagonist!.shell = draft.antagonist!.gun.shells[2];
+1 -1
View File
@@ -134,7 +134,7 @@ export function ShotDisplay() {
)} )}
mm mm
{layer.type === 'gap' && isExplosive(shell.type) {layer.type === 'gap' && isExplosive(shell.type)
? ` (${Math.round(Math.min(100, 0.5 * layer.gap * 100))}% pen. loss)` ? ` (-${Math.round(Math.min(100, 0.5 * layer.gap * 100))}% penetration)`
: ''} : ''}
</Text> </Text>
</Flex> </Flex>