PermanentEnterField.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can trigger one of [On Play] effect or [When Digivolving] effect
  9. static bool CanTriggerOnEnterField(Hashtable hashtable, CardSource card, bool isEvolution, Func<SelectCardEffect.Root, bool> rootCondition = null)
  10. {
  11. return CanTriggerOnPermanentEnterField(hashtable, (permanent) => permanent.cardSources.Contains(card), isEvolution, rootCondition);
  12. }
  13. #endregion
  14. #region Can trigger "When permanent is played or digivolves" effect
  15. static bool CanTriggerOnPermanentEnterField(
  16. Hashtable hashtable,
  17. Func<Permanent, bool> permanentCondition,
  18. bool isEvolution,
  19. Func<SelectCardEffect.Root, bool> rootCondition = null)
  20. {
  21. bool IsEvolution = CardEffectCommons.IsEvolution(hashtable);
  22. if (IsEvolution == isEvolution)
  23. {
  24. List<Hashtable> hashtables = GetHashtablesFromHashtable(hashtable);
  25. if (hashtables != null)
  26. {
  27. foreach (Hashtable hashtable1 in hashtables)
  28. {
  29. Permanent permanent = GetPermanentFromHashtable(hashtable1);
  30. if (permanent != null)
  31. {
  32. if (permanentCondition != null)
  33. {
  34. if (permanentCondition(permanent))
  35. {
  36. SelectCardEffect.Root root = GetRootFromHashtable(hashtable1);
  37. if (rootCondition == null || rootCondition(root) || root == SelectCardEffect.Root.None)
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. #endregion
  50. }