summaryrefslogtreecommitdiff
path: root/pkg/ui/views/game_api.go
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2025-04-27 12:52:51 +0200
committerSanto Cariotti <santo@dcariotti.me>2025-04-27 12:52:51 +0200
commit5a3ce746e00393fbb2c676e3d9c037e0e3014fc8 (patch)
tree8a42a1d08c3fe6db768e7569e31800081714ae36 /pkg/ui/views/game_api.go
parent85a6b4c2915fbfb42978fd7d2e3f7bd67e650314 (diff)
Use the multiplayer's type instead of simple string to send messages
Diffstat (limited to 'pkg/ui/views/game_api.go')
-rw-r--r--pkg/ui/views/game_api.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/ui/views/game_api.go b/pkg/ui/views/game_api.go
index 32ea873..5ae03c4 100644
--- a/pkg/ui/views/game_api.go
+++ b/pkg/ui/views/game_api.go
@@ -9,6 +9,7 @@ import (
"github.com/boozec/rahanna/internal/api/database"
"github.com/boozec/rahanna/pkg/p2p"
+ "github.com/boozec/rahanna/pkg/ui/multiplayer"
tea "github.com/charmbracelet/bubbletea"
"github.com/notnil/chess"
)
@@ -56,7 +57,7 @@ func (m GameModel) handleDatabaseGameMsg(msg database.Game) (GameModel, tea.Cmd)
} else {
m.turn = m.playerPeer(1)
}
- m.network.SendAll([]byte("define-turn"), []byte(string(m.turn)))
+ m.network.SendAll([]byte(string(multiplayer.DefineTurnMessage)), []byte(string(m.turn)))
}
@@ -135,7 +136,7 @@ func (m *GameModel) endGame(outcome string, abandon bool) tea.Cmd {
}
if abandon {
- m.network.SendAll([]byte("abandon"), []byte("🏳️"))
+ m.network.SendAll([]byte(string(multiplayer.AbandonGameMessage)), []byte("🏳️"))
}
return game