Skip to content

Commit

Permalink
- don't resign automatically on game close (only unobserve, if
Browse files Browse the repository at this point in the history
  necessary)
- save game earlier, on game result, not on game window close
  • Loading branch information
tgass committed Feb 18, 2017
1 parent d10a2fb commit 327b56f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Macbeth/Wx/Game/Game.hs
Expand Up @@ -120,6 +120,7 @@ wxGame env gameProperties@(G.GameProperties gameId playerW playerB _) chan = do
set status [text := R.toString result]
Api.setResult vBoardState (R.result result)
repaint p_board
when (Api.isGameUser boardState) $ readTVarIO vBoardState >>= saveAsPGN
hPutStrLn h "4 iset seekinfo 1"
killThread threadId

Expand All @@ -140,10 +141,9 @@ wxGame env gameProperties@(G.GameProperties gameId playerW playerB _) chan = do
windowOnDestroy f $ do
sequence_ $ fmap (handle (\(_ :: IOException) -> return ()) . killThread) [threadId, tiClose]
boardState' <- readTVarIO vBoardState
when (Api.isGameUser boardState) $ saveAsPGN boardState'
unless (isJust $ Api.gameResult boardState) $
if Api.isGameUser boardState then hPutStrLn h "5 resign"
else hPutStrLn h $ "5 unobserve " ++ show gameId

when (isNothing (Api.gameResult boardState') && not (Api.isGameUser boardState)) $
hPutStrLn h $ "5 unobserve " ++ show gameId


resizeFrame :: Frame () -> TVar Api.BoardState -> Panel() -> IO ()
Expand Down

0 comments on commit 327b56f

Please sign in to comment.