BT18_072.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_072 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.EqualsTraits("Insectoid");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null)
  24. );
  25. }
  26. #endregion
  27. #region DigiXros
  28. if (timing == EffectTiming.None)
  29. {
  30. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  31. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  32. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  33. addDigiXrosConditionClass.SetNotShowUI(true);
  34. cardEffects.Add(addDigiXrosConditionClass);
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return true;
  38. }
  39. DigiXrosCondition GetDigiXros(CardSource cardSource)
  40. {
  41. if (cardSource == card)
  42. {
  43. DigiXrosConditionElement elementHuman =
  44. new DigiXrosConditionElement(CanSelectCardCondition, "Beetlemon");
  45. bool CanSelectCardCondition(CardSource conditionCardSource)
  46. {
  47. if (conditionCardSource != null)
  48. {
  49. if (conditionCardSource.Owner == card.Owner)
  50. {
  51. if (conditionCardSource.IsDigimon)
  52. {
  53. if (conditionCardSource.CardNames_DigiXros.Contains("Beetlemon"))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. DigiXrosConditionElement elementBeast =
  63. new DigiXrosConditionElement(CanSelectCardCondition1, "MetalKabuterimon");
  64. bool CanSelectCardCondition1(CardSource conditionCardSource)
  65. {
  66. if (conditionCardSource != null)
  67. {
  68. if (conditionCardSource.Owner == card.Owner)
  69. {
  70. if (conditionCardSource.IsDigimon)
  71. {
  72. if (conditionCardSource.CardNames_DigiXros.Contains("MetalKabuterimon"))
  73. {
  74. return true;
  75. }
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  82. { elementHuman, elementBeast };
  83. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  84. return digiXrosCondition;
  85. }
  86. return null;
  87. }
  88. }
  89. #endregion
  90. #region On Play/ When Digivolving Shared
  91. bool CanSelectPermanentConditionShared(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  94. }
  95. bool CanActivateConditionShared(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  98. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  99. }
  100. #endregion
  101. #region On Play
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("De-Digivolve 2 2 of your opponent's Digimon ", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  107. cardEffects.Add(activateClass);
  108. string EffectDescription()
  109. {
  110. return
  111. "[On Play] <De-Digivolve 2> 2 of your opponent's Digimon.";
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable hashtable)
  118. {
  119. SelectPermanentEffect selectPermanentEffect =
  120. GManager.instance.GetComponent<SelectPermanentEffect>();
  121. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared));
  122. selectPermanentEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectPermanentConditionShared,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: false,
  129. canEndNotMax: false,
  130. selectPermanentCoroutine: SelectPermanentCoroutine,
  131. afterSelectPermanentCoroutine: null,
  132. mode: SelectPermanentEffect.Mode.Custom,
  133. cardEffect: activateClass);
  134. selectPermanentEffect.SetUpCustomMessage("Select 2 Digimon to De-Digivolve 2.",
  135. "The opponent is selecting 2 Digimon to De-Digivolve 2.");
  136. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  137. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(
  140. new IDegeneration(permanent, 2, activateClass).Degeneration());
  141. }
  142. }
  143. }
  144. #endregion
  145. #region When Digivolving
  146. if (timing == EffectTiming.OnEnterFieldAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("De-Digivolve 2 2 of your opponent's Digimon ", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return
  155. "[When Digivolving] <De-Digivolve 2> 2 of your opponent's Digimon.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. SelectPermanentEffect selectPermanentEffect =
  164. GManager.instance.GetComponent<SelectPermanentEffect>();
  165. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared));
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectPermanentConditionShared,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: false,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: SelectPermanentCoroutine,
  175. afterSelectPermanentCoroutine: null,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage("Select 2 Digimon to De-Digivolve 2.",
  179. "The opponent is selecting 2 Digimon to De-Digivolve 2.");
  180. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  181. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  182. {
  183. yield return ContinuousController.instance.StartCoroutine(
  184. new IDegeneration(permanent, 2, activateClass).Degeneration());
  185. }
  186. }
  187. }
  188. #endregion
  189. #region All Turns
  190. if (timing == EffectTiming.WhenRemoveField)
  191. {
  192. ActivateClass activateClass = new ActivateClass();
  193. activateClass.SetUpICardEffect("Play a Digimon from digivolution cards.", CanUseCondition, card);
  194. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  195. cardEffects.Add(activateClass);
  196. string EffectDescription()
  197. {
  198. return
  199. "[All Turns] When this Digimon would leave the battle area, you may play 1 level 4 or lower Digimon card with the [Insectoid]/[Hybrid] trait from this Digimon's digivolution cards without paying the cost.";
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  204. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  205. }
  206. bool CanSelectCardCondition(CardSource cardSource)
  207. {
  208. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 4 &&
  209. (cardSource.ContainsTraits("Insectoid") || cardSource.ContainsTraits("Hybrid")) &&
  210. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  211. }
  212. bool CanActivateCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  215. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition);
  216. }
  217. IEnumerator ActivateCoroutine(Hashtable hashtable)
  218. {
  219. List<CardSource> selectedCards = new List<CardSource>();
  220. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  221. selectCardEffect.SetUp(
  222. canTargetCondition: CanSelectCardCondition,
  223. canTargetCondition_ByPreSelecetedList: null,
  224. canEndSelectCondition: null,
  225. canNoSelect: () => true,
  226. selectCardCoroutine: SelectCardCoroutine,
  227. afterSelectCardCoroutine: null,
  228. message: "Select 1 digivolution card to play.",
  229. maxCount: 1,
  230. canEndNotMax: false,
  231. isShowOpponent: true,
  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.SetUpCustomMessage(
  239. "Select 1 digivolution card to play.",
  240. "The opponent is selecting 1 digivolution card to play.");
  241. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  242. yield return StartCoroutine(selectCardEffect.Activate());
  243. IEnumerator SelectCardCoroutine(CardSource cardSource)
  244. {
  245. selectedCards.Add(cardSource);
  246. yield return null;
  247. }
  248. yield return ContinuousController.instance.StartCoroutine(
  249. CardEffectCommons.PlayPermanentCards(
  250. cardSources: selectedCards,
  251. activateClass: activateClass,
  252. payCost: false,
  253. isTapped: false,
  254. root: SelectCardEffect.Root.DigivolutionCards,
  255. activateETB: true));
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }