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 GameFinishedEventArgs(Action restartGame, ReadOnlyBoardContext board) { Board = board; this.restartGame = restartGame; }
public AllShipsSunkEventArgs(int shotsCount, ReadOnlyBoardContext board) { ShotsCount = shotsCount; Board = board; }
public RepeatedShotEventArgs(Shot shot, ReadOnlyBoardContext board) { Shot = shot; Board = board; }
public MissedShotEventArgs(ReadOnlyBoardContext board) { Board = board; }
public AccurateShotEventArgs(string shipName, ReadOnlyBoardContext board) { ShipName = shipName; Board = board; }
public ShipSunkEventArgs(IShip ship, ReadOnlyBoardContext board) { Board = board; ShipName = ship.Name; }