BT21_077.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //BT21_077 Regulusmon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition(Permanent permanent)
  16. {
  17. return permanent.Level == 4 && permanent.TopCard.HasText("Gammamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(Condition, 3, false, card, null));
  20. }
  21. #endregion
  22. #region On Play/When Digivolving shared
  23. bool CanTargetPermanent(Permanent permanent)
  24. {
  25. return permanent.IsDigimon && CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanActivateConditionShared(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  30. }
  31. bool CanTrashCard(CardSource card)
  32. {
  33. return card.HasText("Gammamon");
  34. }
  35. #endregion
  36. #region On Play
  37. if (timing == EffectTiming.OnEnterFieldAnyone)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("Force attack and give collision", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  42. cardEffects.Add(activateClass);
  43. string EffectDescription()
  44. {
  45. return "[On Play] By trashing 1 card with [Gammamon] in its text from your hand, give 1 of your opponent's Digimon <Collision> and \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. if (card.Owner.HandCards.Count(CanTrashCard) >= 1)
  54. {
  55. bool discarded = false;
  56. int discardCount = 1;
  57. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  58. selectHandEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanTrashCard,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: discardCount,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. isShowOpponent: true,
  67. selectCardCoroutine: null,
  68. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  69. mode: SelectHandEffect.Mode.Discard,
  70. cardEffect: activateClass);
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  73. {
  74. if (cardSources.Count >= 1)
  75. {
  76. discarded = true;
  77. yield return null;
  78. }
  79. }
  80. if (discarded)
  81. {
  82. if (CardEffectCommons.HasMatchConditionPermanent(CanTargetPermanent))
  83. {
  84. Permanent selectedPermanent = null;
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanTargetPermanent,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: SelectPermanentCoroutine,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  99. "The opponent is selecting 1 Digimon that will get effects.");
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  102. {
  103. selectedPermanent = permanent;
  104. yield return null;
  105. }
  106. if (selectedPermanent != null)
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCollision(
  109. targetPermanent: selectedPermanent,
  110. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  111. activateClass: activateClass));
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.StartOfMainAttack(
  113. targetPermanent: selectedPermanent,
  114. cardEffect: activateClass));
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. #endregion
  122. #region When Digivolving
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Force attack and give collision", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  128. cardEffects.Add(activateClass);
  129. string EffectDescription()
  130. {
  131. return "[When Digivolving] By trashing 1 card with [Gammamon] in its text from your hand, give 1 of your opponent's Digimon <Collision> and \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable hashtable)
  138. {
  139. if (card.Owner.HandCards.Count(CanTrashCard) >= 1)
  140. {
  141. bool discarded = false;
  142. int discardCount = 1;
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanTrashCard,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: discardCount,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: null,
  154. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  155. mode: SelectHandEffect.Mode.Discard,
  156. cardEffect: activateClass);
  157. yield return StartCoroutine(selectHandEffect.Activate());
  158. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  159. {
  160. if (cardSources.Count >= 1)
  161. {
  162. discarded = true;
  163. yield return null;
  164. }
  165. }
  166. if (discarded)
  167. {
  168. if (CardEffectCommons.HasMatchConditionPermanent(CanTargetPermanent))
  169. {
  170. Permanent selectedPermanent = null;
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: CanTargetPermanent,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: 1,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: SelectPermanentCoroutine,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Custom,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  185. "The opponent is selecting 1 Digimon that will get effects.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedPermanent = permanent;
  190. yield return null;
  191. }
  192. if (selectedPermanent != null)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCollision(
  195. targetPermanent: selectedPermanent,
  196. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  197. activateClass: activateClass));
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.StartOfMainAttack(
  199. targetPermanent: selectedPermanent,
  200. cardEffect: activateClass));
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. #endregion
  208. #region On deletion regular
  209. if (timing == EffectTiming.OnDestroyedAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("Play Cannonweissmon or level 4 or lower gammamon in text digimon", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  214. cardEffects.Add(activateClass);
  215. string EffectDescription()
  216. {
  217. return "[On Deletion] You may play 1 [Canoweissmon] or 1 level 4 or lower Digimon card with [Gammamon] in its text from your trash without paying the cost.";
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  222. }
  223. bool CanPlay(CardSource cardSource)
  224. {
  225. return ((cardSource.HasText("Gammamon") && cardSource.HasLevel && cardSource.Level <= 4 && cardSource.IsDigimon) || cardSource.EqualsCardName("Canoweissmon")) &&
  226. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlay);
  231. }
  232. IEnumerator ActivateCoroutine(Hashtable hashtable)
  233. {
  234. List<CardSource> selectedCards = new List<CardSource>();
  235. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  236. selectCardEffect.SetUp(
  237. canTargetCondition: CanPlay,
  238. canTargetCondition_ByPreSelecetedList: null,
  239. canEndSelectCondition: null,
  240. canNoSelect: () => true,
  241. selectCardCoroutine: SelectCardCoroutine,
  242. afterSelectCardCoroutine: null,
  243. message: "Select 1 [Canoweissmon] or level 4 or lower [Gammamon] in text Digimon to play.",
  244. maxCount: 1,
  245. canEndNotMax: false,
  246. isShowOpponent: true,
  247. mode: SelectCardEffect.Mode.Custom,
  248. root: SelectCardEffect.Root.Trash,
  249. customRootCardList: null,
  250. canLookReverseCard: true,
  251. selectPlayer: card.Owner,
  252. cardEffect: activateClass);
  253. selectCardEffect.SetUpCustomMessage("Select 1 [Cannonweissmon] or level 4 or lower [Gammamon] in text Digimon to play.",
  254. "The opponent is selecting 1 [Cannonweissmon] or level 4 or lower [Gammamon] in text Digimon to play.");
  255. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  256. yield return StartCoroutine(selectCardEffect.Activate());
  257. IEnumerator SelectCardCoroutine(CardSource cardSource)
  258. {
  259. selectedCards.Add(cardSource);
  260. yield return null;
  261. }
  262. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  263. cardSources: selectedCards,
  264. activateClass: activateClass,
  265. payCost: false,
  266. isTapped: false,
  267. root: SelectCardEffect.Root.Trash,
  268. activateETB: true));
  269. }
  270. }
  271. #endregion
  272. #region On deletion inherit
  273. if (timing == EffectTiming.OnDestroyedAnyone)
  274. {
  275. ActivateClass activateClass = new ActivateClass();
  276. activateClass.SetUpICardEffect("Play Cannonweissmon or level 4 or lower gammamon in text digimon", CanUseCondition, card);
  277. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  278. activateClass.SetIsInheritedEffect(true);
  279. cardEffects.Add(activateClass);
  280. string EffectDescription()
  281. {
  282. return "[On Deletion] You may play 1 level 4 or lower Digimon card with [Gammamon] in its text from your trash without paying the cost.";
  283. }
  284. bool CanUseCondition(Hashtable hashtable)
  285. {
  286. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  287. }
  288. bool CanPlay(CardSource cardSource)
  289. {
  290. return cardSource.HasText("Gammamon") && cardSource.HasLevel && cardSource.Level <= 4 && cardSource.IsDigimon &&
  291. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  292. }
  293. bool CanActivateCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlay);
  296. }
  297. IEnumerator ActivateCoroutine(Hashtable hashtable)
  298. {
  299. List<CardSource> selectedCards = new List<CardSource>();
  300. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  301. selectCardEffect.SetUp(
  302. canTargetCondition: CanPlay,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. canNoSelect: () => true,
  306. selectCardCoroutine: SelectCardCoroutine,
  307. afterSelectCardCoroutine: null,
  308. message: "Select 1 level 4 or lower [Gammamon] in text Digimon to play.",
  309. maxCount: 1,
  310. canEndNotMax: false,
  311. isShowOpponent: true,
  312. mode: SelectCardEffect.Mode.Custom,
  313. root: SelectCardEffect.Root.Trash,
  314. customRootCardList: null,
  315. canLookReverseCard: true,
  316. selectPlayer: card.Owner,
  317. cardEffect: activateClass);
  318. selectCardEffect.SetUpCustomMessage("Select 1 level 4 or lower [Gammamon] in text Digimon to play.",
  319. "The opponent is selecting 1 level 4 or lower [Gammamon] in text Digimon to play.");
  320. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  321. yield return StartCoroutine(selectCardEffect.Activate());
  322. IEnumerator SelectCardCoroutine(CardSource cardSource)
  323. {
  324. selectedCards.Add(cardSource);
  325. yield return null;
  326. }
  327. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  328. cardSources: selectedCards,
  329. activateClass: activateClass,
  330. payCost: false,
  331. isTapped: false,
  332. root: SelectCardEffect.Root.Trash,
  333. activateETB: true));
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }