module Skat.Matches ( singleVsBots, pvp, pvpWithBidding, singleWithBidding ) where import Control.Monad.State import Control.Monad.Reader import System.Random (mkStdGen) import Skat import Skat.Operations import Skat.Player import Skat.Pile import Skat.Card import Skat.Preperation import Skat.AI.Rulebased import Skat.AI.Online import Skat.AI.Stupid -- | predefined card distribution for testing purposes cardDistr :: Piles cardDistr = emptyPiles hand1 hand2 hand3 skt where hand3 = [Card Ace Spades, Card Jack Diamonds, Card Jack Clubs, Card King Spades, Card Nine Spades, Card Ace Diamonds, Card Queen Diamonds, Card Ten Clubs, Card Eight Clubs, Card King Clubs] hand1 = [Card Jack Spades, Card Jack Hearts, Card Ten Spades, Card Ace Hearts, Card Ten Hearts, Card Nine Hearts, Card Seven Clubs, Card Ace Clubs, Card King Diamonds, Card Ten Diamonds] hand2 = [Card Eight Spades, Card Queen Spades, Card Seven Spades, Card Seven Diamonds, Card Seven Hearts, Card Eight Hearts, Card Queen Hearts, Card King Hearts, Card Nine Diamonds, Card Eight Diamonds] skt = [Card Nine Clubs, Card Queen Clubs] singleVsBots :: Communicator c => c -> IO () singleVsBots comm = do cards <- shuffleCards let ps = Players (PL $ OnlineEnv Team Hand1 comm) (PL $ Stupid Team Hand2) (PL $ mkAIEnv Single Hand3 10) env = SkatEnv (distribute cards) Nothing Spades ps Hand1 liftIO $ evalStateT (publishGameStart >> turn >>= publishGameResults) env singleWithBidding :: Communicator c => c -> IO () singleWithBidding comm = do cards <- shuffleCards let ps = distribute cards h1 = map toCard $ handCards Hand1 ps bs = Bidders (BD $ PrepOnline Hand1 comm h1) (BD $ NoBidder Hand2) (BD $ NoBidder Hand3) env = PrepEnv ps bs maySkatEnv <- liftIO $ runReaderT runPreperation env case maySkatEnv of Just skatEnv -> liftIO $ evalStateT (publishGameStart >> turn >>= publishGameResults) skatEnv Nothing -> putStrLn "No one wanted to play." pvp :: Communicator c => c -> c -> c -> IO () pvp comm1 comm2 comm3 = do cards <- shuffleCards let ps = Players (PL $ OnlineEnv Team Hand1 comm1) (PL $ OnlineEnv Team Hand2 comm2) (PL $ OnlineEnv Team Hand3 comm3) env = SkatEnv (distribute cards) Nothing Spades ps Hand1 liftIO $ evalStateT (publishGameStart >> turn >>= publishGameResults) env pvpWithBidding :: Communicator c => c -> c -> c -> IO () pvpWithBidding comm1 comm2 comm3 = do cards <- shuffleCards let ps = distribute cards h1 = map toCard $ handCards Hand1 ps h2 = map toCard $ handCards Hand2 ps h3 = map toCard $ handCards Hand3 ps bs = Bidders (BD $ PrepOnline Hand1 comm1 $ h1) (BD $ PrepOnline Hand2 comm2 $ h2) (BD $ PrepOnline Hand3 comm3 $ h3) env = PrepEnv ps bs maySkatEnv <- liftIO $ runReaderT runPreperation env case maySkatEnv of Just skatEnv -> liftIO $ evalStateT (publishGameStart >> turn >>= publishGameResults) skatEnv Nothing -> putStrLn "No one wanted to play."