diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-04-26 21:12:38 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-04-26 21:12:38 +0200 |
commit | a39917dd45838b8e6d78f28b61d46478e428aa21 (patch) | |
tree | fc0f553f28605b56f33698ce38f217eae60a7cf6 | |
parent | 0eba18e775ec6de803a9f562739004b27fc63ce2 (diff) |
Fix: do not add emtpy IP peers
-rw-r--r-- | pkg/ui/views/game_api.go | 7 | ||||
-rw-r--r-- | pkg/ui/views/game_restore.go | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/pkg/ui/views/game_api.go b/pkg/ui/views/game_api.go index f39a771..66b63c1 100644 --- a/pkg/ui/views/game_api.go +++ b/pkg/ui/views/game_api.go @@ -18,8 +18,11 @@ func (m GameModel) handleDatabaseGameMsg(msg database.Game) (GameModel, tea.Cmd) peers := map[int]string{ 1: m.game.IP1, 2: m.game.IP2, - 3: m.game.IP3, - 4: m.game.IP4, + } + + if m.game.Type == database.PairGameType { + peers[3] = m.game.IP3 + peers[4] = m.game.IP4 } myPlayerNum := -1 diff --git a/pkg/ui/views/game_restore.go b/pkg/ui/views/game_restore.go index 95f8844..64d99ce 100644 --- a/pkg/ui/views/game_restore.go +++ b/pkg/ui/views/game_restore.go @@ -5,6 +5,7 @@ import ( "strings" "time" + "github.com/boozec/rahanna/internal/api/database" "github.com/boozec/rahanna/pkg/p2p" tea "github.com/charmbracelet/bubbletea" ) @@ -23,8 +24,11 @@ func (m GameModel) handleSendRestoreMsg(source p2p.NetworkID) tea.Cmd { peers := map[int]string{ 1: m.game.IP1, 2: m.game.IP2, - 3: m.game.IP3, - 4: m.game.IP4, + } + + if m.game.Type == database.PairGameType { + peers[3] = m.game.IP3 + peers[4] = m.game.IP4 } myPlayerNum := -1 |