public static IEnumerable <HitResult> Hit(Army army, UnitType firer, Army firingArmy, decimal amt, bool attacker, IHitSelector selector) { // If the army is empty, no hits are necessary. Return such. if (army.Empty) { return(NoHits()); } var type = selector.Select(army, firer, firingArmy, amt, !attacker); // Check if the hitType is null. If so, no valid hits are possible. Thus, return an ineffective hit result for the appropriate amount. if (type == null) { return(OneHit(HitResult.NewIneffective(amt))); } // Take the appropriate number of casualties from the army and capture the result. var result = army.Hit(type, amt); // Check if the resulting hit completed the required amount. if (result.Amount == amt) { // If so, simply return that hit result. return(OneHit(result)); } else { // If not, then further hits need to be made. Recursively take away the remaining number of causualties, adding the results // to the current one. return(Hit(army, firer, firingArmy, amt - result.Amount, attacker, selector).Prepend(result)); } }