P_187.cs 26 KB

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