/// <summary>
 /// Determines whether the the given army can surprise strike another army.
 /// </summary>
 /// <param name="striker">The striking army.</param>
 /// <param name="sustainer">The army being struck.</param>
 /// <returns>True if the surprise strike is valid; false otherwise.</returns>
 private static bool CanSurpriseStrike(Army striker, Army sustainer)
 {
     // To be valid:
     //   1) The striking army must of course contain a submarine, and
     //   2) The sustaining army must not contain a destroyer, which counters surprise strikes.
     return(striker.Contains(UnitType.Submarine) && !sustainer.Contains(UnitType.Destroyer));
 }
Exemple #2
0
 /// <summary>
 /// Ensures that an air unit cannot fire upon a submarine without a destroyer.
 /// </summary>
 /// <param name="firer">The firing unit type.</param>
 /// <param name="sustainer">The unit type being fired upon.</param>
 /// <param name="firingArmy">The army to which the firing unit belongs.</param>
 /// <returns>True if the hit is not an air-to-submarine hit or if a destroyer is present in the firing army; false otherwise.</returns>
 private static bool CheckAir(UnitType firer, UnitType sustainer, Army firingArmy)
 {
     // One of two conditions must be met for this to not be an air-to-submarine hit at all:
     //   1) The firing unit type is not an air unit, or
     //   2) The unit type being fired upon is not a submarine.
     // Finally, even if this is an air-to-submarine hit, it is still valid if the firing army contains a destroyer. Thus, if even
     // one of these three conditions are met, the hit is valid.
     return(firer.Category != UnitCategory.Air || sustainer != UnitType.Submarine || firingArmy.Contains(UnitType.Destroyer));
 }