WhenPermanentWouldDigivolve.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 would digivolve" effects of 1 permanent
  9. public static bool CanTriggerWhenPermanentWouldDigivolveOfCard(Hashtable hashtable, Func<CardSource, bool> cardCondition, CardSource card)
  10. {
  11. bool PermanentCondition(Permanent permanent)
  12. {
  13. return permanent == card.PermanentOfThisCard();
  14. }
  15. return CanTriggerWhenPermanentWouldDigivolve(hashtable: hashtable, permanentCondition: PermanentCondition, cardCondition: cardCondition);
  16. }
  17. #endregion
  18. #region Can trigger when "1 Digimon would digivolve into 1 card" effect
  19. public static bool CanTriggerWhenPermanentWouldDigivolve(Hashtable hashtable, Func<Permanent, bool> permanentCondition,
  20. Func<CardSource, bool> cardCondition)
  21. {
  22. bool IsEvolution = CardEffectCommons.IsEvolution(hashtable);
  23. if (IsEvolution)
  24. {
  25. CardSource Card = GetCardFromHashtable(hashtable);
  26. if (Card != null)
  27. {
  28. if (cardCondition == null || cardCondition(Card))
  29. {
  30. List<Permanent> permanents = GetPermanentsFromHashtable(hashtable);
  31. if (permanents != null)
  32. {
  33. if (permanents
  34. .Filter(permanent => permanent != null && permanent.TopCard != null)
  35. .Some(permanent => permanentCondition == null || permanentCondition(permanent)))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. #endregion
  46. }