EX5_048.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.EX5
  5. {
  6. public class EX5_048 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. static bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.ContainsCardName("Sukamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Opponent's 1 Digimon gains DP -3000 and must attack", canUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] Until the end of your opponent's turn, 1 of your opponent's Digimon gets -3000 DP and gains \"[Start of Your Main Phase] This Digimon attacks.\"";
  28. }
  29. bool CanSelectPermanentCondition(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  32. }
  33. bool canUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. Permanent selectedPermanent = null;
  51. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  52. {
  53. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: maxCount,
  61. canNoSelect: false,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: SelectPermanentCoroutine,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage(
  68. $"Select 1 Digimon that will get DP -3000 and effects.",
  69. $"The opponent is selecting 1 Digimon that will get DP -3000 and effects.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  75. targetPermanent: permanent,
  76. changeValue: -3000,
  77. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  78. activateClass: activateClass));
  79. }
  80. if (selectedPermanent != null)
  81. {
  82. ActivateClass activateClass1 = new ActivateClass();
  83. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  84. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  85. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  86. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  87. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  90. }
  91. string EffectDiscription1()
  92. {
  93. return "[Start of Your Main Phase] Attack with this Digimon.";
  94. }
  95. bool CanUseCondition1(Hashtable hashtable1)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  98. {
  99. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  100. {
  101. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. bool CanActivateCondition1(Hashtable hashtable1)
  110. {
  111. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  112. {
  113. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  114. {
  115. if (selectedPermanent.CanAttack(activateClass1))
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  124. {
  125. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  126. {
  127. if (selectedPermanent.CanAttack(activateClass1))
  128. {
  129. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  130. selectAttackEffect.SetUp(
  131. attacker: selectedPermanent,
  132. canAttackPlayerCondition: () => true,
  133. defenderCondition: (permanent) => true,
  134. cardEffect: activateClass1);
  135. selectAttackEffect.SetCanNotSelectNotAttack();
  136. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  137. }
  138. }
  139. }
  140. ICardEffect GetCardEffect(EffectTiming _timing)
  141. {
  142. if (_timing == EffectTiming.OnStartMainPhase)
  143. {
  144. return activateClass1;
  145. }
  146. return null;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. if (timing == EffectTiming.OnEnterFieldAnyone)
  153. {
  154. ActivateClass activateClass = new ActivateClass();
  155. activateClass.SetUpICardEffect("Opponent's 1 Digimon gains DP -3000 and must attack", canUseCondition, card);
  156. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[When Digivolving] Until the end of your opponent's turn, 1 of your opponent's Digimon gets -3000 DP and gains \"[Start of Your Main Phase] This Digimon attacks.\"";
  161. }
  162. bool CanSelectPermanentCondition(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  165. }
  166. bool canUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. bool CanActivateCondition(Hashtable hashtable)
  171. {
  172. if (CardEffectCommons.IsExistOnBattleArea(card))
  173. {
  174. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  182. {
  183. Permanent selectedPermanent = null;
  184. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  185. {
  186. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  187. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  188. selectPermanentEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: CanSelectPermanentCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: maxCount,
  194. canNoSelect: false,
  195. canEndNotMax: false,
  196. selectPermanentCoroutine: SelectPermanentCoroutine,
  197. afterSelectPermanentCoroutine: null,
  198. mode: SelectPermanentEffect.Mode.Custom,
  199. cardEffect: activateClass);
  200. selectPermanentEffect.SetUpCustomMessage(
  201. $"Select 1 Digimon that will get DP -3000 and effects.",
  202. $"The opponent is selecting 1 Digimon that will get DP -3000 and effects.");
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  205. {
  206. selectedPermanent = permanent;
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  208. targetPermanent: permanent,
  209. changeValue: -3000,
  210. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  211. activateClass: activateClass));
  212. }
  213. if (selectedPermanent != null)
  214. {
  215. ActivateClass activateClass1 = new ActivateClass();
  216. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  217. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  218. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  219. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  220. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  223. }
  224. string EffectDiscription1()
  225. {
  226. return "[Start of Your Main Phase] Attack with this Digimon.";
  227. }
  228. bool CanUseCondition1(Hashtable hashtable1)
  229. {
  230. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  231. {
  232. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  233. {
  234. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  235. {
  236. return true;
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. bool CanActivateCondition1(Hashtable hashtable1)
  243. {
  244. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  245. {
  246. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  247. {
  248. if (selectedPermanent.CanAttack(activateClass1))
  249. {
  250. return true;
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  257. {
  258. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  259. {
  260. if (selectedPermanent.CanAttack(activateClass1))
  261. {
  262. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  263. selectAttackEffect.SetUp(
  264. attacker: selectedPermanent,
  265. canAttackPlayerCondition: () => true,
  266. defenderCondition: (permanent) => true,
  267. cardEffect: activateClass1);
  268. selectAttackEffect.SetCanNotSelectNotAttack();
  269. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  270. }
  271. }
  272. }
  273. ICardEffect GetCardEffect(EffectTiming _timing)
  274. {
  275. if (_timing == EffectTiming.OnStartMainPhase)
  276. {
  277. return activateClass1;
  278. }
  279. return null;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. if (timing == EffectTiming.OnAllyAttack)
  286. {
  287. ActivateClass activateClass = new ActivateClass();
  288. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  289. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  290. activateClass.SetHashString("Reveal_EX5_048");
  291. activateClass.SetIsInheritedEffect(true);
  292. cardEffects.Add(activateClass);
  293. string EffectDiscription()
  294. {
  295. return "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, you may reveal the top 3 cards of your deck. You may play 1 black or yellow Digimon with a play cost of 3 or less among them without paying the cost. Trash the rest.";
  296. }
  297. bool CanSelectCardCondition(CardSource cardSource)
  298. {
  299. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  300. {
  301. if (cardSource.IsDigimon)
  302. {
  303. if (cardSource.HasPlayCost)
  304. {
  305. if (cardSource.GetCostItself <= 3)
  306. {
  307. if (cardSource.HasCardColor(CardColor.Black))
  308. {
  309. return true;
  310. }
  311. if (cardSource.HasCardColor(CardColor.Yellow))
  312. {
  313. return true;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. return false;
  320. }
  321. bool PermanentCondition(Permanent permanent)
  322. {
  323. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  324. }
  325. bool CanUseCondition(Hashtable hashtable)
  326. {
  327. if (CardEffectCommons.IsExistOnBattleArea(card))
  328. {
  329. if (CardEffectCommons.IsOpponentTurn(card))
  330. {
  331. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  332. {
  333. return true;
  334. }
  335. }
  336. }
  337. return false;
  338. }
  339. bool CanActivateCondition(Hashtable hashtable)
  340. {
  341. if (CardEffectCommons.IsExistOnBattleArea(card))
  342. {
  343. if (card.Owner.LibraryCards.Count >= 1)
  344. {
  345. return true;
  346. }
  347. }
  348. return false;
  349. }
  350. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  351. {
  352. List<CardSource> selectedCards = new List<CardSource>();
  353. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  354. revealCount: 3,
  355. simplifiedSelectCardConditions:
  356. new SimplifiedSelectCardConditionClass[]
  357. {
  358. new SimplifiedSelectCardConditionClass(
  359. canTargetCondition:CanSelectCardCondition,
  360. message: "Select 1 black or yellow Digimon with a play cost of 3 or less.",
  361. mode: SelectCardEffect.Mode.Custom,
  362. maxCount: 1,
  363. selectCardCoroutine: SelectCardCoroutine),
  364. },
  365. remainingCardsPlace: RemainingCardsPlace.Trash,
  366. activateClass: activateClass,
  367. canNoSelect: true
  368. ));
  369. IEnumerator SelectCardCoroutine(CardSource cardSource)
  370. {
  371. selectedCards.Add(cardSource);
  372. yield return null;
  373. }
  374. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  375. cardSources: selectedCards,
  376. activateClass: activateClass,
  377. payCost: false,
  378. isTapped: false,
  379. root: SelectCardEffect.Root.Library,
  380. activateETB: true));
  381. }
  382. }
  383. return cardEffects;
  384. }
  385. }
  386. }