WhenLinked.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 card is linked" effect
  9. public static bool CanTriggerWhenLinked(Hashtable hashtable, Func<Permanent, bool> permanentCondition, CardSource card)
  10. {
  11. if (hashtable != null)
  12. {
  13. Permanent Permanent = GetPermanentFromHashtable(hashtable);
  14. if (Permanent != null)
  15. {
  16. if (Permanent.TopCard != null)
  17. {
  18. if (permanentCondition == null || permanentCondition(Permanent))
  19. {
  20. ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
  21. if (CardEffect != null)
  22. {
  23. CardSource cardSource = GetCardFromHashtable(hashtable);
  24. if (cardSource != null)
  25. {
  26. if (cardSource == card)
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. #endregion
  39. }