summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2023-01-11 15:55:41 +0800
committerFrederick Yin <fkfd@fkfd.me>2023-01-11 15:55:41 +0800
commit7f34eef9fb39824ea5457368db593adca7b5c30b (patch)
tree8ab059204a95c68b17f8ead07e419ddf7a4d8487
parentc01a05c12636382db64799f3e6184c0b0f269bc6 (diff)
Define data Setup
-rw-r--r--Game.hs21
1 files changed, 13 insertions, 8 deletions
diff --git a/Game.hs b/Game.hs
index 08016c9..3b3c5c8 100644
--- a/Game.hs
+++ b/Game.hs
@@ -8,6 +8,13 @@ import qualified Player as P
import Card (Card(..))
import qualified Card as C
+data Setup = Setup { playerN :: Int
+ , roundN :: Int
+ , deckN :: Int
+ , cardN :: Int -- cards dealt to each player
+ , autoMode :: Bool
+ }
+
data Game = Game { players :: [Player]
, playerIdx :: Int
, attack :: Int
@@ -28,14 +35,12 @@ dealCards c game@(Game plyrs _ _ _ _ stock disc)
giveOneCardEach =
zipWith (\card player -> player { P.cards = card:(P.cards player) })
--- | Begin `r` rounds of game.
-beginRounds :: Int -> Bool -> Game -> IO Game
-beginRounds r auto game = do
- if r == 0
- then return game
- else do
- game' <- beginTurn auto game
- beginRounds (r - 1) auto game'
+-- | Begin game.
+beginRounds :: Setup -> Game -> IO Game
+beginRounds (Setup _ 0 _ _ _) game = return game
+beginRounds (Setup n r d c a) game = do
+ game' <- beginTurn a game
+ beginRounds (Setup n (r - 1) d c a) game'
-- | Let current player take their turn.
beginTurn :: Bool -> Game -> IO Game