BT21_060.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. //Destromon
  7. public class BT21_060 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if ((targetPermanent.TopCard.EqualsCardName("Vemmon")))
  18. {
  19. return true;
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 6, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region When Digivolving
  27. if (timing == EffectTiming.OnEnterFieldAnyone)
  28. {
  29. ActivateClass activateClass = new ActivateClass();
  30. activateClass.SetUpICardEffect("Can't trash stacked cards, then de-digivolve", CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  32. cardEffects.Add(activateClass);
  33. string EffectDiscription()
  34. {
  35. return "[When Digivolving] Until your opponent's turn ends, their effects can't trash this Digimon's top stacked cards. Then, to 1 of your opponent's Digimon, <De-Digivolve 1> for every 2 [Vemmon] in this Digimon's digivolution cards.";
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  44. }
  45. bool SelectableOpponentsDigimon(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. int VemmonInSourceDividedBy2()
  50. {
  51. int vemmonCounter = 0;
  52. foreach (CardSource cardSource in card.PermanentOfThisCard().DigivolutionCards)
  53. {
  54. if (cardSource.EqualsCardName("Vemmon"))
  55. {
  56. vemmonCounter++;
  57. }
  58. }
  59. return vemmonCounter / 2;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. Permanent selectedPermanent = card.PermanentOfThisCard();
  64. if (selectedPermanent != null)
  65. {
  66. ImmuneStackTrashingClass immuneFromStackTrashingClass = new ImmuneStackTrashingClass();
  67. immuneFromStackTrashingClass.SetUpICardEffect("Isn't affected by trashing any stacked card", CanUseCondition1, selectedPermanent.TopCard);
  68. immuneFromStackTrashingClass.SetUpImmuneFromStackTrashingClass(PermanentCondition: PermanentCondition, EffectCondition: EffectCondition);
  69. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromStackTrashingClass);
  70. bool CanUseCondition1(Hashtable hashtable1)
  71. {
  72. return selectedPermanent.TopCard != null;
  73. }
  74. bool EffectCondition(ICardEffect effect)
  75. {
  76. return CardEffectCommons.IsOpponentEffect(effect, card);
  77. }
  78. bool PermanentCondition(Permanent permanent)
  79. {
  80. return permanent == selectedPermanent;
  81. }
  82. }
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: SelectableOpponentsDigimon,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: 1,
  90. canNoSelect: false,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: SelectPermanentCoroutine,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. for (int i = 0; i < VemmonInSourceDividedBy2(); i++)
  101. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  102. }
  103. }
  104. }
  105. #endregion
  106. #region All Turns
  107. if (timing == EffectTiming.WhenRemoveField)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Play 1 [Vemmon] from source without paying the cost when leaving battle area.", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[All Turns] When this Digimon would leave the battle area, you may play 1 [Vemmon] from its digivolution cards without paying the cost.";
  116. }
  117. bool CanSelectSourceCardCondition(CardSource cardSource)
  118. {
  119. return cardSource.EqualsCardName("Vemmon") &&
  120. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  125. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  130. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. List<CardSource> selectedCards = new List<CardSource>();
  135. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  136. selectCardEffect.SetUp(
  137. canTargetCondition: CanSelectSourceCardCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. canNoSelect: () => true,
  141. selectCardCoroutine: SelectCardCoroutine,
  142. afterSelectCardCoroutine: null,
  143. message: "Select 1 digivolution card to play.",
  144. maxCount: 1,
  145. canEndNotMax: false,
  146. isShowOpponent: true,
  147. mode: SelectCardEffect.Mode.Custom,
  148. root: SelectCardEffect.Root.Custom,
  149. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  150. canLookReverseCard: true,
  151. selectPlayer: card.Owner,
  152. cardEffect: activateClass);
  153. selectCardEffect.SetUpCustomMessage(
  154. "Select 1 digivolution card to play.",
  155. "The opponent is selecting 1 digivolution card to play.");
  156. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  157. yield return StartCoroutine(selectCardEffect.Activate());
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCards.Add(cardSource);
  161. yield return null;
  162. }
  163. yield return ContinuousController.instance.StartCoroutine(
  164. CardEffectCommons.PlayPermanentCards(
  165. cardSources: selectedCards,
  166. activateClass: activateClass,
  167. payCost: false,
  168. isTapped: false,
  169. root: SelectCardEffect.Root.DigivolutionCards,
  170. activateETB: true));
  171. }
  172. }
  173. #endregion
  174. #region Opponent's Turn Inherited
  175. if (timing == EffectTiming.OnAllyAttack)
  176. {
  177. ActivateClass activateClass = new ActivateClass();
  178. activateClass.SetUpICardEffect("Return 2 [Vemmon] from source to bottom of deck to end the attack", CanUseCondition, card);
  179. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  180. activateClass.SetIsInheritedEffect(true);
  181. activateClass.SetHashString("end-attack-BT21-060");
  182. cardEffects.Add(activateClass);
  183. string EffectDiscription()
  184. {
  185. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, by returning 2 [Vemmon] from this Digimon's digivolution cards to the bottom of the deck, end that attack.";
  186. }
  187. bool PermanentCondition(Permanent permanent)
  188. {
  189. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  190. }
  191. bool CanSelectVemmon(CardSource cardSource)
  192. {
  193. return cardSource.EqualsCardName("Vemmon");
  194. }
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  198. CardEffectCommons.IsOpponentTurn(card) &&
  199. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  204. card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectVemmon) >= 2;
  205. }
  206. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  207. {
  208. List<CardSource> selectedCards = new List<CardSource>();
  209. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  210. selectCardEffect.SetUp(
  211. canTargetCondition: CanSelectVemmon,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. canNoSelect: () => false,
  215. selectCardCoroutine: null,
  216. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  217. message: "Select 2 [Vemmon] to place at the bottom of the deck.",
  218. maxCount: 2,
  219. canEndNotMax: false,
  220. isShowOpponent: false,
  221. mode: SelectCardEffect.Mode.Custom,
  222. root: SelectCardEffect.Root.Custom,
  223. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  224. canLookReverseCard: true,
  225. selectPlayer: card.Owner,
  226. cardEffect: activateClass);
  227. selectCardEffect.SetNotShowCard();
  228. selectCardEffect.SetNotAddLog();
  229. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  230. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  231. {
  232. selectedCards = cardSources;
  233. yield return null;
  234. }
  235. if(selectedCards.Count > 0)
  236. {
  237. yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass(card.PermanentOfThisCard(), selectedCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards());
  238. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(selectedCards, "Deck Bottom Cards", true, true));
  239. GManager.instance.attackProcess.IsEndAttack = true;
  240. }
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }