better life handling

This commit is contained in:
Viktor Rådberg
2023-09-22 13:13:29 +02:00
parent d7d9d26540
commit 4157ef53c1
15 changed files with 197 additions and 268 deletions

View File

@@ -10,6 +10,7 @@ import {
PartnerTax,
Poison,
} from '../../Icons/generated';
import { usePlayers } from '../../Hooks/usePlayers';
const Container = styled.div<{ $rotation: Rotation }>`
width: 100%;
@@ -56,13 +57,11 @@ const ExtraCountersGrid = styled.div<{ $rotation: Rotation }>`
type ExtraCountersBarProps = {
player: Player;
onPlayerChange: (updatedPlayer: Player) => void;
};
const ExtraCountersBar = ({
player,
onPlayerChange,
}: ExtraCountersBarProps) => {
const ExtraCountersBar = ({ player }: ExtraCountersBarProps) => {
const { updatePlayer } = usePlayers();
const handleCounterChange = (
updatedCounterTotal: number,
type: CounterType
@@ -82,7 +81,7 @@ const ExtraCountersBar = ({
};
const updatedExtraCounters = [...player.extraCounters, newCounter];
const updatedPlayer = { ...player, extraCounters: updatedExtraCounters };
onPlayerChange(updatedPlayer);
updatePlayer(updatedPlayer);
return;
}
@@ -94,7 +93,7 @@ const ExtraCountersBar = ({
});
const updatedPlayer = { ...player, extraCounters: updatedExtraCounters };
onPlayerChange(updatedPlayer);
updatePlayer(updatedPlayer);
};
const iconSize =