BT21_077.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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 isExistOnField(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(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  109. ActivateClass activateClassDebuff = new ActivateClass();
  110. activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
  111. selectedPermanent.TopCard);
  112. activateClassDebuff.SetUpActivateClass(CanActivateConditionDebuff, ActivateCoroutineDebuff, -1, false,
  113. EffectDescriptionDebuff());
  114. activateClassDebuff.SetEffectSourcePermanent(selectedPermanent);
  115. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  116. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  119. .CreateDebuffEffect(selectedPermanent));
  120. }
  121. string EffectDescriptionDebuff()
  122. {
  123. return "[Start of Your Main Phase] Attack with this Digimon.";
  124. }
  125. bool CanUseConditionDebuff(Hashtable hashtable1)
  126. {
  127. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  128. selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent) &&
  129. GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  130. }
  131. bool CanActivateConditionDebuff(Hashtable hashtable1)
  132. {
  133. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  134. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  135. selectedPermanent.CanAttack(activateClassDebuff);
  136. }
  137. IEnumerator ActivateCoroutineDebuff(Hashtable hashtableDebuff)
  138. {
  139. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  140. selectedPermanent.CanAttack(activateClassDebuff))
  141. {
  142. SelectAttackEffect selectAttackEffect =
  143. GManager.instance.GetComponent<SelectAttackEffect>();
  144. selectAttackEffect.SetUp(
  145. attacker: selectedPermanent,
  146. canAttackPlayerCondition: () => true,
  147. defenderCondition: _ => true,
  148. cardEffect: activateClassDebuff);
  149. selectAttackEffect.SetCanNotSelectNotAttack();
  150. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  151. }
  152. }
  153. ICardEffect GetCardEffect(EffectTiming timingDebuff)
  154. {
  155. return timingDebuff == EffectTiming.OnStartMainPhase ? activateClassDebuff : null;
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. #region When Digivolving
  165. if (timing == EffectTiming.OnEnterFieldAnyone)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Force attack and give collision", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  170. cardEffects.Add(activateClass);
  171. string EffectDescription()
  172. {
  173. 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.";
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable hashtable)
  180. {
  181. if (card.Owner.HandCards.Count(CanTrashCard) >= 1)
  182. {
  183. bool discarded = false;
  184. int discardCount = 1;
  185. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  186. selectHandEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanTrashCard,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: discardCount,
  192. canNoSelect: true,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. selectCardCoroutine: null,
  196. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  197. mode: SelectHandEffect.Mode.Discard,
  198. cardEffect: activateClass);
  199. yield return StartCoroutine(selectHandEffect.Activate());
  200. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  201. {
  202. if (cardSources.Count >= 1)
  203. {
  204. discarded = true;
  205. yield return null;
  206. }
  207. }
  208. if (discarded)
  209. {
  210. if (CardEffectCommons.HasMatchConditionPermanent(CanTargetPermanent))
  211. {
  212. Permanent selectedPermanent = null;
  213. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  214. selectPermanentEffect.SetUp(
  215. selectPlayer: card.Owner,
  216. canTargetCondition: CanTargetPermanent,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. maxCount: 1,
  220. canNoSelect: false,
  221. canEndNotMax: false,
  222. selectPermanentCoroutine: SelectPermanentCoroutine,
  223. afterSelectPermanentCoroutine: null,
  224. mode: SelectPermanentEffect.Mode.Custom,
  225. cardEffect: activateClass);
  226. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  227. "The opponent is selecting 1 Digimon that will get effects.");
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  230. {
  231. selectedPermanent = permanent;
  232. yield return null;
  233. }
  234. if (selectedPermanent != null)
  235. {
  236. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCollision(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  237. ActivateClass activateClassDebuff = new ActivateClass();
  238. activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
  239. selectedPermanent.TopCard);
  240. activateClassDebuff.SetUpActivateClass(CanActivateConditionDebuff, ActivateCoroutineDebuff, -1, false,
  241. EffectDescriptionDebuff());
  242. activateClassDebuff.SetEffectSourcePermanent(selectedPermanent);
  243. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  244. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  245. {
  246. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  247. .CreateDebuffEffect(selectedPermanent));
  248. }
  249. string EffectDescriptionDebuff()
  250. {
  251. return "[Start of Your Main Phase] Attack with this Digimon.";
  252. }
  253. bool CanUseConditionDebuff(Hashtable hashtable1)
  254. {
  255. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  256. selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent) &&
  257. GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  258. }
  259. bool CanActivateConditionDebuff(Hashtable hashtable1)
  260. {
  261. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  262. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  263. selectedPermanent.CanAttack(activateClassDebuff);
  264. }
  265. IEnumerator ActivateCoroutineDebuff(Hashtable hashtableDebuff)
  266. {
  267. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  268. selectedPermanent.CanAttack(activateClassDebuff))
  269. {
  270. SelectAttackEffect selectAttackEffect =
  271. GManager.instance.GetComponent<SelectAttackEffect>();
  272. selectAttackEffect.SetUp(
  273. attacker: selectedPermanent,
  274. canAttackPlayerCondition: () => true,
  275. defenderCondition: _ => true,
  276. cardEffect: activateClassDebuff);
  277. selectAttackEffect.SetCanNotSelectNotAttack();
  278. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  279. }
  280. }
  281. ICardEffect GetCardEffect(EffectTiming timingDebuff)
  282. {
  283. return timingDebuff == EffectTiming.OnStartMainPhase ? activateClassDebuff : null;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. #endregion
  292. #region On Deletions Shared
  293. #endregion
  294. #region On deletion regular
  295. if(timing == EffectTiming.OnDestroyedAnyone)
  296. {
  297. ActivateClass activateClass = new ActivateClass();
  298. activateClass.SetUpICardEffect("Play Cannonweissmon or level 4 or lower gammamon in text digimon", CanUseCondition, card);
  299. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  300. cardEffects.Add(activateClass);
  301. string EffectDescription()
  302. {
  303. 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.";
  304. }
  305. bool CanUseCondition(Hashtable hashtable)
  306. {
  307. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  308. }
  309. bool CanPlay(CardSource cardSource)
  310. {
  311. return ((cardSource.HasText("Gammamon") && cardSource.HasLevel && cardSource.Level <= 4) || cardSource.EqualsCardName("Cannonweissmon")) &&
  312. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  313. }
  314. bool CanActivateCondition(Hashtable hashtable)
  315. {
  316. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlay);
  317. }
  318. IEnumerator ActivateCoroutine(Hashtable hashtable)
  319. {
  320. List<CardSource> selectedCards = new List<CardSource>();
  321. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  322. selectCardEffect.SetUp(
  323. canTargetCondition: CanPlay,
  324. canTargetCondition_ByPreSelecetedList: null,
  325. canEndSelectCondition: null,
  326. canNoSelect: () => true,
  327. selectCardCoroutine: SelectCardCoroutine,
  328. afterSelectCardCoroutine: null,
  329. message: "Select 1 [Cannonweissmon] or level 4 or lower [Gammamon] in text Digimon to play.",
  330. maxCount: 1,
  331. canEndNotMax: false,
  332. isShowOpponent: true,
  333. mode: SelectCardEffect.Mode.Custom,
  334. root: SelectCardEffect.Root.Trash,
  335. customRootCardList: null,
  336. canLookReverseCard: true,
  337. selectPlayer: card.Owner,
  338. cardEffect: activateClass);
  339. selectCardEffect.SetUpCustomMessage("Select 1 [Cannonweissmon] or level 4 or lower [Gammamon] in text Digimon to play.",
  340. "The opponent is selecting 1 [Cannonweissmon] or level 4 or lower [Gammamon] in text Digimon to play.");
  341. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  342. yield return StartCoroutine(selectCardEffect.Activate());
  343. IEnumerator SelectCardCoroutine(CardSource cardSource)
  344. {
  345. selectedCards.Add(cardSource);
  346. yield return null;
  347. }
  348. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  349. cardSources: selectedCards,
  350. activateClass: activateClass,
  351. payCost: false,
  352. isTapped: false,
  353. root: SelectCardEffect.Root.Trash,
  354. activateETB: true));
  355. }
  356. }
  357. #endregion
  358. #region On deletion inherit
  359. if (timing == EffectTiming.OnDestroyedAnyone)
  360. {
  361. ActivateClass activateClass = new ActivateClass();
  362. activateClass.SetUpICardEffect("Play Cannonweissmon or level 4 or lower gammamon in text digimon", CanUseCondition, card);
  363. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  364. activateClass.SetIsInheritedEffect(true);
  365. cardEffects.Add(activateClass);
  366. string EffectDescription()
  367. {
  368. 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.";
  369. }
  370. bool CanUseCondition(Hashtable hashtable)
  371. {
  372. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  373. }
  374. bool CanPlay(CardSource cardSource)
  375. {
  376. return cardSource.HasText("Gammamon") && cardSource.HasLevel && cardSource.Level <= 4 &&
  377. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  378. }
  379. bool CanActivateCondition(Hashtable hashtable)
  380. {
  381. return CardEffectCommons.CanActivateOnDeletionInherited(hashtable, card) && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlay);
  382. }
  383. IEnumerator ActivateCoroutine(Hashtable hashtable)
  384. {
  385. List<CardSource> selectedCards = new List<CardSource>();
  386. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  387. selectCardEffect.SetUp(
  388. canTargetCondition: CanPlay,
  389. canTargetCondition_ByPreSelecetedList: null,
  390. canEndSelectCondition: null,
  391. canNoSelect: () => true,
  392. selectCardCoroutine: SelectCardCoroutine,
  393. afterSelectCardCoroutine: null,
  394. message: "Select 1 level 4 or lower [Gammamon] in text Digimon to play.",
  395. maxCount: 1,
  396. canEndNotMax: false,
  397. isShowOpponent: true,
  398. mode: SelectCardEffect.Mode.Custom,
  399. root: SelectCardEffect.Root.Trash,
  400. customRootCardList: null,
  401. canLookReverseCard: true,
  402. selectPlayer: card.Owner,
  403. cardEffect: activateClass);
  404. selectCardEffect.SetUpCustomMessage("Select 1 level 4 or lower [Gammamon] in text Digimon to play.",
  405. "The opponent is selecting 1 level 4 or lower [Gammamon] in text Digimon to play.");
  406. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  407. yield return StartCoroutine(selectCardEffect.Activate());
  408. IEnumerator SelectCardCoroutine(CardSource cardSource)
  409. {
  410. selectedCards.Add(cardSource);
  411. yield return null;
  412. }
  413. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  414. cardSources: selectedCards,
  415. activateClass: activateClass,
  416. payCost: false,
  417. isTapped: false,
  418. root: SelectCardEffect.Root.Trash,
  419. activateETB: true));
  420. }
  421. }
  422. #endregion
  423. return cardEffects;
  424. }
  425. }
  426. }