flip board coordinates

This commit is contained in:
stryan 2022-02-20 18:34:38 -05:00
parent 908f53c5a9
commit 32e7fa3278

View File

@ -47,7 +47,7 @@ func (b *Board) GetPiece(x, y int) (*Piece, error) {
if !b.validatePoint(x, y) { if !b.validatePoint(x, y) {
return nil, errors.New("GetPiece invalid location") return nil, errors.New("GetPiece invalid location")
} }
return b.board[x][y].Piece(), nil return b.board[y][x].Piece(), nil
} }
//Place a piece on the board; returns false if a piece is already there //Place a piece on the board; returns false if a piece is already there
@ -55,10 +55,10 @@ func (b *Board) Place(x, y int, p *Piece) (bool, error) {
if !b.validatePoint(x, y) { if !b.validatePoint(x, y) {
return false, errors.New("Place invalid location") return false, errors.New("Place invalid location")
} }
if b.board[x][y].Piece() != nil { if b.board[y][x].Piece() != nil {
return false, nil return false, nil
} }
err := b.board[x][y].Place(p) err := b.board[y][x].Place(p)
if err != nil { if err != nil {
return false, err return false, err
} }
@ -70,13 +70,13 @@ func (b *Board) Remove(x, y int) error {
if !b.validatePoint(x, y) { if !b.validatePoint(x, y) {
return errors.New("Remove invalid location") return errors.New("Remove invalid location")
} }
b.board[x][y].Remove() b.board[y][x].Remove()
return nil return nil
} }
//GetColor returns color of tile //GetColor returns color of tile
func (b *Board) GetColor(x, y int) Colour { func (b *Board) GetColor(x, y int) Colour {
return b.board[x][y].Colour() return b.board[y][x].Colour()
} }
//AddTerrain puts a river tile at specified location //AddTerrain puts a river tile at specified location
@ -84,6 +84,6 @@ func (b *Board) AddTerrain(x, y, t int) (bool, error) {
if !b.validatePoint(x, y) { if !b.validatePoint(x, y) {
return false, errors.New("River invalid location") return false, errors.New("River invalid location")
} }
b.board[x][y].AddTerrain(t) b.board[y][x].AddTerrain(t)
return true, nil return true, nil
} }