Remove parameter from Game type, games will be shared publicly with a different type

This commit is contained in:
Tissevert 2019-10-16 10:30:31 +02:00
parent 61eeac8bc6
commit ff1a31a105
4 changed files with 7 additions and 10 deletions

View file

@ -4,8 +4,7 @@ module Hanafuda.KoiKoi (
Action(..) Action(..)
, Card(..) , Card(..)
, Environment , Environment
, Game , Game(..)
, GameBlueprint(..)
, GameID , GameID
, Mode(..) , Mode(..)
, Move(..) , Move(..)
@ -22,7 +21,7 @@ import Hanafuda (Card(..), Flower(Pine), contains, flower, match, remove)
import qualified Hanafuda.Player as Player (players, random, scores) import qualified Hanafuda.Player as Player (players, random, scores)
import Hanafuda.KoiKoi.Yaku (Yaku(..), Score) import Hanafuda.KoiKoi.Yaku (Yaku(..), Score)
import Hanafuda.KoiKoi.Game ( import Hanafuda.KoiKoi.Game (
Action(..), Environment, Game, GameBlueprint(..), GameID, Mode(..), Move(..), PlayerID Action(..), Environment, Game(..), GameID, Mode(..), Move(..), PlayerID
, Source(..), Step(..) , Source(..), Step(..)
) )
import qualified Hanafuda.KoiKoi.Round as Round (deal, next) import qualified Hanafuda.KoiKoi.Round as Round (deal, next)

View file

@ -4,8 +4,7 @@
module Hanafuda.KoiKoi.Game ( module Hanafuda.KoiKoi.Game (
Action(..) Action(..)
, Environment , Environment
, Game , Game(..)
, GameBlueprint(..)
, GameID , GameID
, ID , ID
, Mode(..) , Mode(..)
@ -40,7 +39,7 @@ type Environment m = (MonadIO m, MonadError String m, MonadWriter [Action] m)
type PlayerID = Player.ID KoiKoi.Score type PlayerID = Player.ID KoiKoi.Score
type GameID = ID Game type GameID = ID Game
data GameBlueprint deckType = Game { data Game = Game {
mode :: Mode mode :: Mode
, scores :: Scores KoiKoi.Score , scores :: Scores KoiKoi.Score
, month :: Flower , month :: Flower
@ -48,13 +47,12 @@ data GameBlueprint deckType = Game {
, playing :: PlayerID , playing :: PlayerID
, winning :: PlayerID , winning :: PlayerID
, oyake :: PlayerID , oyake :: PlayerID
, deck :: deckType , deck :: [Card]
, river :: Pack , river :: Pack
, step :: Step , step :: Step
, trick :: [Card] , trick :: [Card]
, rounds :: [(PlayerID, KoiKoi.Score)] , rounds :: [(PlayerID, KoiKoi.Score)]
} deriving (Show) } deriving (Show)
type Game = GameBlueprint [Card]
setPlayer :: Game -> Player KoiKoi.Score -> Game setPlayer :: Game -> Player KoiKoi.Score -> Game
setPlayer game@(Game {players, playing}) player = game {players = set playing player players} setPlayer game@(Game {players, playing}) player = game {players = set playing player players}

View file

@ -6,7 +6,7 @@ module Hanafuda.KoiKoi.Round (
import Hanafuda (Flower(Paulownia), cards, shuffle, packOfCards) import Hanafuda (Flower(Paulownia), cards, shuffle, packOfCards)
import Hanafuda.KoiKoi.Yaku (sumYakus) import Hanafuda.KoiKoi.Yaku (sumYakus)
import Hanafuda.KoiKoi.Game (Game, GameBlueprint(..), Mode(..), Step(..), end) import Hanafuda.KoiKoi.Game (Game(..), Mode(..), Step(..), end)
import qualified Hanafuda.Player as Player (deal, get, next, score, yakus) import qualified Hanafuda.Player as Player (deal, get, next, score, yakus)
import Data.Map ((!), insert) import Data.Map ((!), insert)
import Control.Monad.IO.Class (MonadIO) import Control.Monad.IO.Class (MonadIO)

View file

@ -11,7 +11,7 @@ import Hanafuda (Card, Pack, empty, match)
import Hanafuda.Player (Player(..), plays) import Hanafuda.Player (Player(..), plays)
import qualified Hanafuda.Player as Player (get, next) import qualified Hanafuda.Player as Player (get, next)
import Hanafuda.KoiKoi.Yaku (meldInto) import Hanafuda.KoiKoi.Yaku (meldInto)
import Hanafuda.KoiKoi.Game (Action(..), Environment, Game, GameBlueprint(..), Source(..), Step(..), setPlayer) import Hanafuda.KoiKoi.Game (Action(..), Environment, Game(..), Source(..), Step(..), setPlayer)
import qualified Hanafuda.KoiKoi.Round as Round (next) import qualified Hanafuda.KoiKoi.Round as Round (next)
import Control.Monad.Except (MonadError(..)) import Control.Monad.Except (MonadError(..))
import Control.Monad.IO.Class (MonadIO) import Control.Monad.IO.Class (MonadIO)