Follow «Coordinates» change in protocol

This commit is contained in:
Tissevert 2020-01-18 09:36:01 +01:00
parent 76c27fa4b4
commit ff9194d416
1 changed files with 6 additions and 2 deletions

View File

@ -14,10 +14,11 @@ import Hanafuda (
)
import Hanafuda.KoiKoi (Move(..), PlayerID, Step(..))
import Hanafuda.Message (PublicGame(..), PublicState(..), PublicPlayer)
import qualified Hanafuda.Message as Message (Coordinates(..))
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
[] -> Play $ worstFor month opponent hand
available ->
@ -25,11 +26,14 @@ move me (PublicGame {playerHand, public = PublicState {step = ToPlay, month, pla
let matchingCards = cardsOfPack . sameMonth riverCard $ playerHand in
capture (bestFor month (players ! me) matchingCards) riverCard river
where
month = Message.month $ coordinates
hand = cardsOfPack playerHand
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
where
month = Message.month $ coordinates
move _ (PublicGame {playerHand, public = PublicState {step = Scored}}) =
KoiKoi $ playerHand /= empty