EX6_066.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_066 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[Main] By placing 1 Digimon card with [Aqua]/[Sea Animal] in one of its traits from your hand as the bottom digivolution card of 1 of your blue Digimon, return all of your opponent's Digimon with the same level as the placed card to the hand.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (cardSource.IsDigimon)
  27. {
  28. if (cardSource.HasAquaTraits)
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanSelectPermanentCondition(Permanent permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  40. {
  41. if (!permanent.IsToken)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. // If there is a Digimon card with Aqua traits in hand and blue Digimon on owner's field
  56. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. CardSource selectedCard = null;
  61. int maxCount = 1;
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectCardCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage(
  77. "Select 1 card to place at the bottom of digivolution cards.",
  78. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  79. yield return StartCoroutine(selectHandEffect.Activate());
  80. IEnumerator SelectCardCoroutine(CardSource cardSource)
  81. {
  82. selectedCard = cardSource;
  83. yield return null;
  84. }
  85. if (selectedCard != null)
  86. {
  87. maxCount = Math.Min(1,
  88. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  89. SelectPermanentEffect selectPermanentEffect =
  90. GManager.instance.GetComponent<SelectPermanentEffect>();
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CanSelectPermanentCondition,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: true,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: SelectPermanentCoroutine,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectPermanentEffect.SetUpCustomMessage(
  104. "Select 1 Digimon that will get a bottom digivolution card.",
  105. "The opponent is selecting 1 Digimon that will get a bottom digivolution card.");
  106. yield return ContinuousController.instance.StartCoroutine(
  107. selectPermanentEffect.Activate());
  108. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  109. {
  110. Permanent selectedPermanent = permanent;
  111. if (selectedPermanent != null)
  112. {
  113. // Add chosen card to Digimon's sources
  114. yield return ContinuousController.instance.StartCoroutine(
  115. selectedPermanent.AddDigivolutionCardsBottom(
  116. new List<CardSource>() { selectedCard }, activateClass));
  117. bool PermanentConditionEnemy(Permanent enemyPermanent)
  118. {
  119. return enemyPermanent.Level == selectedCard.Level;
  120. }
  121. // Return all opponent's Digimon with the same level as the chosen card to their hand
  122. List<Permanent> bounceTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons()
  123. .Filter(PermanentConditionEnemy);
  124. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(bounceTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. #endregion
  133. #region Security Effect
  134. if (timing == EffectTiming.SecuritySkill)
  135. {
  136. ActivateClass activateClass = new ActivateClass();
  137. activateClass.SetUpICardEffect($"Return all of your opponent's Digimon with the lowest level to the hand.", CanUseCondition, card);
  138. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  139. activateClass.SetIsSecurityEffect(true);
  140. cardEffects.Add(activateClass);
  141. string EffectDescription()
  142. {
  143. return "[Security] Return all of your opponent's Digimon with the lowest level to the hand.";
  144. }
  145. bool PermanentCondition(Permanent permanent)
  146. {
  147. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. List<Permanent> bounceTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  156. yield return ContinuousController.instance.StartCoroutine(new HandBounceClaass(bounceTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  157. }
  158. }
  159. #endregion
  160. return cardEffects;
  161. }
  162. }
  163. }