module Skat.AI.Human where import Control.Monad.Trans (liftIO) import Skat.Player import Skat.Pile import Skat.Card import Skat.Utils import Skat.Render data Human = Human { getTeam :: Team , getHand :: Hand } deriving Show instance Player Human where team = getTeam hand = getHand chooseCard p table _ hand = do trumpCol <- trump turnCol <- turnColour let possible = filter (isAllowed trumpCol turnCol hand) hand c <- liftIO $ askIO (map getCard table) (map toCard possible) (map toCard hand) return $ (c, p) askIO :: [Card] -> [Card] -> [Card] -> IO Card askIO table possible hand = do putStrLn "Your hand" render hand putStrLn "These options are possible" render possible putStrLn "These cards are on the table" render table idx <- query "Which card do you want to play? Give the index of the card" if idx >= 0 && idx < length possible then return $ possible !! idx else askIO table possible hand