예제 #1
0
        public CellState Attack(BoardCellLocation location)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }
            ValidateCurrentGameStatus(GameStatus.InProgress, GameStatus.NotStarted);
            var boardCell = Board.GetCells().Where(x => x.Location == location).FirstOrDefault()
                            ?? throw new CellNotFoundException(location);

            var targetState = GetAttachTargetState(boardCell.State)
                              ?? throw new IllegitimateTransitionException(boardCell, CellState.Hit);

            TransitionCellState(boardCell, targetState);
            return(targetState);
        }
예제 #2
0
 public CellsNotVacantException(BoardCellLocation location)
     : base(nameof(CellsNotVacantException))
 {
     Location = location;
 }
예제 #3
0
 public CellNotFoundException(BoardCellLocation location)
     : base(nameof(CellNotFoundException))
 {
     Location = location;
 }