EX6_029.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_029 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ace - Blast DNA Digivolve
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. List<BlastDNACondition> blastDNAConditions = new List<BlastDNACondition>
  16. {
  17. new("Angewomon"),
  18. new("LadyDevimon")
  19. };
  20. cardEffects.Add(CardEffectFactory.BlastDNADigivolveEffect(card: card,
  21. blastDNAConditions: blastDNAConditions, condition: null));
  22. }
  23. #endregion
  24. #region DNA Digivolution
  25. if (timing == EffectTiming.None)
  26. {
  27. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  28. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  29. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  30. addJogressConditionClass.SetNotShowUI(true);
  31. cardEffects.Add(addJogressConditionClass);
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return true;
  35. }
  36. JogressCondition GetJogress(CardSource cardSource)
  37. {
  38. if (cardSource == card)
  39. {
  40. bool PermanentCondition1(Permanent permanent)
  41. {
  42. if (permanent != null)
  43. {
  44. if (permanent.TopCard != null)
  45. {
  46. if (permanent.TopCard.Owner == card.Owner)
  47. {
  48. if (permanent.IsDigimon)
  49. {
  50. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent,
  51. card))
  52. {
  53. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  54. {
  55. if (permanent.Levels_ForJogress(card).Contains(5))
  56. {
  57. return true;
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. bool PermanentCondition2(Permanent permanent)
  68. {
  69. if (permanent != null)
  70. {
  71. if (permanent.TopCard != null)
  72. {
  73. if (permanent.TopCard.Owner == card.Owner)
  74. {
  75. if (permanent.IsDigimon)
  76. {
  77. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent,
  78. card))
  79. {
  80. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  81. {
  82. if (permanent.Levels_ForJogress(card).Contains(5))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. JogressConditionElement[] elements =
  95. {
  96. new(PermanentCondition1, "a level 5 Yellow Digimon"),
  97. new(PermanentCondition2, "a level 5 Purple Digimon")
  98. };
  99. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  100. return jogressCondition;
  101. }
  102. return null;
  103. }
  104. }
  105. #endregion
  106. #region On Play/ When Digivolving Shared
  107. bool CanSelectPermanentSharedCondition(Permanent permanent)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  110. {
  111. if (permanent != card.PermanentOfThisCard())
  112. {
  113. if (permanent.IsDigimon)
  114. {
  115. if (!permanent.TopCard.Equals(card))
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. #endregion
  123. #region On Play
  124. if (timing == EffectTiming.OnEnterFieldAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect(
  128. "Play 1 level 5 or lower Digimon card with the [Angel]/[Archangel]/[Fallen Angel] trait from your hand or trash, then, if DNA digivolving, place 1 other Digimon at the bottom of its owner's security stack, and trash cards from the top of your opponent's security stack until it has 4 left.",
  129. CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  131. EffectDescription());
  132. cardEffects.Add(activateClass);
  133. string EffectDescription()
  134. {
  135. return
  136. "[On Play] You may play 1 level 5 or lower Digimon card with the [Angel]/[Archangel]/[Fallen Angel] trait from your hand or trash without paying the cost. Then, if DNA digivolving, place 1 other Digimon at the bottom of its owner's security stack, and trash cards from the top of your opponent's security stack until it has 4 left.";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  141. }
  142. bool IsCardAngelCondition(CardSource cardSource)
  143. {
  144. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  145. cardEffect: activateClass))
  146. {
  147. if (cardSource.IsDigimon)
  148. {
  149. if(cardSource.HasLevel && cardSource.Level <= 5)
  150. {
  151. if (cardSource.HasAngelTraits)
  152. {
  153. return true;
  154. }
  155. }
  156. }
  157. }
  158. return false;
  159. }
  160. bool CanActivateCondition(Hashtable hashtable)
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. if (card.Owner.HandCards.Count(IsCardAngelCondition) >= 1)
  165. {
  166. return true;
  167. }
  168. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardAngelCondition))
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. IEnumerator ActivateCoroutine(Hashtable hashtable)
  176. {
  177. bool canSelectHand = card.Owner.HandCards.Count(IsCardAngelCondition) >= 1;
  178. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardAngelCondition);
  179. if (canSelectHand || canSelectTrash)
  180. {
  181. if (canSelectHand && canSelectTrash)
  182. {
  183. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  184. {
  185. new(message: "From hand", value: true, spriteIndex: 0),
  186. new(message: "From trash", value: false, spriteIndex: 1),
  187. };
  188. string selectPlayerMessage = "From which area do you play a card?";
  189. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  190. GManager.instance.userSelectionManager.SetBoolSelection(
  191. selectionElements: selectionElements, selectPlayer: card.Owner,
  192. selectPlayerMessage: selectPlayerMessage,
  193. notSelectPlayerMessage: notSelectPlayerMessage);
  194. }
  195. else
  196. {
  197. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  198. }
  199. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  200. .WaitForEndSelect());
  201. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  202. List<CardSource> selectedCards = new List<CardSource>();
  203. IEnumerator SelectCardCoroutine(CardSource cardSource)
  204. {
  205. selectedCards.Add(cardSource);
  206. yield return null;
  207. }
  208. if (fromHand)
  209. {
  210. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  211. selectHandEffect.SetUp(
  212. selectPlayer: card.Owner,
  213. canTargetCondition: IsCardAngelCondition,
  214. canTargetCondition_ByPreSelecetedList: null,
  215. canEndSelectCondition: null,
  216. maxCount: 1,
  217. canNoSelect: true,
  218. canEndNotMax: false,
  219. isShowOpponent: true,
  220. selectCardCoroutine: SelectCardCoroutine,
  221. afterSelectCardCoroutine: null,
  222. mode: SelectHandEffect.Mode.Custom,
  223. cardEffect: activateClass);
  224. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  225. "The opponent is selecting 1 card to play.");
  226. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  227. yield return StartCoroutine(selectHandEffect.Activate());
  228. }
  229. else
  230. {
  231. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  232. selectCardEffect.SetUp(
  233. canTargetCondition: IsCardAngelCondition,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. canNoSelect: () => true,
  237. selectCardCoroutine: SelectCardCoroutine,
  238. afterSelectCardCoroutine: null,
  239. message: "Select 1 card to play.",
  240. maxCount: 1,
  241. canEndNotMax: false,
  242. isShowOpponent: true,
  243. mode: SelectCardEffect.Mode.Custom,
  244. root: SelectCardEffect.Root.Trash,
  245. customRootCardList: null,
  246. canLookReverseCard: true,
  247. selectPlayer: card.Owner,
  248. cardEffect: activateClass);
  249. selectCardEffect.SetUpCustomMessage("Select 1 card to play.",
  250. "The opponent is selecting 1 card to play.");
  251. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  252. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  253. }
  254. SelectCardEffect.Root root =
  255. (fromHand) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  257. cardSources: selectedCards,
  258. activateClass: activateClass,
  259. payCost: false,
  260. isTapped: false,
  261. root: root,
  262. activateETB: true));
  263. }
  264. if (CardEffectCommons.IsJogress(hashtable))
  265. {
  266. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  267. {
  268. int maxCount = Math.Min(1,
  269. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition));
  270. SelectPermanentEffect selectPermanentEffect =
  271. GManager.instance.GetComponent<SelectPermanentEffect>();
  272. selectPermanentEffect.SetUp(
  273. selectPlayer: card.Owner,
  274. canTargetCondition: CanSelectPermanentSharedCondition,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. maxCount: maxCount,
  278. canNoSelect: false,
  279. canEndNotMax: false,
  280. selectPermanentCoroutine: SelectPermanentCoroutine,
  281. afterSelectPermanentCoroutine: null,
  282. mode: SelectPermanentEffect.Mode.Custom,
  283. cardEffect: activateClass);
  284. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place on bottom of security.",
  285. "The opponent is selecting 1 Digimon to place on bottom of security.");
  286. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  287. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  288. {
  289. if (permanent.TopCard != null)
  290. {
  291. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  292. {
  293. yield return ContinuousController.instance.StartCoroutine(
  294. new IPutSecurityPermanent(
  295. permanent,
  296. CardEffectCommons.CardEffectHashtable(activateClass),
  297. toTop: false).PutSecurity());
  298. }
  299. }
  300. }
  301. }
  302. if (card.Owner.Enemy.SecurityCards.Count > 4)
  303. {
  304. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  305. player: card.Owner.Enemy,
  306. destroySecurityCount: card.Owner.Enemy.SecurityCards.Count - 4,
  307. cardEffect: activateClass,
  308. fromTop: true).DestroySecurity());
  309. }
  310. }
  311. }
  312. }
  313. #endregion
  314. #region When Digivolving
  315. if (timing == EffectTiming.OnEnterFieldAnyone)
  316. {
  317. ActivateClass activateClass = new ActivateClass();
  318. activateClass.SetUpICardEffect(
  319. "Play 1 level 5 or lower Digimon card with the [Angel]/[Archangel]/[Fallen Angel] trait from your hand or trash, then, if DNA digivolving, place 1 other Digimon at the bottom of its owner's security stack, and trash cards from the top of your opponent's security stack until it has 4 left.",
  320. CanUseCondition, card);
  321. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  322. EffectDescription());
  323. cardEffects.Add(activateClass);
  324. string EffectDescription()
  325. {
  326. return
  327. "[When Digivolving] You may play 1 level 5 or lower Digimon card with the [Angel]/[Archangel]/[Fallen Angel] trait from your hand or trash without paying the cost. Then, if DNA digivolving, place 1 other Digimon at the bottom of its owner's security stack, and trash cards from the top of your opponent's security stack until it has 4 left.";
  328. }
  329. bool CanUseCondition(Hashtable hashtable)
  330. {
  331. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  332. }
  333. bool IsCardAngelCondition(CardSource cardSource)
  334. {
  335. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  336. cardEffect: activateClass))
  337. {
  338. if (cardSource.IsDigimon)
  339. {
  340. if (cardSource.HasLevel && cardSource.Level <= 5)
  341. {
  342. if (cardSource.HasAngelTraits)
  343. {
  344. return true;
  345. }
  346. }
  347. }
  348. }
  349. return false;
  350. }
  351. bool CanActivateCondition(Hashtable hashtable)
  352. {
  353. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  354. }
  355. IEnumerator ActivateCoroutine(Hashtable hashtable)
  356. {
  357. bool canSelectHand = card.Owner.HandCards.Count(IsCardAngelCondition) >= 1;
  358. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsCardAngelCondition);
  359. if (canSelectHand || canSelectTrash)
  360. {
  361. if (canSelectHand && canSelectTrash)
  362. {
  363. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  364. {
  365. new(message: "From hand", value: true, spriteIndex: 0),
  366. new(message: "From trash", value: false, spriteIndex: 1),
  367. };
  368. string selectPlayerMessage = "From which area do you play a card?";
  369. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  370. GManager.instance.userSelectionManager.SetBoolSelection(
  371. selectionElements: selectionElements, selectPlayer: card.Owner,
  372. selectPlayerMessage: selectPlayerMessage,
  373. notSelectPlayerMessage: notSelectPlayerMessage);
  374. }
  375. else
  376. {
  377. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  378. }
  379. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  380. .WaitForEndSelect());
  381. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  382. List<CardSource> selectedCards = new List<CardSource>();
  383. IEnumerator SelectCardCoroutine(CardSource cardSource)
  384. {
  385. selectedCards.Add(cardSource);
  386. yield return null;
  387. }
  388. if (fromHand)
  389. {
  390. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  391. selectHandEffect.SetUp(
  392. selectPlayer: card.Owner,
  393. canTargetCondition: IsCardAngelCondition,
  394. canTargetCondition_ByPreSelecetedList: null,
  395. canEndSelectCondition: null,
  396. maxCount: 1,
  397. canNoSelect: true,
  398. canEndNotMax: false,
  399. isShowOpponent: true,
  400. selectCardCoroutine: SelectCardCoroutine,
  401. afterSelectCardCoroutine: null,
  402. mode: SelectHandEffect.Mode.Custom,
  403. cardEffect: activateClass);
  404. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  405. "The opponent is selecting 1 card to play.");
  406. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  407. yield return StartCoroutine(selectHandEffect.Activate());
  408. }
  409. else
  410. {
  411. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  412. selectCardEffect.SetUp(
  413. canTargetCondition: IsCardAngelCondition,
  414. canTargetCondition_ByPreSelecetedList: null,
  415. canEndSelectCondition: null,
  416. canNoSelect: () => true,
  417. selectCardCoroutine: SelectCardCoroutine,
  418. afterSelectCardCoroutine: null,
  419. message: "Select 1 card to play.",
  420. maxCount: 1,
  421. canEndNotMax: false,
  422. isShowOpponent: true,
  423. mode: SelectCardEffect.Mode.Custom,
  424. root: SelectCardEffect.Root.Trash,
  425. customRootCardList: null,
  426. canLookReverseCard: true,
  427. selectPlayer: card.Owner,
  428. cardEffect: activateClass);
  429. selectCardEffect.SetUpCustomMessage("Select 1 card to play.",
  430. "The opponent is selecting 1 card to play.");
  431. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  432. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  433. }
  434. SelectCardEffect.Root root =
  435. (fromHand) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  436. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  437. cardSources: selectedCards,
  438. activateClass: activateClass,
  439. payCost: false,
  440. isTapped: false,
  441. root: root,
  442. activateETB: true));
  443. }
  444. if (CardEffectCommons.IsJogress(hashtable))
  445. {
  446. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  447. {
  448. int maxCount = Math.Min(1,
  449. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentSharedCondition));
  450. SelectPermanentEffect selectPermanentEffect =
  451. GManager.instance.GetComponent<SelectPermanentEffect>();
  452. selectPermanentEffect.SetUp(
  453. selectPlayer: card.Owner,
  454. canTargetCondition: CanSelectPermanentSharedCondition,
  455. canTargetCondition_ByPreSelecetedList: null,
  456. canEndSelectCondition: null,
  457. maxCount: maxCount,
  458. canNoSelect: false,
  459. canEndNotMax: false,
  460. selectPermanentCoroutine: SelectPermanentCoroutine,
  461. afterSelectPermanentCoroutine: null,
  462. mode: SelectPermanentEffect.Mode.Custom,
  463. cardEffect: activateClass);
  464. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place on bottom of security.",
  465. "The opponent is selecting 1 Digimon to place on bottom of security.");
  466. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  467. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  468. {
  469. if (permanent != null)
  470. {
  471. if (permanent.TopCard != null)
  472. {
  473. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  474. {
  475. yield return ContinuousController.instance.StartCoroutine(
  476. new IPutSecurityPermanent(
  477. permanent,
  478. CardEffectCommons.CardEffectHashtable(activateClass),
  479. toTop: false).PutSecurity());
  480. }
  481. }
  482. }
  483. }
  484. }
  485. if (card.Owner.Enemy.SecurityCards.Count > 4)
  486. {
  487. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  488. player: card.Owner.Enemy,
  489. destroySecurityCount: card.Owner.Enemy.SecurityCards.Count - 4,
  490. cardEffect: activateClass,
  491. fromTop: true).DestroySecurity());
  492. }
  493. }
  494. }
  495. }
  496. #endregion
  497. return cardEffects;
  498. }
  499. }
  500. }