Exemple #1
0
        public void GivenABoardWithAnOpponentCell_WhenPuttingAnOpponentCellInTheSameCell_NotAllowedMovementExceptionIsThrown()
        {
            var board = new Board();
            var cellCoordinates = new CellCoordinates(0,0);
            board.FillCell(cellCoordinates, OPPONENTS_MARK);

            board.FillCell(cellCoordinates, OPPONENTS_MARK);
        }
Exemple #2
0
 public void WhenPuttingAnOpponentCellOutsideTheBoard_NotAllowedMovementExceptionIsThrown()
 {
     var board = new Board();
     var cellCoordinates = new CellCoordinates(4, 4);
     board.FillCell(cellCoordinates, OPPONENTS_MARK);
 }
Exemple #3
0
 public Mark(char cell, CellCoordinates cellCoordinate)
 {
     Cell = cell;
     CellCoordinate = cellCoordinate;
 }
Exemple #4
0
 private bool AreCoordinatesOutsideTheBoard(CellCoordinates cellCoordinate)
 {
     return (cellCoordinate.Row >= SIZE || cellCoordinate.Column >= SIZE);
 }
Exemple #5
0
 private bool IsCellNotEmpty(CellCoordinates cellCoordinate)
 {
     return !IsCellEmpty(cellCoordinate);
 }
Exemple #6
0
 public bool IsCenterEmpty()
 {
     var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN);
     return IsCellOfType(' ', centerCoordinate);
 }
Exemple #7
0
 public bool IsCellOfType(char mark, CellCoordinates cellCoordinate)
 {
     return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == mark;
 }
Exemple #8
0
 public bool IsCellEmpty(CellCoordinates cellCoordinate)
 {
     return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == EMPTY_CELL;
 }
Exemple #9
0
 public void FillCenterWithCell(char mark)
 {
     var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN);
     FillCell(centerCoordinate, mark);
 }
Exemple #10
0
        public virtual void FillCell(CellCoordinates cellCoordinate, char mark)
        {
            if (State != TicTacToeBoardState.Playing ||
                AreCoordinatesOutsideTheBoard(cellCoordinate) || IsCellNotEmpty(cellCoordinate))
                throw new NotAllowedMovementException();

            Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] = mark;
            CheckForWinner();
        }