private void CheckShot(int rowIndex, int columnIndex) { var ship = GetShipByGridPoint(rowIndex, columnIndex); if (ship.IsDead) { ShipSunk?.Invoke(this, ship); } else { ShipHit?.Invoke(this, ship); } }
private void HandleAccurateShot(Shot shot, IShip shotShip) { SetField(boardStateFields, shot.Position, new ShootShipField(shot.Position, shotShip)); SetField(playerFields, shot.Position, new ShootShipField(shot.Position, shotShip)); var boardContext = new ReadOnlyBoardContext(this); if (shotShip.IsSunk) { ShipSunk?.Invoke(this, new ShipSunkEventArgs(shotShip, boardContext)); if (Ships.All(s => s.IsSunk)) { AllShipsSunk?.Invoke(this, new AllShipsSunkEventArgs(shotHistory.Count, boardContext)); } } else { AccurateShot?.Invoke(this, new AccurateShotEventArgs(shotShip.Name, boardContext)); } }
public Task Handle(ShipSunk message) { _gameDisplay.DisplayShipSunk(message.ShipName); return(Task.CompletedTask); }