WhenLinked.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 CanTriggerWhenLinking(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. #region Can trigger "When a card gets linked" effect
  40. public static bool CanTriggerWhenLinked(Hashtable hashtable, Func<Permanent, bool> permanentCondition, Func<CardSource, bool> sourcecCondition)
  41. {
  42. if (hashtable != null)
  43. {
  44. Permanent Permanent = GetPermanentFromHashtable(hashtable);
  45. if (Permanent != null)
  46. {
  47. if (Permanent.TopCard != null)
  48. {
  49. if (permanentCondition == null || permanentCondition(Permanent))
  50. {
  51. ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
  52. if (CardEffect != null)
  53. {
  54. CardSource cardSource = GetCardFromHashtable(hashtable);
  55. if (cardSource != null)
  56. {
  57. if (sourcecCondition == null || sourcecCondition(cardSource))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. #endregion
  70. }