Browse Source

Fix bug in end of game handling

main
Tissevert 3 years ago
parent
commit
9fb130c944
  1. 12
      src/Automaton.hs

12
src/Automaton.hs

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

Loading…
Cancel
Save