mirror of
https://github.com/maaslalani/gambit.git
synced 2024-12-30 21:19:52 +02:00
refactor: remove players
This commit is contained in:
parent
17ed9f5096
commit
82c54e7919
10
board.go
10
board.go
@ -22,7 +22,7 @@ const (
|
||||
)
|
||||
|
||||
type Board struct {
|
||||
Players []Player
|
||||
Pieces []*Piece
|
||||
Grid [dimensions][dimensions]*Piece
|
||||
flipped bool
|
||||
}
|
||||
@ -42,11 +42,9 @@ func (b *Board) Move(from, to position) {
|
||||
}
|
||||
|
||||
func (b *Board) Draw() {
|
||||
for _, player := range b.Players {
|
||||
for _, piece := range player.Pieces {
|
||||
p := piece
|
||||
b.Grid[piece.Position[0]-1][piece.Position[1]-1] = p
|
||||
}
|
||||
for _, piece := range b.Pieces {
|
||||
p := piece
|
||||
b.Grid[piece.Position[0]-1][piece.Position[1]-1] = p
|
||||
}
|
||||
}
|
||||
|
||||
|
6
main.go
6
main.go
@ -9,10 +9,8 @@ import (
|
||||
|
||||
func main() {
|
||||
m := model{}
|
||||
m.Board.Players = []Player{
|
||||
{Pieces: BlackPieces()},
|
||||
{Pieces: WhitePieces()},
|
||||
}
|
||||
m.Board.Pieces = append(m.Board.Pieces, WhitePieces()...)
|
||||
m.Board.Pieces = append(m.Board.Pieces, BlackPieces()...)
|
||||
p := tea.NewProgram(m, tea.WithMouseAllMotion())
|
||||
if err := p.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user