diff --git a/src/App.tsx b/src/App.tsx index 49c61fe..f0470b1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -121,18 +121,16 @@ function CreatureComponent({ * Displays card shape with a number on it indicating how many cards are in the pile. This one has onclick to allow player to draw * @returns returns markup displaying what i wrote just above */ -function Deck({ player }: { player: Player }) { +function Deck({ player, handState }: { player: Player, handState: React.Dispatch>}) { let handleDraw = function () { - if (player.actions < 1) { - player.drawCard(1); - player.actions -= 1; - } else { + if (!player.drawCardUsingAction()) { log.push(
{player.username} attempted to draw, but does not have enough actions.
, ); - } + } + handState(player.hand); }; return (
{shownHand}
; } -function AppBoard() { - return ( -
-
-
-
-
- Card 1 -
-
- Card 2 -
-
- Card 3 -
-
- Card 4 -
-
-
-
-
-
-
-
- Card 1 -
-
- Card 2 -
-
- Card 3 -
-
- Card 4 -
-
-
-
-
- ); -} - /** * * Board loops through the board (the actual array that keeps track of the board) to display each @@ -414,7 +321,8 @@ function GameBoard({ game }: { game: Game }) { const [turn, setTurn] = useState(game.currentTurn); const [phase, setPhase] = useState(game.turnPhase); const [currentPlayer, setCurrentPlayer] = useState(game.currentPlayer); - + const [hand1, setCurrentHand1] = useState(game.players[0].hand); + const [hand2, setCurrentHand2] = useState(game.players[1].hand); let player1 = game.getPlayerById(0); let player2 = game.getPlayerById(1); return ( @@ -430,7 +338,7 @@ function GameBoard({ game }: { game: Game }) { {/*This column shows a deck and discard pile*/}
- +
{/*The board between two columns*/} @@ -440,7 +348,7 @@ function GameBoard({ game }: { game: Game }) { {/*The first column shows the deck and discard pile (like the one you saw earlier*/}
- +
{/*This column shows the game log text bot and the button for moving phases below it*/} diff --git a/src/model.ts b/src/model.ts index d33647d..b85fe58 100644 --- a/src/model.ts +++ b/src/model.ts @@ -338,6 +338,20 @@ export class Player { } } } + + } + /** + * function that is called when a player uses an action to draw for turn. + * @returns boolean based on whether the player had enough actions to draw + */ + drawCardUsingAction(){ + if(this.actions >= 1){ + this.drawCard(1, true) + return true; + } + else{ + return false; + } } }