From 8fba7605b4f8c31f2a5043de847ccba325e600d0 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson Date: Sat, 6 Aug 2022 12:13:12 -0500 Subject: [PATCH] added counter for cards remaining --- src/components/Card/Card.tsx | 2 +- src/components/Card/CardRow.tsx | 6 ++++++ src/components/Card/MiniCard.tsx | 10 ---------- src/components/Gameboard/Gameboard.tsx | 4 ++++ src/components/Player/Player.tsx | 5 +++++ 5 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 src/components/Card/MiniCard.tsx diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx index a5f38d7..a689856 100644 --- a/src/components/Card/Card.tsx +++ b/src/components/Card/Card.tsx @@ -11,7 +11,7 @@ export default function Card({ data, state, setState }: CardProps) { const currentPlayer = useCurrentPlayer(state); return ( -
+

Counts as: {data.gemValue}

Point value: {data.points || 0}

diff --git a/src/components/Card/CardRow.tsx b/src/components/Card/CardRow.tsx index 2b89a07..f998d0e 100644 --- a/src/components/Card/CardRow.tsx +++ b/src/components/Card/CardRow.tsx @@ -2,8 +2,11 @@ import { CardRowProps } from '../../util/propTypes'; import { CardData } from "../../util/types" import Card from "../Card/Card" import { v4 } from 'uuid'; +import cardTierToKey from '../../util/cardTierToKey'; export default function CardRow({tier, state, setState}: CardRowProps) { + const typedTier = cardTierToKey(tier); + let cards: Array switch (tier) { case 1: @@ -24,6 +27,9 @@ export default function CardRow({tier, state, setState}: CardRowProps) {

Tier: {tier}

+
+

Remaining: {state.gameboard.deck[typedTier].length}

+
{ cards && cards.map((cardData: CardData) => { return })} diff --git a/src/components/Card/MiniCard.tsx b/src/components/Card/MiniCard.tsx deleted file mode 100644 index 4c272aa..0000000 --- a/src/components/Card/MiniCard.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { CardData } from "../../util/types" - -export const MiniCard = ({ data }: {data: CardData}) => { - return ( -
-

{data.gemValue} card

-

{data.points || null}

-
- ) -} \ No newline at end of file diff --git a/src/components/Gameboard/Gameboard.tsx b/src/components/Gameboard/Gameboard.tsx index 5834987..d30334a 100644 --- a/src/components/Gameboard/Gameboard.tsx +++ b/src/components/Gameboard/Gameboard.tsx @@ -50,6 +50,10 @@ export default function Gameboard({ state, setState }: StateProps) { setCardRows(state); }, [state]) + useEffect(() => { + console.log(state) + }, [state]) + // displays state of board if data is populated useEffect(() => { if (!state.players.length) { diff --git a/src/components/Player/Player.tsx b/src/components/Player/Player.tsx index 346f053..fbd40ed 100644 --- a/src/components/Player/Player.tsx +++ b/src/components/Player/Player.tsx @@ -46,6 +46,11 @@ export default function Player({ player, state, setState }: PlayerProps) {

{data.gemValue} cards

{data.points + " points" || null}

+ { + Object.entries(data.resourceCost).map(([key, value]) => { + return value > 0 &&

{key}: {value}

+ }) + }
) })