Add gameID directly into Game data structure
This commit is contained in:
parent
ce0f51720a
commit
7a324ee7ef
2 changed files with 7 additions and 3 deletions
|
@ -32,7 +32,8 @@ import Hanafuda.KoiKoi.Game (
|
|||
import qualified Hanafuda.KoiKoi.Round as Round (deal, next)
|
||||
import qualified Hanafuda.KoiKoi.Turn as Turn (catch, end, next)
|
||||
import Control.Monad.Except (MonadError(..))
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import Control.Monad.IO.Class (MonadIO(..))
|
||||
import System.Random (randomIO)
|
||||
|
||||
play :: Environment m => Move -> Game -> m Game
|
||||
play move game@(Game {river, step}) =
|
||||
|
@ -56,8 +57,10 @@ play move game@(Game {river, step}) =
|
|||
new :: MonadIO m => (PlayerID, PlayerID) -> Mode -> m Game
|
||||
new (playerA, playerB) mode = do
|
||||
playing <- Player.random players
|
||||
gameID <- liftIO $ randomIO
|
||||
Round.deal $ Game {
|
||||
mode
|
||||
gameID
|
||||
, mode
|
||||
, scores = Player.scores players [0, 0]
|
||||
, month = Pine
|
||||
, players
|
||||
|
|
|
@ -50,7 +50,8 @@ instance IDType Game where
|
|||
type PlayerTurn = Map PlayerID PlayerID
|
||||
|
||||
data Game = Game {
|
||||
mode :: Mode
|
||||
gameID :: GameID
|
||||
, mode :: Mode
|
||||
, scores :: Scores
|
||||
, month :: Flower
|
||||
, nextPlayer :: PlayerTurn
|
||||
|
|
Loading…
Reference in a new issue