diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2025-04-24 13:53:54 +0200 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2025-04-24 13:53:54 +0200 |
| commit | b35829071ab0d0f3479021eac151b90e49a2fca5 (patch) | |
| tree | 0e2af88ed2732e2211ffbf5689488e010174783a /pkg/ui/views/game_moves.go | |
| parent | 4ae96a216eb50ccec7712fa9ed0d4dc8d9950f68 (diff) | |
Play co-op 2 vs 2
Diffstat (limited to 'pkg/ui/views/game_moves.go')
| -rw-r--r-- | pkg/ui/views/game_moves.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/pkg/ui/views/game_moves.go b/pkg/ui/views/game_moves.go index 32f440f..ed11d30 100644 --- a/pkg/ui/views/game_moves.go +++ b/pkg/ui/views/game_moves.go @@ -27,6 +27,7 @@ func (i item) FilterValue() string { return i.title } func (m *GameModel) getMoves() tea.Cmd { m.network.AddReceiveFunction(func(msg p2p.Message) { gm := multiplayer.GameMove{ + Source: msg.Source, Type: msg.Type, Payload: msg.Payload, } @@ -40,7 +41,7 @@ func (m *GameModel) getMoves() tea.Cmd { case multiplayer.AbandonGameMessage: return EndGameMsg{abandoned: true} case multiplayer.RestoreGameMessage: - return SendRestoreMsg{} + return SendRestoreMsg(move.Source) case multiplayer.RestoreAckGameMessage: return RestoreMoves(string(move.Payload)) default: @@ -79,14 +80,8 @@ func (m GameModel) handleUpdateMovesListMsg() GameModel { } func (m GameModel) handleChessMoveMsg(msg ChessMoveMsg) (GameModel, tea.Cmd) { - err := m.chessGame.MoveStr(string(msg)) + m.err = m.chessGame.MoveStr(string(msg)) cmds := []tea.Cmd{m.getMoves(), m.updateMovesListCmd()} - if err != nil { - m.err = err - } else { - m.turn++ - m.err = nil - } if m.chessGame.Outcome() != chess.NoOutcome { cmds = append(cmds, m.endGame(m.chessGame.Outcome().String())) |