Fix: various bug fix
This commit is contained in:
@@ -22,9 +22,8 @@ const (
|
||||
|
||||
type WordleClientModel struct {
|
||||
*BaseModel
|
||||
conn *websocket.Conn
|
||||
state types.WordleState
|
||||
shutdown types.ShutdownFunc
|
||||
conn *websocket.Conn
|
||||
state types.WordleState
|
||||
|
||||
input textinput.Model
|
||||
err error
|
||||
@@ -32,7 +31,6 @@ type WordleClientModel struct {
|
||||
|
||||
func NewWordleClientModel(
|
||||
base *BaseModel,
|
||||
shutdown types.ShutdownFunc,
|
||||
) *WordleClientModel {
|
||||
input := textinput.New()
|
||||
input.Focus()
|
||||
@@ -41,7 +39,6 @@ func NewWordleClientModel(
|
||||
return &WordleClientModel{
|
||||
BaseModel: base,
|
||||
input: input,
|
||||
shutdown: shutdown,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +115,15 @@ func (m *WordleClientModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "ctrl+c":
|
||||
m.conn.Close()
|
||||
m.shutdown()
|
||||
return m, tea.Quit
|
||||
case "enter":
|
||||
if m.state.GameEnd {
|
||||
m.conn.Close()
|
||||
m.shutdown()
|
||||
*m.queue = append(*m.queue,
|
||||
tea.NewProgram(NewLobbyModel(m.BaseModel)))
|
||||
p := tea.NewProgram(NewLobbyModel(m.BaseModel))
|
||||
m.Push(types.Program{
|
||||
Run: func() error { _, err := p.Run(); return err },
|
||||
Stage: types.StageLobby,
|
||||
})
|
||||
return m, tea.Quit
|
||||
}
|
||||
if len(m.input.Value()) == types.GUESS_WORD_LENGTH {
|
||||
|
||||
Reference in New Issue
Block a user