From a073304659941fac661721e3ea3947a2d6251d7d Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:44:46 -0500 Subject: [PATCH] state setter formats --- src/components/Gameboard/Gameboard.tsx | 4 +-- src/components/Player/ActionMethods.ts | 27 +++++++++++++-- src/components/Resources/AvailableChips.tsx | 6 ---- src/components/Resources/SelectionView.tsx | 38 +++++++++++++++++++++ src/components/Resources/ViewHTML.tsx | 36 +++++++++++++++++++ src/util/TurnOrderUtil.ts | 1 + src/util/stateSetters.ts | 17 ++++++--- 7 files changed, 114 insertions(+), 15 deletions(-) create mode 100644 src/components/Resources/SelectionView.tsx create mode 100644 src/components/Resources/ViewHTML.tsx diff --git a/src/components/Gameboard/Gameboard.tsx b/src/components/Gameboard/Gameboard.tsx index 3cefb8e..c942fe8 100644 --- a/src/components/Gameboard/Gameboard.tsx +++ b/src/components/Gameboard/Gameboard.tsx @@ -10,14 +10,13 @@ import AvailableChips from '../Resources/AvailableChips'; import AllPlayers from '../Player/AllPlayers'; import CardRow from '../Card/CardRow'; import { validateChips } from '../Player/ActionMethods'; +import SelectionView from '../Resources/SelectionView'; export default function Gameboard({ state, setState }: StateProps) { const [view, setView] = useState(
Loading...
); // callbacks for lifting state const liftSelection = useCallback((value: keyof ResourceCost) => { - console.log(value) - if (!state.actions.getChips.active) return; setState((prev: AppState) => { @@ -83,6 +82,7 @@ export default function Gameboard({ state, setState }: StateProps) {Your selection is {state.actions.getChips.valid || "not"} valid
} - { - state.actions.getChips.active && - state.actions.getChips.selection?.map((each) =>{each}
) - } { Object.keys(state.gameboard.tradingResources).map((key: string | keyof ResourceCost) => { return ( @@ -31,7 +26,6 @@ export default function AvailableChips({ state, setState, liftSelection }: Resou ) }) } -Card will display here
+ > + ) + default: + return <>>; + } + }) + }, [state]) + + return ( +{each}
) + } +