Exemple #1
0
        public Cell GetNeighborCell(Cell currentCell, CellNeighbor neighbor)
        {
            Cell nCell = null;
            if (currentCell == null) return null;
            try
            {
                switch (neighbor)
                {
                    case CellNeighbor.Backward:
                        nCell = _board[GetBoardNumber(currentCell.GetName())][GetCellRow(currentCell.GetName()), GetCellCol(currentCell.GetName()) - 1];
                        break;
                    case CellNeighbor.Forward:
                        nCell = _board[GetBoardNumber(currentCell.GetName())][GetCellRow(currentCell.GetName()), GetCellCol(currentCell.GetName()) + 1];
                        break;
                    case CellNeighbor.Up:
                        nCell = _board[GetBoardNumber(currentCell.GetName()) - 1][GetCellRow(currentCell.GetName()), GetCellCol(currentCell.GetName())];
                        break;
                    case CellNeighbor.Down:
                        nCell = _board[GetBoardNumber(currentCell.GetName()) + 1][GetCellRow(currentCell.GetName()), GetCellCol(currentCell.GetName())];
                        break;
                    case CellNeighbor.Left:
                        nCell = _board[GetBoardNumber(currentCell.GetName())][GetCellRow(currentCell.GetName()) - 1, GetCellCol(currentCell.GetName())];
                        break;
                    case CellNeighbor.Right:
                        nCell = _board[GetBoardNumber(currentCell.GetName())][GetCellRow(currentCell.GetName()) + 1, GetCellCol(currentCell.GetName())];
                        break;
                }
            }
            catch (Exception)
            {

                return null;
            }

            return nCell;
        }
Exemple #2
0
 public void TestNewBoard()
 {
     var cell = new Cell("Aa1");
     cell.AddPiece(new Pawn(true, cell.GetName()));
     var boardCell = target._board[0][0, 0];
     Assert.IsTrue(cell.GetPiece().Equals( boardCell.GetPiece()));
 }