BT16_058.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_058 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.CardNames.Contains("Dorumon"))
  18. {
  19. return true;
  20. }
  21. if (targetPermanent.TopCard.Level == 3 && targetPermanent.TopCard.ContainsTraits("SoC"))
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition,
  29. digivolutionCost: 2,
  30. ignoreDigivolutionRequirement: false,
  31. card: card,
  32. condition: null));
  33. }
  34. #endregion
  35. #region Collision
  36. if (timing == EffectTiming.OnCounterTiming)
  37. {
  38. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  39. }
  40. #endregion
  41. #region On Play
  42. if (timing == EffectTiming.OnEnterFieldAnyone)
  43. {
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  47. cardEffects.Add(activateClass);
  48. string EffectDiscription()
  49. {
  50. return "[On Play] By trashing 1 card in your hand, <Draw 1>. Then, if this Digimon has a Tamer with the [SoC] trait in its digivolution cards, 1 of your opponent's Digimon gains \"[Start of Your Main Phase] This Digimon attacks.\" until the end of their turn.";
  51. }
  52. bool CanSelectCardCondition(CardSource cardSource)
  53. {
  54. return true;
  55. }
  56. bool HasTamerCardCondition(CardSource cardSource)
  57. {
  58. if (cardSource.CardTraits.Contains("SoC"))
  59. {
  60. if (cardSource.IsTamer)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool CanSelectPermanentCondition(Permanent permanent)
  68. {
  69. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleArea(card);
  78. }
  79. IEnumerator ActivateCoroutine(Hashtable hashtable)
  80. {
  81. bool discarded = false;
  82. Permanent selectedPermanent = null;
  83. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  84. {
  85. int discardCount = 1;
  86. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  87. selectHandEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: CanSelectCardCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: discardCount,
  93. canNoSelect: true,
  94. canEndNotMax: false,
  95. isShowOpponent: true,
  96. selectCardCoroutine: null,
  97. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  98. mode: SelectHandEffect.Mode.Discard,
  99. cardEffect: activateClass);
  100. yield return StartCoroutine(selectHandEffect.Activate());
  101. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  102. {
  103. if (cardSources.Count >= 1)
  104. {
  105. discarded = true;
  106. yield return null;
  107. }
  108. }
  109. }
  110. if (discarded)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  113. #region Has Tamer with [SoC] Trait - grant Start of Your Main Phase Effect
  114. if (card.PermanentOfThisCard().DigivolutionCards.Count(HasTamerCardCondition) >= 1)
  115. {
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  117. {
  118. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectPermanentCoroutine,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. selectedPermanent = permanent;
  137. yield return null;
  138. }
  139. if (selectedPermanent != null)
  140. {
  141. ActivateClass activateClass1 = new ActivateClass();
  142. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  143. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  144. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  145. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  146. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  147. {
  148. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  149. }
  150. string EffectDiscription1()
  151. {
  152. return "[Start of Your Main Phase] Attack with this Digimon.";
  153. }
  154. bool CanUseCondition1(Hashtable hashtable1)
  155. {
  156. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  157. {
  158. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  159. {
  160. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  161. {
  162. return true;
  163. }
  164. }
  165. }
  166. return false;
  167. }
  168. bool CanActivateCondition1(Hashtable hashtable1)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  171. {
  172. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  173. {
  174. if (selectedPermanent.CanAttack(activateClass1))
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. return false;
  181. }
  182. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  183. {
  184. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  185. {
  186. if (selectedPermanent.CanAttack(activateClass1))
  187. {
  188. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  189. selectAttackEffect.SetUp(
  190. attacker: selectedPermanent,
  191. canAttackPlayerCondition: () => true,
  192. defenderCondition: (permanent) => true,
  193. cardEffect: activateClass1);
  194. selectAttackEffect.SetCanNotSelectNotAttack();
  195. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  196. }
  197. }
  198. }
  199. ICardEffect GetCardEffect(EffectTiming _timing)
  200. {
  201. if (_timing == EffectTiming.OnStartMainPhase)
  202. {
  203. return activateClass1;
  204. }
  205. return null;
  206. }
  207. }
  208. }
  209. }
  210. #endregion
  211. }
  212. }
  213. }
  214. #endregion
  215. #region When Digivolving
  216. if (timing == EffectTiming.OnEnterFieldAnyone)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  221. cardEffects.Add(activateClass);
  222. string EffectDiscription()
  223. {
  224. return "[When Digivolving] By trashing 1 card in your hand, <Draw 1>. Then, if this Digimon has a Tamer with the [SoC] trait in its digivolution cards, 1 of your opponent's Digimon gains \"[Start of Your Main Phase] This Digimon attacks.\" until the end of their turn.";
  225. }
  226. bool CanSelectCardCondition(CardSource cardSource)
  227. {
  228. return true;
  229. }
  230. bool HasTamerCardCondition(CardSource cardSource)
  231. {
  232. if (cardSource.CardTraits.Contains("SoC"))
  233. {
  234. if (cardSource.IsTamer)
  235. {
  236. return true;
  237. }
  238. }
  239. return false;
  240. }
  241. bool CanSelectPermanentCondition(Permanent permanent)
  242. {
  243. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  244. }
  245. bool CanUseCondition(Hashtable hashtable)
  246. {
  247. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  248. }
  249. bool CanActivateCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.IsExistOnBattleArea(card);
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. bool discarded = false;
  256. Permanent selectedPermanent = null;
  257. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  258. {
  259. int discardCount = 1;
  260. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  261. selectHandEffect.SetUp(
  262. selectPlayer: card.Owner,
  263. canTargetCondition: CanSelectCardCondition,
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. maxCount: discardCount,
  267. canNoSelect: true,
  268. canEndNotMax: false,
  269. isShowOpponent: true,
  270. selectCardCoroutine: null,
  271. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  272. mode: SelectHandEffect.Mode.Discard,
  273. cardEffect: activateClass);
  274. yield return StartCoroutine(selectHandEffect.Activate());
  275. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  276. {
  277. if (cardSources.Count >= 1)
  278. {
  279. discarded = true;
  280. yield return null;
  281. }
  282. }
  283. }
  284. if (discarded)
  285. {
  286. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  287. #region Has Tamer with [SoC] Trait - grant Start of Your Main Phase Effect
  288. if (card.PermanentOfThisCard().DigivolutionCards.Count(HasTamerCardCondition) >= 1)
  289. {
  290. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  291. {
  292. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  293. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  294. selectPermanentEffect.SetUp(
  295. selectPlayer: card.Owner,
  296. canTargetCondition: CanSelectPermanentCondition,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. maxCount: maxCount,
  300. canNoSelect: false,
  301. canEndNotMax: false,
  302. selectPermanentCoroutine: SelectPermanentCoroutine,
  303. afterSelectPermanentCoroutine: null,
  304. mode: SelectPermanentEffect.Mode.Custom,
  305. cardEffect: activateClass);
  306. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  307. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  308. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  309. {
  310. selectedPermanent = permanent;
  311. yield return null;
  312. }
  313. if (selectedPermanent != null)
  314. {
  315. ActivateClass activateClass1 = new ActivateClass();
  316. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  317. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  318. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  319. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  320. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  321. {
  322. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  323. }
  324. string EffectDiscription1()
  325. {
  326. return "[Start of Your Main Phase] Attack with this Digimon.";
  327. }
  328. bool CanUseCondition1(Hashtable hashtable1)
  329. {
  330. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  331. {
  332. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  333. {
  334. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  335. {
  336. return true;
  337. }
  338. }
  339. }
  340. return false;
  341. }
  342. bool CanActivateCondition1(Hashtable hashtable1)
  343. {
  344. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  345. {
  346. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  347. {
  348. if (selectedPermanent.CanAttack(activateClass1))
  349. {
  350. return true;
  351. }
  352. }
  353. }
  354. return false;
  355. }
  356. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  357. {
  358. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  359. {
  360. if (selectedPermanent.CanAttack(activateClass1))
  361. {
  362. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  363. selectAttackEffect.SetUp(
  364. attacker: selectedPermanent,
  365. canAttackPlayerCondition: () => true,
  366. defenderCondition: (permanent) => true,
  367. cardEffect: activateClass1);
  368. selectAttackEffect.SetCanNotSelectNotAttack();
  369. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  370. }
  371. }
  372. }
  373. ICardEffect GetCardEffect(EffectTiming _timing)
  374. {
  375. if (_timing == EffectTiming.OnStartMainPhase)
  376. {
  377. return activateClass1;
  378. }
  379. return null;
  380. }
  381. }
  382. }
  383. }
  384. #endregion
  385. }
  386. }
  387. }
  388. #endregion
  389. #region Inherited Effect
  390. if (timing == EffectTiming.None)
  391. {
  392. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  393. changeValue: () => 1000,
  394. isInheritedEffect: true,
  395. card: card,
  396. condition: null));
  397. }
  398. #endregion
  399. return cardEffects;
  400. }
  401. }
  402. }