From 3ad0d21e072c7461ea78a9a85111e6e19d3b0632 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 17 Apr 2025 17:46:05 +0200 Subject: Handle abandon game --- pkg/ui/views/game.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkg/ui/views/game.go') 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())) } } } -- cgit v1.2.3-18-g5258