EX2_029.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_029 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Suspend Digimon and it can't unsuspend", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] For each green Tamer you have in play, suspend 1 of your opponent's Digimon. They don't unsuspend during your opponent's next unsuspend phase.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  35. {
  36. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  49. {
  50. int maxCount = Math.Min(card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: null,
  61. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  62. mode: SelectPermanentEffect.Mode.Tap,
  63. cardEffect: activateClass);
  64. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  65. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  66. {
  67. foreach (Permanent selectedPermanent in permanents)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendNextActivePhase(
  70. targetPermanent: selectedPermanent,
  71. activateClass: activateClass
  72. ));
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. if (timing == EffectTiming.OnAllyAttack)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Return 1 suspended Digimon to hand", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  84. activateClass.SetHashString("Bounce_EX2_029");
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[When Attacking][Once Per Turn] Return 1 of your opponent's suspended Digimon with DP less than or equal to this Digimon's DP to its owner's hand.";
  89. }
  90. bool CanSelectPermanentCondition(Permanent permanent)
  91. {
  92. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  93. {
  94. if (permanent.IsSuspended)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (permanent.DP <= card.PermanentOfThisCard().DP)
  99. {
  100. return true;
  101. }
  102. }
  103. }
  104. }
  105. return false;
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. if (CardEffectCommons.IsExistOnBattleArea(card))
  114. {
  115. return true;
  116. }
  117. return false;
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  120. {
  121. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  122. {
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectPermanentCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: false,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: null,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Bounce,
  136. cardEffect: activateClass);
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. }
  139. }
  140. }
  141. return cardEffects;
  142. }
  143. }
  144. }