static void printBattleReport(Fleet fleet1, Fleet fleet2, int round) { if (fleet1.fleetDestroyed() && fleet2.fleetDestroyed()) { Console.WriteLine("\nAfter round " + round + " the battle has been a draw with both sides destroyed"); } else if (fleet1.fleetDestroyed()) { Console.WriteLine("\nAfter round " + round + " the " + fleet2.FleetName + " fleet won"); Console.WriteLine(" " + fleet1.ShipsDestroyed + " enemy ships destroyed"); fleet2.printDamageReport(); } else if (fleet2.fleetDestroyed()) { Console.WriteLine("\nAfter round " + round + " the " + fleet1.FleetName + " fleet won"); Console.WriteLine(" " + fleet2.ShipsDestroyed + " enemy ships destroyed"); fleet1.printDamageReport(); } else { Console.WriteLine("\nERROR BUG - battle ended but neither fleet is destroyed"); } }
static void runBattle(Fleet fleet1, Fleet fleet2, ref int round) { while (!fleet1.fleetDestroyed() && !fleet2.fleetDestroyed()) { round++; // run fleet battles fleet1.attackFleet(fleet2); fleet2.attackFleet(fleet1); // finalise battle round fleet1.finaliseBattleRound(round); fleet2.finaliseBattleRound(round); } }