Finally export the useful Player type instanciated for KoiKoi games since that the only ones we support so far

This commit is contained in:
Tissevert 2019-10-17 12:05:34 +02:00
parent ff1a31a105
commit d2918c5256
2 changed files with 18 additions and 8 deletions

View file

@ -8,8 +8,11 @@ module Hanafuda.KoiKoi (
, GameID , GameID
, Mode(..) , Mode(..)
, Move(..) , Move(..)
, Player
, PlayerID , PlayerID
, Players
, Score , Score
, Scores
, Source(..) , Source(..)
, Step(..) , Step(..)
, Yaku(..) , Yaku(..)
@ -21,8 +24,8 @@ 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(..), GameID, Mode(..), Move(..), PlayerID Action(..), Environment, Game(..), GameID, Mode(..), Move(..), Player
, Source(..), Step(..) , PlayerID, Players, Scores, Source(..), Step(..)
) )
import qualified Hanafuda.KoiKoi.Round as Round (deal, next) import qualified Hanafuda.KoiKoi.Round as Round (deal, next)
import qualified Hanafuda.KoiKoi.Turn as Turn (catch, end, next) import qualified Hanafuda.KoiKoi.Turn as Turn (catch, end, next)

View file

@ -9,7 +9,10 @@ module Hanafuda.KoiKoi.Game (
, ID , ID
, Mode(..) , Mode(..)
, Move(..) , Move(..)
, Player
, PlayerID , PlayerID
, Players
, Scores
, Source(..) , Source(..)
, Step(..) , Step(..)
, end , end
@ -22,8 +25,7 @@ import Control.Monad.Writer (MonadWriter)
import Hanafuda (Card, Flower, Pack) import Hanafuda (Card, Flower, Pack)
import Hanafuda.ID (ID) import Hanafuda.ID (ID)
import qualified Hanafuda.KoiKoi.Yaku as KoiKoi (Score) import qualified Hanafuda.KoiKoi.Yaku as KoiKoi (Score)
import Hanafuda.Player (Players, Player, Scores, set) import qualified Hanafuda.Player as Player (ID, Players, Player, Scores, set)
import qualified Hanafuda.Player as Player (ID)
data Mode = FirstAt Int | WholeYear deriving (Show) data Mode = FirstAt Int | WholeYear deriving (Show)
data Move = Play Card | Capture (Card, Card) | Choose Card | KoiKoi Bool data Move = Play Card | Capture (Card, Card) | Choose Card | KoiKoi Bool
@ -36,14 +38,17 @@ data Action = Action {
} deriving (Show) } deriving (Show)
type Environment m = (MonadIO m, MonadError String m, MonadWriter [Action] m) type Environment m = (MonadIO m, MonadError String m, MonadWriter [Action] m)
type Player = Player.Player KoiKoi.Score
type PlayerID = Player.ID KoiKoi.Score type PlayerID = Player.ID KoiKoi.Score
type Players = Player.Players KoiKoi.Score
type Scores = Player.Scores KoiKoi.Score
type GameID = ID Game type GameID = ID Game
data Game = Game { data Game = Game {
mode :: Mode mode :: Mode
, scores :: Scores KoiKoi.Score , scores :: Scores
, month :: Flower , month :: Flower
, players :: Players KoiKoi.Score , players :: Players
, playing :: PlayerID , playing :: PlayerID
, winning :: PlayerID , winning :: PlayerID
, oyake :: PlayerID , oyake :: PlayerID
@ -54,8 +59,10 @@ data Game = Game {
, rounds :: [(PlayerID, KoiKoi.Score)] , rounds :: [(PlayerID, KoiKoi.Score)]
} deriving (Show) } deriving (Show)
setPlayer :: Game -> Player KoiKoi.Score -> Game setPlayer :: Game -> Player -> Game
setPlayer game@(Game {players, playing}) player = game {players = set playing player players} setPlayer game@(Game {players, playing}) player = game {
players = Player.set playing player players
}
end :: Monad m => Game -> m Game end :: Monad m => Game -> m Game
end game = return $ game {step = Over} end game = return $ game {step = Over}