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); }
public void WhenPuttingAnOpponentCellOutsideTheBoard_NotAllowedMovementExceptionIsThrown() { var board = new Board(); var cellCoordinates = new CellCoordinates(4, 4); board.FillCell(cellCoordinates, OPPONENTS_MARK); }
public Mark(char cell, CellCoordinates cellCoordinate) { Cell = cell; CellCoordinate = cellCoordinate; }
private bool AreCoordinatesOutsideTheBoard(CellCoordinates cellCoordinate) { return (cellCoordinate.Row >= SIZE || cellCoordinate.Column >= SIZE); }
private bool IsCellNotEmpty(CellCoordinates cellCoordinate) { return !IsCellEmpty(cellCoordinate); }
public bool IsCenterEmpty() { var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN); return IsCellOfType(' ', centerCoordinate); }
public bool IsCellOfType(char mark, CellCoordinates cellCoordinate) { return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == mark; }
public bool IsCellEmpty(CellCoordinates cellCoordinate) { return Cells[cellCoordinate.Row * SIZE + cellCoordinate.Column] == EMPTY_CELL; }
public void FillCenterWithCell(char mark) { var centerCoordinate = new CellCoordinates(CENTER_ROW, CENTER_COLUMN); FillCell(centerCoordinate, mark); }
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(); }