P_187.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. if (selectedPermanent.TopCard.Owner.CanAddSecurity(activateClass))
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(selectedPermanent, CardEffectCommons.CardEffectHashtable(activateClass), toTop: position).PutSecurity());
  175. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  176. player: card.Owner.Enemy,
  177. destroySecurityCount: 1,
  178. cardEffect: activateClass,
  179. fromTop: true).DestroySecurity());
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. #endregion
  187. #region When Digivolving OPT
  188. if (timing == EffectTiming.OnEnterFieldAnyone)
  189. {
  190. ActivateClass activateClass = new ActivateClass();
  191. activateClass.SetUpICardEffect("Trash top security to play a digimon", CanUseCondition, card);
  192. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  193. activateClass.SetHashString("PlayDigimon_P_187");
  194. cardEffects.Add(activateClass);
  195. string EffectDiscription()
  196. => "[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.";
  197. bool CanUseCondition(Hashtable hashtable)
  198. {
  199. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  200. {
  201. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  202. {
  203. return true;
  204. }
  205. }
  206. return false;
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  211. {
  212. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. bool CanSelectCardCondition(CardSource cardSource)
  220. {
  221. if (cardSource.IsDigimon)
  222. {
  223. if (cardSource.CardColors.Contains(CardColor.Purple) || cardSource.CardColors.Contains(CardColor.Yellow))
  224. {
  225. if (cardSource.CardDP <= 6000)
  226. {
  227. return true;
  228. }
  229. }
  230. }
  231. return false;
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable hashtable)
  234. {
  235. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  236. player: card.Owner,
  237. destroySecurityCount: 1,
  238. cardEffect: activateClass,
  239. fromTop: true).DestroySecurity());
  240. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  241. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  242. SelectCardEffect.Root root = SelectCardEffect.Root.None;
  243. if (canSelectHand && !canSelectTrash) root = SelectCardEffect.Root.Hand;
  244. if (!canSelectHand && canSelectTrash) root = SelectCardEffect.Root.Trash;
  245. if (canSelectHand && canSelectTrash)
  246. {
  247. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  248. {
  249. new SelectionElement<bool>(message: $"From Hand", value : true, spriteIndex: 0),
  250. new SelectionElement<bool>(message: $"From Trash", value : false, spriteIndex: 1),
  251. };
  252. string selectPlayerMessage = "Which location do you choose?";
  253. string notSelectPlayerMessage = "The opponent is choosing the location.";
  254. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  255. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  256. root = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  257. }
  258. if (root == SelectCardEffect.Root.Hand || root == SelectCardEffect.Root.Trash)
  259. {
  260. CardSource selectedCard = null;
  261. IEnumerator SelectCardCoroutine(CardSource cardSource)
  262. {
  263. selectedCard = cardSource;
  264. yield return null;
  265. }
  266. if (root == SelectCardEffect.Root.Hand)
  267. {
  268. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  269. selectHandEffect.SetUp(
  270. selectPlayer: card.Owner,
  271. canTargetCondition: CanSelectCardCondition,
  272. canTargetCondition_ByPreSelecetedList: null,
  273. canEndSelectCondition: null,
  274. maxCount: 1,
  275. canNoSelect: true,
  276. canEndNotMax: false,
  277. isShowOpponent: true,
  278. selectCardCoroutine: SelectCardCoroutine,
  279. afterSelectCardCoroutine: null,
  280. mode: SelectHandEffect.Mode.Custom,
  281. cardEffect: activateClass);
  282. selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  283. yield return StartCoroutine(selectHandEffect.Activate());
  284. }
  285. else
  286. {
  287. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  288. selectCardEffect.SetUp(
  289. canTargetCondition: CanSelectCardCondition,
  290. canTargetCondition_ByPreSelecetedList: null,
  291. canEndSelectCondition: null,
  292. canNoSelect: () => true,
  293. selectCardCoroutine: SelectCardCoroutine,
  294. afterSelectCardCoroutine: null,
  295. message: "Select 1 card to play",
  296. maxCount: 1,
  297. canEndNotMax: false,
  298. isShowOpponent: true,
  299. mode: SelectCardEffect.Mode.Custom,
  300. root: SelectCardEffect.Root.Trash,
  301. customRootCardList: null,
  302. canLookReverseCard: true,
  303. selectPlayer: card.Owner,
  304. cardEffect: activateClass);
  305. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  306. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  307. }
  308. if (selectedCard != null)
  309. {
  310. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  311. }
  312. }
  313. }
  314. }
  315. #endregion
  316. #region When Attacking OPT
  317. if (timing == EffectTiming.OnAllyAttack)
  318. {
  319. ActivateClass activateClass = new ActivateClass();
  320. activateClass.SetUpICardEffect("Trash top security to play a digimon", CanUseCondition, card);
  321. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  322. activateClass.SetHashString("PlayDigimon_P_187");
  323. cardEffects.Add(activateClass);
  324. string EffectDiscription()
  325. => "[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.";
  326. bool CanUseCondition(Hashtable hashtable)
  327. {
  328. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  329. {
  330. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  331. {
  332. return true;
  333. }
  334. }
  335. return false;
  336. }
  337. bool CanActivateCondition(Hashtable hashtable)
  338. {
  339. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  340. {
  341. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  342. {
  343. return true;
  344. }
  345. }
  346. return false;
  347. }
  348. bool CanSelectCardCondition(CardSource cardSource)
  349. {
  350. if (cardSource.IsDigimon)
  351. {
  352. if (cardSource.CardColors.Contains(CardColor.Purple) || cardSource.CardColors.Contains(CardColor.Yellow))
  353. {
  354. if (cardSource.CardDP <= 6000)
  355. {
  356. return true;
  357. }
  358. }
  359. }
  360. return false;
  361. }
  362. IEnumerator ActivateCoroutine(Hashtable hashtable)
  363. {
  364. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  365. player: card.Owner,
  366. destroySecurityCount: 1,
  367. cardEffect: activateClass,
  368. fromTop: true).DestroySecurity());
  369. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  370. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  371. SelectCardEffect.Root root = SelectCardEffect.Root.None;
  372. if (canSelectHand && !canSelectTrash) root = SelectCardEffect.Root.Hand;
  373. if (!canSelectHand && canSelectTrash) root = SelectCardEffect.Root.Trash;
  374. if (canSelectHand && canSelectTrash)
  375. {
  376. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  377. {
  378. new SelectionElement<bool>(message: $"From Hand", value : true, spriteIndex: 0),
  379. new SelectionElement<bool>(message: $"From Trash", value : false, spriteIndex: 1),
  380. };
  381. string selectPlayerMessage = "Which location do you choose?";
  382. string notSelectPlayerMessage = "The opponent is choosing the location.";
  383. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  384. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  385. root = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  386. }
  387. if (root == SelectCardEffect.Root.Hand || root == SelectCardEffect.Root.Trash)
  388. {
  389. CardSource selectedCard = null;
  390. IEnumerator SelectCardCoroutine(CardSource cardSource)
  391. {
  392. selectedCard = cardSource;
  393. yield return null;
  394. }
  395. if (root == SelectCardEffect.Root.Hand)
  396. {
  397. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  398. selectHandEffect.SetUp(
  399. selectPlayer: card.Owner,
  400. canTargetCondition: CanSelectCardCondition,
  401. canTargetCondition_ByPreSelecetedList: null,
  402. canEndSelectCondition: null,
  403. maxCount: 1,
  404. canNoSelect: true,
  405. canEndNotMax: false,
  406. isShowOpponent: true,
  407. selectCardCoroutine: SelectCardCoroutine,
  408. afterSelectCardCoroutine: null,
  409. mode: SelectHandEffect.Mode.Custom,
  410. cardEffect: activateClass);
  411. selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  412. yield return StartCoroutine(selectHandEffect.Activate());
  413. }
  414. else
  415. {
  416. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  417. selectCardEffect.SetUp(
  418. canTargetCondition: CanSelectCardCondition,
  419. canTargetCondition_ByPreSelecetedList: null,
  420. canEndSelectCondition: null,
  421. canNoSelect: () => true,
  422. selectCardCoroutine: SelectCardCoroutine,
  423. afterSelectCardCoroutine: null,
  424. message: "Select 1 card to play",
  425. maxCount: 1,
  426. canEndNotMax: false,
  427. isShowOpponent: true,
  428. mode: SelectCardEffect.Mode.Custom,
  429. root: SelectCardEffect.Root.Trash,
  430. customRootCardList: null,
  431. canLookReverseCard: true,
  432. selectPlayer: card.Owner,
  433. cardEffect: activateClass);
  434. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  435. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  436. }
  437. if (selectedCard != null)
  438. {
  439. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  440. }
  441. }
  442. }
  443. }
  444. #endregion
  445. return cardEffects;
  446. }
  447. }
  448. }