diff options
Diffstat (limited to 'Game.hs')
-rw-r--r-- | Game.hs | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1,11 +1,37 @@ module Game where -import Player (Player) +import Data.Char (isDigit) +import Control.Monad (when) +import System.Random (RandomGen) +import Player (Player, shed, draw) import qualified Player as P import Card (Card) import qualified Card as C +data Direction = CCW | CW data Game = Game { players :: [Player] + , playerIdx :: Int + , attack :: Integer + , direction :: Direction , stockPile :: [Card] , discardPile :: [Card] } + +prompt :: Game -> IO Card +prompt game@(Game plyrs pidx att _ _ _) = do + let player = plyrs !! pidx + let cards = P.cards player + putStrLn $ P.name player ++ "'s turn" + putStrLn $ P.showCards player + cardIdxStr <- getLine + if any (== False) $ map isDigit cardIdxStr + then do + putStrLn "Please input card #" + prompt game + else do + let cardIdx = read cardIdxStr - 1 + if cardIdx < 0 || cardIdx >= length cards + then do + putStrLn "This card does not exist, try again" + prompt game + else return $ cards !! cardIdx |