BT21_060.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  67. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseCondition1, selectedPermanent.TopCard);
  68. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentCondition);
  69. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  70. bool CanUseCondition1(Hashtable hashtable1)
  71. {
  72. return selectedPermanent.TopCard != null;
  73. }
  74. bool PermanentCondition(Permanent permanent)
  75. {
  76. return permanent == selectedPermanent;
  77. }
  78. CanNotTrashFromDigivolutionCardsClass canNotTrashFromDigivolutionCardsClass = new CanNotTrashFromDigivolutionCardsClass();
  79. canNotTrashFromDigivolutionCardsClass.SetUpICardEffect("[This Digimon's sources can't be trashed", CanUseCondition2, card);
  80. canNotTrashFromDigivolutionCardsClass.SetUpCanNotTrashFromDigivolutionCardsClass(CardCondition: CardCondition, CardEffectCondition: CardEffectCondition);
  81. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotTrashFromDigivolutionCardsClass);
  82. bool CanUseCondition2(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleArea(card);
  85. }
  86. bool CardCondition(CardSource cardSource)
  87. {
  88. return CardEffectCommons.IsExistOnBattleArea(card);
  89. }
  90. bool CardEffectCondition(ICardEffect cardEffect)
  91. {
  92. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  93. }
  94. }
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: SelectableOpponentsDigimon,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: 1,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, VemmonInSourceDividedBy2(), activateClass).Degeneration());
  113. }
  114. }
  115. }
  116. #endregion
  117. #region All Turns
  118. if (timing == EffectTiming.WhenRemoveField)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("Play 1 [Vemmon] from source without paying the cost when leaving battle area.", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  123. cardEffects.Add(activateClass);
  124. string EffectDiscription()
  125. {
  126. return "[All Turns] When this Digimon would leave the battle area, you may play 1 [Vemmon] from its digivolution cards without paying the cost.";
  127. }
  128. bool CanSelectSourceCardCondition(CardSource cardSource)
  129. {
  130. return cardSource.EqualsCardName("Vemmon") &&
  131. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  136. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  137. }
  138. bool CanActivateCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  141. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
  142. }
  143. IEnumerator ActivateCoroutine(Hashtable hashtable)
  144. {
  145. List<CardSource> selectedCards = new List<CardSource>();
  146. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  147. selectCardEffect.SetUp(
  148. canTargetCondition: CanSelectSourceCardCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. canNoSelect: () => true,
  152. selectCardCoroutine: SelectCardCoroutine,
  153. afterSelectCardCoroutine: null,
  154. message: "Select 1 digivolution card to play.",
  155. maxCount: 1,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. mode: SelectCardEffect.Mode.Custom,
  159. root: SelectCardEffect.Root.Custom,
  160. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  161. canLookReverseCard: true,
  162. selectPlayer: card.Owner,
  163. cardEffect: activateClass);
  164. selectCardEffect.SetUpCustomMessage(
  165. "Select 1 digivolution card to play.",
  166. "The opponent is selecting 1 digivolution card to play.");
  167. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  168. yield return StartCoroutine(selectCardEffect.Activate());
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. yield return ContinuousController.instance.StartCoroutine(
  175. CardEffectCommons.PlayPermanentCards(
  176. cardSources: selectedCards,
  177. activateClass: activateClass,
  178. payCost: false,
  179. isTapped: false,
  180. root: SelectCardEffect.Root.DigivolutionCards,
  181. activateETB: true));
  182. }
  183. }
  184. #endregion
  185. #region Opponent's Turn Inherited
  186. if (timing == EffectTiming.OnAllyAttack)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("Return 2 [Vemmon] from source to bottom of deck to end the attack", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  191. activateClass.SetIsInheritedEffect(true);
  192. activateClass.SetHashString("end-attack-BT21-060");
  193. cardEffects.Add(activateClass);
  194. string EffectDiscription()
  195. {
  196. 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.";
  197. }
  198. bool PermanentCondition(Permanent permanent)
  199. {
  200. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  201. }
  202. bool CanSelectVemmon(CardSource cardSource)
  203. {
  204. return cardSource.EqualsCardName("Vemmon");
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  209. CardEffectCommons.IsOpponentTurn(card) &&
  210. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  211. }
  212. bool CanActivateCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  215. card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectVemmon) >= 2;
  216. }
  217. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  218. {
  219. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  220. selectCardEffect.SetUp(
  221. canTargetCondition: CanSelectVemmon,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. canNoSelect: () => false,
  225. selectCardCoroutine: null,
  226. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  227. message: "Select 2 [Vemmon] to place at the bottom of the deck.",
  228. maxCount: 2,
  229. canEndNotMax: false,
  230. isShowOpponent: false,
  231. mode: SelectCardEffect.Mode.Custom,
  232. root: SelectCardEffect.Root.Custom,
  233. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  234. canLookReverseCard: true,
  235. selectPlayer: card.Owner,
  236. cardEffect: activateClass);
  237. selectCardEffect.SetNotShowCard();
  238. selectCardEffect.SetNotAddLog();
  239. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  240. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  241. {
  242. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  243. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Bottom Cards", true, true));
  244. GManager.instance.attackProcess.IsEndAttack = true;
  245. }
  246. }
  247. }
  248. #endregion
  249. return cardEffects;
  250. }
  251. }
  252. }