EX4_022.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_022 : 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("Return 1 level 4 or lower Digimon and 1 level 6 or higher Digimon to hand", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Digivolving] Return 1 of your opponent's level 4 or lower Digimon to the hand. Then, if they have 8 or more cards in their hand, return 1 of their level 6 or higher Digimon to the hand.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.Level <= 4)
  26. {
  27. if (permanent.TopCard.HasLevel)
  28. {
  29. return true;
  30. }
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanSelectPermanentCondition1(Permanent permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.Level >= 6)
  40. {
  41. if (permanent.TopCard.HasLevel)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. return true;
  60. }
  61. if (card.Owner.Enemy.HandCards.Count >= 8)
  62. {
  63. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  74. {
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: null,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Bounce,
  88. cardEffect: activateClass);
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. }
  91. if (card.Owner.Enemy.HandCards.Count >= 8)
  92. {
  93. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  94. {
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectPermanentCondition1,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: null,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Bounce,
  108. cardEffect: activateClass);
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. }
  111. }
  112. }
  113. }
  114. if (timing == EffectTiming.OnAddHand)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect("Return 1 level 3 Digimon to hand", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  119. activateClass.SetHashString("Bounce_EX4_022");
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[All Turns][Once Per Turn] When an effect adds cards to your opponent's hand, if you have a Tamer, return 1 of your opponent's level 3 Digimon to the hand.";
  124. }
  125. bool CanSelectPermanentCondition(Permanent permanent)
  126. {
  127. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  128. {
  129. if (permanent.Level == 3)
  130. {
  131. if (permanent.TopCard.HasLevel)
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. return false;
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (CardEffectCommons.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  162. {
  163. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  164. {
  165. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectPermanentCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: false,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: null,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Bounce,
  178. cardEffect: activateClass);
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. }
  181. }
  182. }
  183. return cardEffects;
  184. }
  185. }
  186. }