OnTrashLinkedCard.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 this linked card is trashed" effect
  9. public static bool CanTriggerOnTrashSelfLinkedCard(Hashtable hashtable, Func<ICardEffect, bool> cardEffectCondition, CardSource card)
  10. {
  11. bool PermanentCondition(Permanent permanent)
  12. {
  13. if (IsPermanentExistsOnBattleArea(permanent))
  14. {
  15. if (permanent.LinkedCards.Contains(card))
  16. {
  17. return true;
  18. }
  19. }
  20. return false;
  21. }
  22. bool CardCondition(CardSource cardSource)
  23. {
  24. return cardSource == card;
  25. }
  26. return CanTriggerOnTrashLinkedCard(hashtable, PermanentCondition, cardEffectCondition, CardCondition);
  27. }
  28. #endregion
  29. #region Can trigger "When this linked card is trashed due to effect" effect
  30. public static bool CanTriggerOnTrashLinkedCard(Hashtable hashtable, Func<Permanent, bool> permanentCondition, Func<ICardEffect, bool> cardEffectCondition, Func<CardSource, bool> cardCondition)
  31. {
  32. Permanent permanent = GetPermanentFromHashtable(hashtable);
  33. if (permanent != null)
  34. {
  35. if (permanent.TopCard != null)
  36. {
  37. if (permanentCondition == null || permanentCondition(permanent))
  38. {
  39. ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
  40. if (CardEffect != null)
  41. {
  42. if (cardEffectCondition == null || cardEffectCondition(CardEffect))
  43. {
  44. List<CardSource> DiscardedCards = GetDiscardedCardsFromHashtable(hashtable);
  45. if (DiscardedCards != null)
  46. {
  47. if (DiscardedCards.Count(cardSource => cardCondition == null || cardCondition(cardSource)) >= 1)
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. #endregion
  60. }