diff options
-rw-r--r-- | Game.hs | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -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 |