private void AttackFleet(Ship ship, Fleet fleet) { for (int i = 0; i < ship.RedDice; i++) { if (fleet.DetermineDamage(4, DiceRoll(), ship.Computers)) { if (fleet.Destroyed()) { return; } } } for (int i = 0; i < ship.OrangeDice; i++) { if (fleet.DetermineDamage(2, DiceRoll(), ship.Computers)) { if (fleet.Destroyed()) { return; } } } for (int i = 0; i < ship.YellowDice; i++) { if (fleet.DetermineDamage(1, DiceRoll(), ship.Computers)) { if (fleet.Destroyed()) { return; } } } }
public bool Combat(Fleet attackers, Fleet defenders) { while (!attackers.Destroyed() && !defenders.Destroyed()) { if (attackers.GetCurrentInitiative() > defenders.GetCurrentInitiative()) { Ship ship = attackers.GetAttacker(); AttackFleet(ship, defenders); } else { Ship ship = defenders.GetAttacker(); AttackFleet(ship, attackers); } if (defenders.Done() && attackers.Done()) { defenders.ResetTurn(); attackers.ResetTurn(); } } if (defenders.Destroyed()) { return(true); } else { return(false); } }