From 7f34eef9fb39824ea5457368db593adca7b5c30b Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 11 Jan 2023 15:55:41 +0800 Subject: Define data Setup --- Game.hs | 21 +++++++++++++-------- 1 file 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 -- cgit v1.2.3