Fix bug in end of game handling

This commit is contained in:
Tissevert 2019-08-27 21:57:26 +02:00
parent 48f6ab65ab
commit 9fb130c944

View file

@ -78,11 +78,11 @@ answer (Message.Relay {Message.message = Message.Invitation {}}) state = do
return state return state
answer (Message.Game {Message.game, Message.logs}) state@(Playing {key, name}) = do answer (Message.Game {Message.game, Message.logs}) state@(Playing {key, name}) = do
if playing game == key
then do
case step game of case step game of
Over -> send Message.Quit >> return (LoggedIn {key, name}) Over -> send Message.Quit >> return (LoggedIn {key, name})
_ -> send (Message.Play {Message.move = AI.move key game}) >> return state _ -> do
if playing game == key
then send (Message.Play {Message.move = AI.move key game}) >> return state
else return state else return state
answer (Message.Relay {Message.from, Message.message = Message.LogOut}) (Playing {key, name, against}) answer (Message.Relay {Message.from, Message.message = Message.LogOut}) (Playing {key, name, against})