implement online player bidding

This commit is contained in:
2020-03-28 22:30:06 +01:00
parent b6b92c2cf9
commit 1ccce66d4a
5 changed files with 173 additions and 17 deletions
+21 -1
View File
@@ -1,8 +1,9 @@
module Skat.Matches (
singleVsBots, pvp
singleVsBots, pvp, pvpWithBidding
) where
import Control.Monad.State
import Control.Monad.Reader
import System.Random (mkStdGen)
import Skat
@@ -10,6 +11,7 @@ import Skat.Operations
import Skat.Player
import Skat.Pile
import Skat.Card
import Skat.Preperation
import Skat.AI.Rulebased
import Skat.AI.Online
@@ -48,3 +50,21 @@ pvp comm1 comm2 comm3 = do
(PL $ OnlineEnv Team Hand3 comm3)
env = SkatEnv (distribute cards) Nothing Spades ps Hand1
liftIO $ evalStateT (publishGameStart Hand3 >> 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 Hand3 >> turn >>= publishGameResults) skatEnv
Nothing -> putStrLn "No one wanted to play."