BT14_029.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_029 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Trash 3 digivolution cards from enemy digimon", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  16. cardEffects.Add(activateClass);
  17. string EffectDescription()
  18. {
  19. return "[When Digivolving] Trash any 3 digivolution cards from your opponent's Digimon.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  39. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  50. permanentCondition: CanSelectPermanentCondition,
  51. cardCondition: CanSelectCardCondition,
  52. maxCount: 3,
  53. canNoTrash: false,
  54. isFromOnly1Permanent: false,
  55. activateClass: activateClass
  56. ));
  57. }
  58. }
  59. }
  60. if (timing == EffectTiming.OnAllyAttack)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  65. activateClass.SetIsSkippableFunction(IsSkippable);
  66. activateClass.SetHashString("Unsuspend_BT14_029");
  67. cardEffects.Add(activateClass);
  68. string EffectDescription()
  69. {
  70. return "[When Attacking] [Once Per Turn] If your opponent has no Digimon with as many or more digivolution cards than this Digimon, unsuspend this Digimon.";
  71. }
  72. bool IsSkippable(Hashtable hashtable)
  73. {
  74. int digivolutionCardCount = card.PermanentOfThisCard().DigivolutionCards.Count;
  75. bool HasMoreDigivolutionCardsCondition(Permanent permanent)
  76. {
  77. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  78. && permanent.DigivolutionCards.Count > digivolutionCardCount;
  79. }
  80. return CardEffectCommons.HasMatchConditionPermanent(HasMoreDigivolutionCardsCondition);
  81. }
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  85. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable hashtable)
  92. {
  93. if (!IsSkippable(hashtable))
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  96. }
  97. else activateClass.RemoveUse();
  98. }
  99. }
  100. return cardEffects;
  101. }
  102. }
  103. }