Follow «Coordinates» change in protocol

This commit is contained in:
Tissevert 2020-01-18 09:36:01 +01:00
parent 76c27fa4b4
commit ff9194d416

View file

@ -14,10 +14,11 @@ import Hanafuda (
) )
import Hanafuda.KoiKoi (Move(..), PlayerID, Step(..)) import Hanafuda.KoiKoi (Move(..), PlayerID, Step(..))
import Hanafuda.Message (PublicGame(..), PublicState(..), PublicPlayer) import Hanafuda.Message (PublicGame(..), PublicState(..), PublicPlayer)
import qualified Hanafuda.Message as Message (Coordinates(..))
move :: PlayerID -> PublicGame -> Move move :: PlayerID -> PublicGame -> Move
move me (PublicGame {playerHand, public = PublicState {step = ToPlay, month, players, river}}) = move me (PublicGame {playerHand, public = PublicState {coordinates, step = ToPlay, players, river}}) =
case getAvailableCards hand (cardsOfPack river) of case getAvailableCards hand (cardsOfPack river) of
[] -> Play $ worstFor month opponent hand [] -> Play $ worstFor month opponent hand
available -> available ->
@ -25,11 +26,14 @@ move me (PublicGame {playerHand, public = PublicState {step = ToPlay, month, pla
let matchingCards = cardsOfPack . sameMonth riverCard $ playerHand in let matchingCards = cardsOfPack . sameMonth riverCard $ playerHand in
capture (bestFor month (players ! me) matchingCards) riverCard river capture (bestFor month (players ! me) matchingCards) riverCard river
where where
month = Message.month $ coordinates
hand = cardsOfPack playerHand hand = cardsOfPack playerHand
opponent = snd . findMin $ delete me players opponent = snd . findMin $ delete me players
move me (PublicGame {public = PublicState {step = Turned card, month, players, river}}) = move me (PublicGame {public = PublicState {coordinates, step = Turned card, players, river}}) =
Choose . bestFor month (players ! me) . cardsOfPack $ sameMonth card river Choose . bestFor month (players ! me) . cardsOfPack $ sameMonth card river
where
month = Message.month $ coordinates
move _ (PublicGame {playerHand, public = PublicState {step = Scored}}) = move _ (PublicGame {playerHand, public = PublicState {step = Scored}}) =
KoiKoi $ playerHand /= empty KoiKoi $ playerHand /= empty