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(AllShipsSunk message) { _gameDisplay.DisplayWon(); return(Task.CompletedTask); }