public override bool Tick() { var pool = Units.ToList(); var targets = Units.OrderBy(SelectionOrder).With(group => ChooseTarget(group, pool)).ToArray(Units.Count); if (targets.WhereValue(group => group != null).All(pair => pair.Value.ComputeLoss(pair.Key.EffectivePower, pair.Key.DamageType) == 0)) { return(false); } targets.OrderByDescending(pair => pair.Key, Initiative) .ForEach(Attack); Units.RemoveAll(group => !group.Alive); return(!Units.AllEqual(group => group.Friendly)); }