implement online player bidding
This commit is contained in:
+21
-1
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user