P_187.cs 26 KB

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