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; }
public CellNotFoundException(BoardCellLocation location) : base(nameof(CellNotFoundException)) { Location = location; }