From b8abc0fb3caa38481738c57afac4e76f36e76583 Mon Sep 17 00:00:00 2001 From: Grzegorz Dziedzic Date: Fri, 31 May 2024 09:11:50 +0200 Subject: [PATCH] fix(Multiplayer): correct description of the controls -use constants instead of string value --- multiplayer-tcp.go | 4 ++-- multiplayer.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/multiplayer-tcp.go b/multiplayer-tcp.go index 9a2b90c..b961cd6 100644 --- a/multiplayer-tcp.go +++ b/multiplayer-tcp.go @@ -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: @@ -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, diff --git a/multiplayer.go b/multiplayer.go index d909c99..bfcaf5a 100644 --- a/multiplayer.go +++ b/multiplayer.go @@ -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 { @@ -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 } @@ -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,