diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-04-17 17:46:05 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-04-17 17:46:05 +0200 |
commit | 3ad0d21e072c7461ea78a9a85111e6e19d3b0632 (patch) | |
tree | 186045fd7b6ecd6c25c1deab504f25297bf6e134 /pkg/ui/views/game.go | |
parent | 95da822f025b544f700729afc676ba0f3c981154 (diff) |
Handle abandon game
Diffstat (limited to 'pkg/ui/views/game.go')
-rw-r--r-- | pkg/ui/views/game.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/ui/views/game.go b/pkg/ui/views/game.go index d545fcb..7075f8b 100644 --- a/pkg/ui/views/game.go +++ b/pkg/ui/views/game.go @@ -96,7 +96,15 @@ func (m GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m, cmd = m.handleDatabaseGameMsg(msg) cmds = append(cmds, cmd, m.updateMovesListCmd()) case EndGameMsg: - return m, nil + if msg.abandoned { + if m.peer == "peer-2" { + m.game.Outcome = "1-0" + } else { + m.game.Outcome = "0-1" + } + m, cmd = m.handleDatabaseGameMsg(*m.game) + cmds = append(cmds, cmd) + } case error: m.err = msg } @@ -121,7 +129,7 @@ func (m GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { cmds = append(cmds, m.getMoves(), m.updateMovesListCmd()) if m.chessGame.Outcome() != chess.NoOutcome { - cmds = append(cmds, m.endGame()) + cmds = append(cmds, m.endGame(m.chessGame.Outcome().String())) } } } |