WhenWouldLink.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 "When permanent would be played" effects of 1 permanent
  9. public static bool CanTriggerWhenWouldLink(Hashtable hashtable, Func<CardSource, bool> cardCondition, Func<Permanent, bool> permanentCondition, Func<SelectCardEffect.Root, bool> rootCondition = null, Func<ICardEffect, bool> cardEffectCondition = null)
  10. {
  11. CardSource cardSource = GetCardFromHashtable(hashtable);
  12. if (cardSource != null)
  13. {
  14. if (cardCondition == null || cardCondition(cardSource))
  15. {
  16. Permanent permanent = GetPermanentFromHashtable(hashtable);
  17. if (permanentCondition == null || permanentCondition(permanent))
  18. {
  19. SelectCardEffect.Root root = GetRootFromHashtable(hashtable);
  20. if (rootCondition == null || rootCondition(root))
  21. {
  22. ICardEffect cardEffect = GetCardEffectFromHashtable(hashtable);
  23. if (cardEffectCondition == null || cardEffectCondition(cardEffect))
  24. {
  25. return true;
  26. }
  27. }
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. #endregion
  34. }