From a5c5b83b27e03c5fea741b6c62f7905790728c97 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Sat, 23 Jul 2022 11:59:55 -0500 Subject: [PATCH 1/4] in progress: turn handling for picking up resources --- src/components/Gameboard/Gameboard.tsx | 6 +- src/components/Player/AllPlayers.tsx | 16 +++++- src/components/Player/Player.tsx | 61 +++++++++++++++++---- src/components/Resources/AvailableChips.tsx | 33 ++++++++++- 4 files changed, 97 insertions(+), 19 deletions(-) diff --git a/src/components/Gameboard/Gameboard.tsx b/src/components/Gameboard/Gameboard.tsx index 88078f2..a61e40d 100644 --- a/src/components/Gameboard/Gameboard.tsx +++ b/src/components/Gameboard/Gameboard.tsx @@ -8,6 +8,8 @@ import NobleStore from '../../data/nobles.json'; export default function Gameboard({ state, setState }: StateProps) { const [view, setView] = useState(
Loading...
) + const [selection, setSelection] = useStateIs {player.starter || "not"} round starter
{/* Dynamic data from state */} -{dynamic?.turnActive ? "My turn!" : "..."}
- +{dynamic?.turnActive ? actionPrompt : "..."}
+ + + + + diff --git a/src/components/Resources/AvailableChips.tsx b/src/components/Resources/AvailableChips.tsx index baaad0a..40b38d0 100644 --- a/src/components/Resources/AvailableChips.tsx +++ b/src/components/Resources/AvailableChips.tsx @@ -1,20 +1,47 @@ import { ResourceCost, StateProps } from "../../util/types"; import { v4 } from "uuid"; import "./AvailableChips.css" -import { useEffect } from "react"; +import { Dispatch, SetStateAction, useEffect } from "react"; + +interface AvailableChipsProps extends StateProps { + chipSelection: { + selection: String[], + setSelection: Dispatch{key}: {state.gameboard.tradingResources[key as keyof ResourceCost]}
+{dynamic?.turnActive ? actionPrompt : "..."}
- + diff --git a/src/components/Resources/AvailableChips.tsx b/src/components/Resources/AvailableChips.tsx index 40b38d0..ba5d4fb 100644 --- a/src/components/Resources/AvailableChips.tsx +++ b/src/components/Resources/AvailableChips.tsx @@ -1,7 +1,7 @@ -import { ResourceCost, StateProps } from "../../util/types"; +import { GameActions, ResourceCost, StateProps } from "../../util/types"; import { v4 } from "uuid"; import "./AvailableChips.css" -import { Dispatch, SetStateAction, useEffect } from "react"; +import { Dispatch, SetStateAction, useEffect, useState } from "react"; interface AvailableChipsProps extends StateProps { chipSelection: { @@ -20,7 +20,6 @@ export default function AvailableChips({ state, chipSelection }: AvailableChipsP newValue.push(key); setSelection(newValue); - console.log(selection); } useEffect(() => { @@ -28,11 +27,20 @@ export default function AvailableChips({ state, chipSelection }: AvailableChipsP }, [state]) useEffect(() => { - console.log(selection); - }, [selection, setSelection]) + switch (state.actions) { + case (GameActions.GETCHIPS): + console.log('get chips'); + } + }) return ({each}
) } +Loading...
) @@ -31,8 +32,8 @@ export default function Gameboard({ state, setState }: StateProps) {{dynamic?.turnActive ? actionPrompt : "..."}
- - - + + diff --git a/src/components/Resources/AvailableChips.tsx b/src/components/Resources/AvailableChips.tsx index ba5d4fb..5f4bc11 100644 --- a/src/components/Resources/AvailableChips.tsx +++ b/src/components/Resources/AvailableChips.tsx @@ -2,37 +2,36 @@ import { GameActions, ResourceCost, StateProps } from "../../util/types"; import { v4 } from "uuid"; import "./AvailableChips.css" import { Dispatch, SetStateAction, useEffect, useState } from "react"; +import useActionStatus from "../../util/useActionStatus"; interface AvailableChipsProps extends StateProps { + liftFromChildren: any, chipSelection: { selection: String[], setSelection: Dispatch