fix: address review issues in screen extraction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,7 @@ func (s *ClassSelectScreen) Update(msg tea.Msg, ctx *Context) (Screen, tea.Cmd)
|
|||||||
ctx.Lobby.StartRoom(ctx.RoomCode)
|
ctx.Lobby.StartRoom(ctx.RoomCode)
|
||||||
gs := NewGameScreen()
|
gs := NewGameScreen()
|
||||||
gs.gameState = ctx.Session.GetState()
|
gs.gameState = ctx.Session.GetState()
|
||||||
return gs, nil
|
return gs, gs.pollState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
ui/model.go
10
ui/model.go
@@ -8,11 +8,6 @@ import (
|
|||||||
"github.com/tolelom/catacombs/store"
|
"github.com/tolelom/catacombs/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StateUpdateMsg is sent by GameSession to update the view
|
|
||||||
type StateUpdateMsg struct {
|
|
||||||
State game.GameState
|
|
||||||
}
|
|
||||||
|
|
||||||
type tickMsg struct{}
|
type tickMsg struct{}
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
@@ -66,11 +61,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.ctx.Height = 24
|
m.ctx.Height = 24
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
case StateUpdateMsg:
|
|
||||||
if gs, ok := m.currentScreen.(*GameScreen); ok {
|
|
||||||
gs.gameState = msg.State
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next, cmd := m.currentScreen.Update(msg, m.ctx)
|
next, cmd := m.currentScreen.Update(msg, m.ctx)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
@@ -22,7 +23,9 @@ func (s *NicknameScreen) Update(msg tea.Msg, ctx *Context) (Screen, tea.Cmd) {
|
|||||||
if isEnter(key) && len(s.input) > 0 {
|
if isEnter(key) && len(s.input) > 0 {
|
||||||
ctx.PlayerName = s.input
|
ctx.PlayerName = s.input
|
||||||
if ctx.Store != nil && ctx.Fingerprint != "" {
|
if ctx.Store != nil && ctx.Fingerprint != "" {
|
||||||
ctx.Store.SaveProfile(ctx.Fingerprint, ctx.PlayerName)
|
if err := ctx.Store.SaveProfile(ctx.Fingerprint, ctx.PlayerName); err != nil {
|
||||||
|
slog.Error("failed to save profile", "error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ctx.Lobby != nil {
|
if ctx.Lobby != nil {
|
||||||
ctx.Lobby.PlayerOnline(ctx.Fingerprint, ctx.PlayerName)
|
ctx.Lobby.PlayerOnline(ctx.Fingerprint, ctx.PlayerName)
|
||||||
|
|||||||
Reference in New Issue
Block a user