Add some todos

This commit is contained in:
Felix Albrigtsen 2024-12-25 22:48:01 +01:00
parent 70b45671a8
commit c6226cf24c

20
main.go
View File

@ -109,6 +109,13 @@ func RotateBoard(board [][]Player) [][]Player {
return nBoard
}
func (m GameModel) CheckVictory() GameModel {
//TODO: Check horizontal
//TODO: Check vertical
//TODO: Check diagonal
return m
}
func (m GameModel) Move() GameModel {
m.message = ""
@ -118,7 +125,7 @@ func (m GameModel) Move() GameModel {
m.message = "You cannot move to an occupied space"
break
}
// TODO: Valid that cursor is out of bounds?
xDiff := m.cursor.x - m.moveCursor.x
yDiff := m.cursor.y - m.moveCursor.y
@ -137,13 +144,14 @@ func (m GameModel) Move() GameModel {
case HasPlaced:
m.board = RotateBoard(m.board)
m.message = "The board has been rotated."
if m.playerTurn == POne {
m.playerTurn = PTwo
} else {
m.playerTurn = POne
}
m.state = StartTurn
//TODO: m = m.CheckVictory()
//TODO: Check if the board is full; do end-game checks
default:
switch m.board[m.cursor.y][m.cursor.x] {
@ -154,6 +162,7 @@ func (m GameModel) Move() GameModel {
case m.playerTurn:
m.message = "You cannot move your own piece."
default:
// Initiate move
m.state = IsMoving
m.moveCursor = m.cursor
}
@ -188,6 +197,8 @@ func (m GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.String() {
// TODO: Cancel a move on esc/q
case "ctrl+c", "q":
return m, tea.Quit
@ -260,6 +271,8 @@ func (m GameModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
func (m GameModel) View() string {
//TODO: Redo the UI, with proper bubbletea modules, colors, etc.
s := m.PrintBoard()
msg := ""
@ -293,10 +306,11 @@ func (m GameModel) View() string {
func main() {
fmt.Println("==== Gorbito ====")
//TODO: All the stuff; player names, separate client/server model, """AI""" opponent
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}