public void Attack(BattleFleet defender) { for (int j = 0; j < 10; j++) { Shuffle(); defender.Shuffle(); for (int i = 0; i < Math.Max(Count, defender.Count); i++) { if (i < Count) { Ship shipA = this[i]; shipA.Reload(); Ship shipB = shipA.Attack(defender); if (shipA.HullStrength == 0) { Remove(shipA); WriteDestroyed(shipA); } if (shipB?.HullStrength == 0) { defender.Remove(shipB); WriteDestroyed(shipB); } } if (i < defender.Count) { Ship shipB = defender[i]; shipB.Reload(); Ship shipA = shipB.Attack(this); if (shipB.HullStrength == 0) { Remove(shipB); WriteDestroyed(shipB); } if (shipA?.HullStrength == 0) { defender.Remove(shipA); WriteDestroyed(shipA); } } } } }