Skip to content

Commit

Permalink
fix(Multiplayer): correct description of the controls
Browse files Browse the repository at this point in the history
-use constants instead of string value
  • Loading branch information
DziedzicGrzegorz committed May 31, 2024
1 parent 7a0ad99 commit b8abc0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions multiplayer-tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (m TCPmodel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case tea.KeyMsg:
switch msg.String() {
case constants.CtrlC, constants.Quit:
case constants.CtrlC, constants.Esc:
return m, tea.Quit

case constants.Up:
Expand Down Expand Up @@ -162,7 +162,7 @@ func (m TCPmodel) View() string {
header := constants.HeaderStyle.Render(currentPlayer)

// Instructions
footer := constants.SubtleStyle.Render("j/k, up/down: move | h/l, left/right: move | enter: select | ctrl+c: quit")
footer := constants.SubtleStyle.Render("arrow keys: move | enter: select | ctrl+c or Esc: quit")

// Joining all cells horizontally
board := lipgloss.JoinVertical(lipgloss.Left,
Expand Down
14 changes: 7 additions & 7 deletions multiplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ func (m *GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "up", "k":
case constants.Up:
m.moveCursor(-3)
case "down", "j":
case constants.Down:
m.moveCursor(3)
case "left", "h":
case constants.Left:
m.moveCursor(-1)
case "right", "l":
case constants.Right:
m.moveCursor(1)
case "enter":
case constants.Enter:
if !m.placeMarker() {
m.errorMessage = "Cannot overwrite existing marker!"
} else {
Expand All @@ -72,7 +72,7 @@ func (m *GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
m.switchPlayer()
}
case "ctrl+c", "q", "esc":
case constants.CtrlC, constants.Esc:
return m, tea.Quit
}

Expand Down Expand Up @@ -199,7 +199,7 @@ func (m *GameModel) renderBoard() string {
header := constants.HeaderStyle.Render(currentPlayer)

// Quick help
footer := constants.SubtleStyle.Render("j/k, up/down: move | h/l, left/right: move | enter: select | ctrl+c: quit")
footer := constants.SubtleStyle.Render("arrow keys: move | enter: select | ctrl+c or Esc: quit")

// Joining all cells horizontally
board := lipgloss.JoinVertical(lipgloss.Left,
Expand Down

0 comments on commit b8abc0f

Please # to comment.