-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.go
45 lines (36 loc) · 1.12 KB
/
help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package tictactoe
import tea "github.com/charmbracelet/bubbletea"
type Help struct {
Parent tea.Model
}
func (h Help) Init() tea.Cmd {
return nil
}
func (h Help) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case tea.KeyMsg:
return h.Parent, nil
}
return h, nil
}
func (h Help) View() string {
return `
TicTacToe - Help
════════════════════
Rules:
Two players place their piece ("X" or "O") on the board.
Goal is to get 3 pieces in a row. A "row" is vertical, horizontal or diagonal.
A player can't place a piece into a cell that's already occupied.
Also: Once a piece was placed into a cell, it can't be moved anymore.
Can no player make a valid move, but no player got 3 pieces in a row,
the game ends in a draw.
Keys:
<Arrow Keys> = Move your cursor across the board
<Enter> = Place your piece into the current cell if possible
<t> = Change the board layout
<CTRL+C>, <q> = Quit the game
<h> = Show this help
<m> = Let the A.I. make a move
<n> = Start a new game
Press any key to return to the game`
}