예제 #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);
        }
예제 #2
0
 public void WhenPuttingAnOpponentCellOutsideTheBoard_NotAllowedMovementExceptionIsThrown()
 {
     var board = new Board();
     var cellCoordinates = new CellCoordinates(4, 4);
     board.FillCell(cellCoordinates, OPPONENTS_MARK);
 }
예제 #3
0
파일: Mark.cs 프로젝트: vgaltes/TicTacToe
 public Mark(char cell, CellCoordinates cellCoordinate)
 {
     Cell = cell;
     CellCoordinate = cellCoordinate;
 }
예제 #4
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 private bool AreCoordinatesOutsideTheBoard(CellCoordinates cellCoordinate)
 {
     return (cellCoordinate.Row >= SIZE || cellCoordinate.Column >= SIZE);
 }
예제 #5
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 private bool IsCellNotEmpty(CellCoordinates cellCoordinate)
 {
     return !IsCellEmpty(cellCoordinate);
 }
예제 #6
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 public bool IsCenterEmpty()
 {
     var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN);
     return IsCellOfType(' ', centerCoordinate);
 }
예제 #7
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 public bool IsCellOfType(char mark, CellCoordinates cellCoordinate)
 {
     return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == mark;
 }
예제 #8
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 public bool IsCellEmpty(CellCoordinates cellCoordinate)
 {
     return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == EMPTY_CELL;
 }
예제 #9
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
 public void FillCenterWithCell(char mark)
 {
     var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN);
     FillCell(centerCoordinate, mark);
 }
예제 #10
0
파일: Board.cs 프로젝트: vgaltes/TicTacToe
        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();
        }