BT24_091.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Tidal Stream
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_091 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Ignore Color Requirement
  15. if (timing == EffectTiming.None)
  16. {
  17. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  18. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  19. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  20. cardEffects.Add(ignoreColorConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. => CardEffectCommons.HasMatchConditionPermanent((permanent) => permanent.TopCard.Owner == card.Owner && (permanent.IsTamer || permanent.IsDigimon) && permanent.TopCard.HasTSTraits, true);
  23. bool CardCondition(CardSource cardSource)
  24. => cardSource == card;
  25. }
  26. #endregion
  27. #region Link Condition
  28. if (timing == EffectTiming.None)
  29. {
  30. static bool PermanentCondition(Permanent targetPermanent)
  31. {
  32. return targetPermanent.IsDigimon && targetPermanent.TopCard.HasTSTraits;
  33. }
  34. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  35. }
  36. #endregion
  37. #region Link
  38. if (timing == EffectTiming.OnDeclaration)
  39. {
  40. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  41. }
  42. #endregion
  43. #endregion
  44. #region Security Effect
  45. if (timing == EffectTiming.SecuritySkill)
  46. {
  47. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  48. card: card,
  49. cardEffects: ref cardEffects,
  50. effectName: "Bounce all opponent's lowest level. Unsuspend a Digimon. Then, you may link this card.");
  51. }
  52. #endregion
  53. #region Main
  54. if (timing == EffectTiming.OptionSkill)
  55. {
  56. ActivateClass activateClass = new ActivateClass();
  57. activateClass.SetUpICardEffect("Bounce all opponent's lowest level. Unsuspend a Digimon. Then, you may link this card.", CanUseCondition, card);
  58. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  59. cardEffects.Add(activateClass);
  60. string EffectDescription()
  61. => "[Main] Return all of your opponent's lowest level Digimon to the hand. If this effect returned, 1 of your [TS] trait Digimon unsuspends. Then, you may link this card to 1 of your Digimon on the field without paying the cost.";
  62. bool CanUseCondition(Hashtable hashtable)
  63. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  64. bool CanSelectPermanentCondition(Permanent permanent)
  65. {
  66. return permanent.IsDigimon
  67. && CardEffectCommons.IsOwnerPermanent(permanent, card)
  68. && card.CanLinkToTargetPermanent(permanent, false, true);
  69. }
  70. bool CanSelectTargetCondition(Permanent permanent)
  71. {
  72. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  73. {
  74. if (permanent.TopCard.HasLevel)
  75. {
  76. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  77. {
  78. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  79. {
  80. return true;
  81. }
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanSelectDigimonCondition(Permanent permament)
  88. {
  89. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permament, card) && permament.TopCard.HasTSTraits;
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable hashtable)
  92. {
  93. #region Return all Lowest Level Digimon to Hand
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  95. {
  96. List<Permanent> bouncePermanents = (from Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons()
  97. where CanSelectTargetCondition(permanent)
  98. where !permanent.TopCard.CanNotBeAffected(activateClass)
  99. select permanent).ToList();
  100. if (bouncePermanents.Count >= 1)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  103. targetPermanents: bouncePermanents,
  104. activateClass: activateClass,
  105. successProcess: SuccessProcess(),
  106. failureProcess: null));
  107. IEnumerator SuccessProcess()
  108. {
  109. #region if returned, unsuspend
  110. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDigimonCondition))
  111. {
  112. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimonCondition));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectDigimonCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: null,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.UnTap,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will unsuspend", "The opponent is selecting 1 Digimon to unsuspend.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. }
  129. #endregion
  130. }
  131. }
  132. }
  133. #endregion
  134. #region Select Digimon To Link
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition, true))
  136. {
  137. Permanent selectedPermanent = null;
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: 1,
  145. canNoSelect: true,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectPermanentCoroutine,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link.", "The opponent is selecting 1 Digimon to link.");
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  154. {
  155. selectedPermanent = permanent;
  156. yield return null;
  157. }
  158. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(card, activateClass));
  159. }
  160. #endregion
  161. }
  162. }
  163. #endregion
  164. #region Link ESS
  165. if (timing == EffectTiming.OnAllyAttack)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Bounce 1 opponent's lowest level Digimon.", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  170. activateClass.SetIsLinkedEffect(true);
  171. activateClass.SetHashString("WA_BT24-091");
  172. cardEffects.Add(activateClass);
  173. string EffectDescription()
  174. {
  175. return "[When Attacking] [Once Per Turn] Return 1 of your opponent's lowest level Digimon to the hand.";
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  180. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  181. }
  182. bool CanSelectOpponentDigimon(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  185. && CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
  190. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentDigimon);
  191. }
  192. IEnumerator ActivateCoroutine(Hashtable hashtable)
  193. {
  194. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentDigimon));
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: CanSelectOpponentDigimon,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: maxCount,
  202. canNoSelect: false,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: null,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Bounce,
  207. cardEffect: activateClass);
  208. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to bounce.", "The opponent is selecting a digimon to bounce.");
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }