Post by Legend on Sept 5, 2018 19:01:38 GMT
Hello
i need some help - the secret system i created added created a subclass for the systems that have triggeredabilities
it gets messed up when i call the refreshtriggers method
and each system has its seperetate triggerstocheck
in the triggeredabilityloader i have the functions that get called like
it works with 1 system only but not the second one --- does it have something to do with not protecting the classes or because i made them public or something that the cardswithabilities could be running into each other or something?
any help would be greatlyyy appreciated - thank you!
i need some help - the secret system i created added created a subclass for the systems that have triggeredabilities
it gets messed up when i call the refreshtriggers method
public class AttackSystem : TriggeredAbilityLoader, IObserve {
and each system has its seperetate triggerstocheck
List<Trigger> triggersToCheck = new List<Trigger>
{
Trigger.OnThisCreatureAttacked
};
in the triggeredabilityloader i have the functions that get called like
protected List<Card> cardswithabilities;
protected void ApplyTrigger(TriggeredAbility tability)
{
container.AddReaction(new TriggeredAbilityAction(tability));
}
protected void RefreshTriggers(List<Trigger> triggersToCheck)
{
cardswithabilities = new List<Card>();
cardswithabilities = checkforTriggers(triggersToCheck);
}
public List<Card> checkforTriggers(List<Trigger> triggersToCheck)
{
List<Card> list = GetActiveAbilityTriggers();
OnFilterTriggerAbilities(list, triggersToCheck);
return list;
}
public List<Card> GetActiveAbilityTriggers()
{
List<Card> list = new List<Card>();
foreach (var player in container.GetMatch().players)
{
list.Add(player[Zones.Hero]);
}
return list;
}
public void OnFilterTriggerAbilities(List<Card> candidates, List<Trigger> triggersToCheck)
{
if (TargetContainsTriggeredAbility(candidates) == false)
return;
for (int i = candidates.Count - 1; i >= 0; --i)
{
if (candidates[i].GetAspect<TriggeredAbilities>() != null)
{
Trigger trigger;
var candidatelist = candidates[i].GetAspect<TriggeredAbilities>().triggeredAbilities;
candidatelist.RemoveAll(a => !triggersToCheck.Exists(b => Enum.TryParse(Convert.ToString(a.trigger), out trigger) && trigger == b));
}
else
candidates.RemoveAt(i);
}
}
public bool TargetContainsTriggeredAbility(List<Card> cards)
{
foreach (Card card in cards)
{
if (card.GetAspect<TriggeredAbilities>() != null)
return true;
}
return false;
}
it works with 1 system only but not the second one --- does it have something to do with not protecting the classes or because i made them public or something that the cardswithabilities could be running into each other or something?
any help would be greatlyyy appreciated - thank you!