static IEnumerator <List <int> > GetTargetEnumerator(NetSkill ns, NetCard nc, IList <int> potentialTargets, CardAI ai) { if (potentialTargets.Count < 1) { return(null); } Subskill ss = ns.GetSubSkill(); int count = 0; if (ss.trigger.triggerGroup == ETriggerGroupType.DoAttack || ss.trigger.triggerGroup == ETriggerGroupType.DoAlternateAttack) { count = 1; } else { if (potentialTargets.Count < ss.targets.targetCountRange.minimumCount) { return(null); } if (potentialTargets.Count <= ss.targets.targetCountRange.maximumCount) { count = potentialTargets.Count; } else { count = ss.targets.targetCountRange.maximumCount; } } List <int> pt = new List <int>(potentialTargets); pt.Sort(delegate(int a, int b) { if (ai.preferredStrategicPlaces != null) { bool stratA = ai.preferredStrategicPlaces.Contains(a); bool stratB = ai.preferredStrategicPlaces.Contains(b); if (stratA != stratB) { return(stratA ? -1 : 1); } //if they are the same use regular random } return(ai.r.GetInt(0, 2) - 1); }); var lu = new ListUtils(pt, count); return(lu.GetEnumerator()); }