BT24_059.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Sharkmon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_059 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.HasTSTraits
  20. || targetPermanent.TopCard.HasAquaTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Shared OP/WD
  26. string SharedEffectName() => "<De-Digivolve 1> of your opponent's Digimon.";
  27. string SharedEffectDescription(string tag) => $"[{tag}] <De-Digivolve 1> of your opponent's Digimon.";
  28. bool SharedCanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  31. }
  32. bool CanSelectPermanentConditionShared(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  35. }
  36. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  37. {
  38. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared))
  39. {
  40. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared));
  41. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: CanSelectPermanentConditionShared,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: maxCount,
  48. canNoSelect: false,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  55. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  56. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  57. {
  58. Permanent selectedPermanent = permanent;
  59. if (selectedPermanent != null)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  62. }
  63. yield return null;
  64. }
  65. }
  66. }
  67. #endregion
  68. #region On Play
  69. if (timing == EffectTiming.OnEnterFieldAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  73. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  74. cardEffects.Add(activateClass);
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  78. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  79. }
  80. }
  81. #endregion
  82. #region When Digivolving
  83. if (timing == EffectTiming.OnEnterFieldAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  87. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  88. cardEffects.Add(activateClass);
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  92. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  93. }
  94. }
  95. #endregion
  96. #region On Deletion
  97. if (timing == EffectTiming.OnDestroyedAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Reveal 3, maybe play 7 cost [TS] trait, trash rest.", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  102. cardEffects.Add(activateClass);
  103. string EffectDescription()
  104. {
  105. return "[On Deletion] Reveal the top 3 cards of your deck. You may play 1 cost 7 or lower [TS] trait card suspended among them without paying the cost. Trash the rest.";
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  114. }
  115. bool CanSelectCardCondition(CardSource cardSource)
  116. {
  117. return (cardSource.IsDigimon || cardSource.IsTamer)
  118. && cardSource.EqualsTraits("TS")
  119. && cardSource.GetCostItself <= 7
  120. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  123. {
  124. List<CardSource> selectedCards = new List<CardSource>();
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  126. revealCount: 3,
  127. simplifiedSelectCardConditions:
  128. new SimplifiedSelectCardConditionClass[]
  129. {
  130. new SimplifiedSelectCardConditionClass(
  131. canTargetCondition:CanSelectCardCondition,
  132. message: "Select 1 play cost 7 or lower [TS] trait card to play.",
  133. mode: SelectCardEffect.Mode.Custom,
  134. maxCount: 1,
  135. selectCardCoroutine: SelectCardCoroutine),
  136. },
  137. remainingCardsPlace: RemainingCardsPlace.Trash,
  138. activateClass: activateClass,
  139. canNoSelect: true
  140. ));
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. selectedCards.Add(cardSource);
  144. yield return null;
  145. }
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  147. cardSources: selectedCards,
  148. activateClass: activateClass,
  149. payCost: false,
  150. isTapped: true,
  151. root: SelectCardEffect.Root.Library,
  152. activateETB: true));
  153. }
  154. }
  155. #endregion
  156. #region When Attacking - ESS
  157. if (timing == EffectTiming.OnAllyAttack)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("Place 1 of your other Digimon as this Digimon's bottom digivolution card to unsuspend this Digimon.", CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  162. activateClass.SetIsInheritedEffect(true);
  163. activateClass.SetHashString("BT24_059_Inherited");
  164. cardEffects.Add(activateClass);
  165. string EffectDescription()
  166. {
  167. return "[When Attacking] [Once Per Turn] By placing 1 of your other Digimon as this Digimon's bottom digivolution card, it unsuspends.";
  168. }
  169. bool CanSelectPermanentCondition(Permanent permanent)
  170. {
  171. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  172. && permanent != card.PermanentOfThisCard()
  173. && !permanent.TopCard.Equals(card);
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleArea(card)
  182. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  183. }
  184. IEnumerator ActivateCoroutine(Hashtable hashtable)
  185. {
  186. CardSource placedCard = null;
  187. Permanent thisPermanent = card.PermanentOfThisCard();
  188. SelectPermanentEffect selectPermanentEffect =
  189. GManager.instance.GetComponent<SelectPermanentEffect>();
  190. selectPermanentEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: CanSelectPermanentCondition,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: 1,
  196. canNoSelect: false,
  197. canEndNotMax: false,
  198. selectPermanentCoroutine: SelectPermanentCoroutine,
  199. afterSelectPermanentCoroutine: null,
  200. mode: SelectPermanentEffect.Mode.Custom,
  201. cardEffect: activateClass);
  202. selectPermanentEffect.SetUpCustomMessage(
  203. "Select 1 card to place on bottom of digivolution cards.",
  204. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  207. {
  208. placedCard = permanent.TopCard;
  209. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  210. new List<Permanent[]>() { new Permanent[] { permanent, thisPermanent } },
  211. false,
  212. activateClass).PlacePermanentToDigivolutionCards());
  213. }
  214. if (thisPermanent.DigivolutionCards.Contains(placedCard))
  215. {
  216. yield return ContinuousController.instance.StartCoroutine(
  217. new IUnsuspendPermanents(new List<Permanent>() { thisPermanent },
  218. activateClass).Unsuspend());
  219. }
  220. }
  221. }
  222. #endregion
  223. return cardEffects;
  224. }
  225. }
  226. }