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