示例#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);
        }
 public CellsNotVacantException(BoardCellLocation location)
     : base(nameof(CellsNotVacantException))
 {
     Location = location;
 }
示例#3
0
 public CellNotFoundException(BoardCellLocation location)
     : base(nameof(CellNotFoundException))
 {
     Location = location;
 }