BT24_030.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Neptunemon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel5
  19. && (targetPermanent.TopCard.HasAquaTraits || targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Reduce Play Cost
  25. if (timing == EffectTiming.None)
  26. {
  27. bool Condition()
  28. {
  29. return card.Owner.Enemy.GetBattleAreaDigimons().Count >= 2;
  30. }
  31. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  32. }
  33. #endregion
  34. #endregion
  35. #region On Play / When Digivolving Shared
  36. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  37. {
  38. var opponentDigimons = card.Owner.Enemy.GetBattleAreaDigimons();
  39. if (opponentDigimons.Any())
  40. {
  41. var lowestSourcesPermanents = card.Owner.Enemy.GetBattleAreaDigimons()
  42. .GroupBy(x => x.DigivolutionCards.Count)
  43. .OrderBy(g => g.Key)
  44. .First()
  45. .ToList();
  46. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeckBouncePeremanentAndProcessAccordingToResult(
  47. targetPermanents: lowestSourcesPermanents,
  48. activateClass: activateClass,
  49. successProcess: null,
  50. failureProcess: null));
  51. }
  52. }
  53. #endregion
  54. #region On Play
  55. if (timing == EffectTiming.OnEnterFieldAnyone)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Bottom deck all opponent digimon with lowest digivolution cards", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  60. cardEffects.Add(activateClass);
  61. string EffectDiscription()
  62. {
  63. return "[On Play] Return all of your opponent's Digimon with the fewest digivolution cards to the bottom of the deck.";
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  68. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  69. }
  70. bool CanActivateCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  73. }
  74. }
  75. #endregion
  76. #region When Digivolving
  77. if (timing == EffectTiming.OnEnterFieldAnyone)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("Bottom deck all opponent digimon with lowest digivolution cards", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[When Digivolving] Return all of your opponent's Digimon with the fewest digivolution cards to the bottom of the deck.";
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  90. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  91. }
  92. bool CanActivateCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  95. }
  96. }
  97. #endregion
  98. #region All Turns - OPT
  99. if (timing == EffectTiming.OnTappedAnyone)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Unsuspend this digimon", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  104. activateClass.SetHashString("BT24_030_AT");
  105. cardEffects.Add(activateClass);
  106. string EffectDiscription()
  107. {
  108. return "[All Turns] [Once Per Turn] When this Digimon suspends, it may unsuspend.";
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  113. && CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable hashtable)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  122. permanents: new List<Permanent>() { card.PermanentOfThisCard() },
  123. cardEffect: activateClass).Unsuspend());
  124. }
  125. }
  126. #endregion
  127. #region All Turns
  128. if (timing == EffectTiming.WhenRemoveField)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("By suspending this digimon, your [TS]/[Aqua]/[Sea Animal] digimon wont leave the field", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[All Turns] When any of your Digimon with the [TS] trait or [Aqua] or [Sea Animal] in any of their traits would leave the battle area by your opponent's effects, by suspending this Digimon, they don't leave.";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  141. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
  142. && CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card));
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  147. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  148. }
  149. bool PermanentCondition(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  152. && (permanent.TopCard.HasTSTraits || permanent.TopCard.HasAquaTraits);
  153. }
  154. IEnumerator ActivateCoroutine(Hashtable hashtable)
  155. {
  156. Permanent thisPermament = card.PermanentOfThisCard();
  157. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { thisPermament }, hashtable).Tap());
  158. if (thisPermament.IsSuspended)
  159. {
  160. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  161. .Filter(PermanentCondition);
  162. foreach (Permanent permanent in protectedPermanents)
  163. {
  164. permanent.willBeRemoveField = false;
  165. permanent.HideHandBounceEffect();
  166. permanent.HideDeckBounceEffect();
  167. permanent.HideDeleteEffect();
  168. permanent.HideWillRemoveFieldEffect();
  169. }
  170. }
  171. }
  172. }
  173. #endregion
  174. return cardEffects;
  175. }
  176. }
  177. }