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_moves.go | |
parent | 95da822f025b544f700729afc676ba0f3c981154 (diff) |
Handle abandon game
Diffstat (limited to 'pkg/ui/views/game_moves.go')
-rw-r--r-- | pkg/ui/views/game_moves.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/ui/views/game_moves.go b/pkg/ui/views/game_moves.go index 2fa7c9e..4ce3796 100644 --- a/pkg/ui/views/game_moves.go +++ b/pkg/ui/views/game_moves.go @@ -25,12 +25,15 @@ func (i item) FilterValue() string { return i.title } func (m *GameModel) getMoves() tea.Cmd { m.network.Server.OnReceiveFn = func(msg network.Message) { - moveStr := string(msg.Payload) - m.incomingMoves <- moveStr + payload := string(msg.Payload) + m.incomingMoves <- payload } return func() tea.Msg { move := <-m.incomingMoves + if move == "🏳️" { + return EndGameMsg{abandoned: true} + } return ChessMoveMsg(move) } } @@ -75,7 +78,7 @@ func (m GameModel) handleChessMoveMsg(msg ChessMoveMsg) (GameModel, tea.Cmd) { } if m.chessGame.Outcome() != chess.NoOutcome { - cmds = append(cmds, m.endGame()) + cmds = append(cmds, m.endGame(m.chessGame.Outcome().String())) } return m, tea.Batch(cmds...) |