BT21_060.cs 14 KB

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