Files
Catacombs/ui/lobby_view.go
tolelom 4e76e48588 feat: TUI views, full state machine, and server integration
Add title, lobby, class select, game, shop, and result screens.
Rewrite model.go with 6-screen state machine and input routing.
Wire server/ssh.go and main.go with lobby and store.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 00:11:56 +09:00

57 lines
1014 B
Go

package ui
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
type lobbyState struct {
rooms []roomInfo
input string
cursor int
creating bool
roomName string
}
type roomInfo struct {
Code string
Name string
Players int
Status string
}
func renderLobby(state lobbyState, width, height int) string {
headerStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("205")).
Bold(true)
roomStyle := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
Padding(0, 1)
header := headerStyle.Render("── Lobby ──")
menu := "[C] Create Room [J] Join by Code [Q] Back"
roomList := ""
for i, r := range state.rooms {
marker := " "
if i == state.cursor {
marker = "> "
}
roomList += fmt.Sprintf("%s%s [%s] (%d/4) %s\n",
marker, r.Name, r.Code, r.Players, r.Status)
}
if roomList == "" {
roomList = " No rooms available. Create one!"
}
return lipgloss.JoinVertical(lipgloss.Left,
header,
"",
roomStyle.Render(roomList),
"",
menu,
)
}