feat: add single player snake mode

Add solo mode where players survive as long as possible while tracking
score (food eaten). Single player games start with a shorter 3-second
countdown vs 10 seconds for multiplayer, maintain exactly 1 food item
for classic snake feel, and end when the player dies rather than when
one player remains.

- Add GameMode type (ModeMultiplayer/ModeSinglePlayer) and Score field
- Filter single player games from "Join a Game" lobby list
- Show "Ready?" and "Score: X" UI for single player mode
- Hide invite link for single player games
- Preserve game mode on rematch
This commit is contained in:
Ryan Hamamura
2026-02-04 07:33:02 -10:00
parent 7faf94fa6d
commit f454e0d220
14 changed files with 205 additions and 78 deletions

View File

@@ -6,20 +6,21 @@ import (
)
type LobbyProps struct {
NicknameBind h.H
CreateGameKeyDown h.H
CreateGameClick h.H
IsLoggedIn bool
Username string
LogoutClick h.H
UserGames []GameListItem
DeleteGameClick func(id string) h.H
ActiveTab string
TabClickConnect4 h.H
TabClickSnake h.H
SnakeNicknameBind h.H
SnakePresetClicks []h.H
ActiveSnakeGames []*snake.SnakeGame
NicknameBind h.H
CreateGameKeyDown h.H
CreateGameClick h.H
IsLoggedIn bool
Username string
LogoutClick h.H
UserGames []GameListItem
DeleteGameClick func(id string) h.H
ActiveTab string
TabClickConnect4 h.H
TabClickSnake h.H
SnakeNicknameBind h.H
SnakeSoloClicks []h.H
SnakeMultiClicks []h.H
ActiveSnakeGames []*snake.SnakeGame
}
func LobbyView(p LobbyProps) h.H {
@@ -40,7 +41,7 @@ func LobbyView(p LobbyProps) h.H {
var tabContent h.H
if p.ActiveTab == "snake" {
tabContent = SnakeLobbyTab(p.SnakeNicknameBind, p.SnakePresetClicks, p.ActiveSnakeGames)
tabContent = SnakeLobbyTab(p.SnakeNicknameBind, p.SnakeSoloClicks, p.SnakeMultiClicks, p.ActiveSnakeGames)
} else {
tabContent = connect4LobbyContent(p)
}