From 32e7fa32781205a6d242a727f8e3f82f9fafd631 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 20 Feb 2022 18:34:38 -0500 Subject: [PATCH] flip board coordinates --- board.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/board.go b/board.go index 7d47ca5..3ff5aa8 100644 --- a/board.go +++ b/board.go @@ -47,7 +47,7 @@ func (b *Board) GetPiece(x, y int) (*Piece, error) { if !b.validatePoint(x, y) { 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 @@ -55,10 +55,10 @@ func (b *Board) Place(x, y int, p *Piece) (bool, error) { if !b.validatePoint(x, y) { return false, errors.New("Place invalid location") } - if b.board[x][y].Piece() != nil { + if b.board[y][x].Piece() != nil { return false, nil } - err := b.board[x][y].Place(p) + err := b.board[y][x].Place(p) if err != nil { return false, err } @@ -70,13 +70,13 @@ func (b *Board) Remove(x, y int) error { if !b.validatePoint(x, y) { return errors.New("Remove invalid location") } - b.board[x][y].Remove() + b.board[y][x].Remove() return nil } //GetColor returns color of tile 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 @@ -84,6 +84,6 @@ func (b *Board) AddTerrain(x, y, t int) (bool, error) { if !b.validatePoint(x, y) { return false, errors.New("River invalid location") } - b.board[x][y].AddTerrain(t) + b.board[y][x].AddTerrain(t) return true, nil }