EX2_055.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX2
  5. {
  6. public class EX2_055 : 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.BeforePayCost)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Trash digivolution cards from [Mother D-Reaper] to make play cost 0", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. activateClass.SetHashString("PlayCost0_EX2_055");
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "When you would play this Digimon, you may trash 7 or more digivolution cards from the bottom of 1 of your [Mother D-Reaper]s to set this Digimon's play cost to 0.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  25. {
  26. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  27. {
  28. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 7)
  29. {
  30. if (permanent.TopCard.CardNames.Contains("Mother D-Reaper"))
  31. {
  32. return true;
  33. }
  34. if (permanent.TopCard.CardNames.Contains("MotherD-Reaper"))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CardCondition(CardSource cardSource)
  44. {
  45. return cardSource == card;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. return true;
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  62. {
  63. bool CanNoSelect = true;
  64. int maxCount = 1;
  65. Permanent selectedPermanent = null;
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: CanNoSelect,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage("Select 1 [Mother D-Reaper].", "The opponent is selecting 1 [Mother D-Reaper].");
  80. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  81. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  82. {
  83. selectedPermanent = permanent;
  84. yield return null;
  85. }
  86. if (selectedPermanent != null)
  87. {
  88. maxCount = selectedPermanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass));
  89. if (maxCount >= 7)
  90. {
  91. int trashCount = maxCount;
  92. SelectCountEffect selectCountEffect = GManager.instance.GetComponent<SelectCountEffect>();
  93. List<int> trashCountList = new List<int>();
  94. for (int i = 0; i < maxCount + 1; i++)
  95. {
  96. if (i >= 7)
  97. {
  98. int k = i;
  99. trashCountList.Add(k);
  100. }
  101. }
  102. if (selectCountEffect != null)
  103. {
  104. selectCountEffect.SetUp(
  105. SelectPlayer: card.Owner,
  106. targetPermanent: null,
  107. MaxCount: 1,
  108. CanNoSelect: false,
  109. Message: "How many digivolution cards will you trash?",
  110. Message_Enemy: "The opponent is choosing how many digivolution cards to trash.",
  111. SelectCountCoroutine: SelectCountCoroutine);
  112. selectCountEffect.SetCandidates(trashCountList);
  113. selectCountEffect.SetPreferMin(true);
  114. yield return ContinuousController.instance.StartCoroutine(selectCountEffect.Activate());
  115. IEnumerator SelectCountCoroutine(int count)
  116. {
  117. trashCount = count;
  118. yield return null;
  119. }
  120. if (trashCount >= 7)
  121. {
  122. List<CardSource> trashCards = new List<CardSource>();
  123. List<CardSource> digivolutionCards_reverse = selectedPermanent.DigivolutionCards.Clone();
  124. digivolutionCards_reverse.Reverse();
  125. for (int i = 0; i < trashCount; i++)
  126. {
  127. foreach (CardSource cardSource in digivolutionCards_reverse)
  128. {
  129. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  130. {
  131. if (!trashCards.Contains(cardSource))
  132. {
  133. trashCards.Add(cardSource);
  134. break;
  135. }
  136. }
  137. }
  138. }
  139. if (trashCards.Count >= 1)
  140. {
  141. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
  142. selectedPermanent,
  143. trashCards,
  144. activateClass).TrashDigivolutionCards());
  145. if (trashCards.Count >= 7)
  146. {
  147. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  148. ChangeCostClass changeCostClass = new ChangeCostClass();
  149. changeCostClass.SetUpICardEffect("Play Cost -12", CanUseCondition1, card);
  150. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  151. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  152. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  153. bool CanUseCondition1(Hashtable hashtable)
  154. {
  155. return true;
  156. }
  157. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  158. {
  159. if (CardSourceCondition(cardSource))
  160. {
  161. if (RootCondition(root))
  162. {
  163. if (PermanentsCondition(targetPermanents))
  164. {
  165. Cost = 0;
  166. }
  167. }
  168. }
  169. return Cost;
  170. }
  171. bool PermanentsCondition(List<Permanent> targetPermanents)
  172. {
  173. if (targetPermanents == null)
  174. {
  175. return true;
  176. }
  177. else
  178. {
  179. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool CardSourceCondition(CardSource cardSource)
  187. {
  188. return cardSource == card;
  189. }
  190. bool RootCondition(SelectCardEffect.Root root)
  191. {
  192. return true;
  193. }
  194. bool isUpDown()
  195. {
  196. return false;
  197. }
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. if (timing == EffectTiming.None)
  208. {
  209. ChangeCostClass changeCostClass = new ChangeCostClass();
  210. changeCostClass.SetUpICardEffect("Play Cost is 0", CanUseCondition, card);
  211. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  212. changeCostClass.SetNotShowUI(true);
  213. cardEffects.Add(changeCostClass);
  214. bool CanSelectPermanentCondition(Permanent permanent)
  215. {
  216. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("", (hashtable) => true, card);
  220. if (activateClass != null)
  221. {
  222. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 7)
  223. {
  224. if (permanent.TopCard.CardNames.Contains("Mother D-Reaper"))
  225. {
  226. return true;
  227. }
  228. if (permanent.TopCard.CardNames.Contains("MotherD-Reaper"))
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. }
  235. return false;
  236. }
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. if (!card.Owner.isYou && GManager.instance.IsAI)
  240. {
  241. return false;
  242. }
  243. if (card.Owner.GetBattleAreaPermanents().Some(CanSelectPermanentCondition))
  244. {
  245. return true;
  246. }
  247. return false;
  248. }
  249. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  250. {
  251. if (CardSourceCondition(cardSource))
  252. {
  253. if (RootCondition(root))
  254. {
  255. if (PermanentsCondition(targetPermanents))
  256. {
  257. Cost = 0;
  258. }
  259. }
  260. }
  261. return Cost;
  262. }
  263. bool PermanentsCondition(List<Permanent> targetPermanents)
  264. {
  265. if (targetPermanents == null)
  266. {
  267. return true;
  268. }
  269. else
  270. {
  271. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  272. {
  273. return true;
  274. }
  275. }
  276. return false;
  277. }
  278. bool CardSourceCondition(CardSource cardSource)
  279. {
  280. return cardSource == card;
  281. }
  282. bool RootCondition(SelectCardEffect.Root root)
  283. {
  284. return true;
  285. }
  286. bool isUpDown()
  287. {
  288. return false;
  289. }
  290. }
  291. if (timing == EffectTiming.None)
  292. {
  293. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  294. }
  295. if (timing == EffectTiming.OnAllyAttack)
  296. {
  297. ActivateClass activateClass = new ActivateClass();
  298. activateClass.SetUpICardEffect("Place 2 [ADR-02 Searcher] under this Digimon from trash to unsuspend this Digimon", CanUseCondition, card);
  299. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  300. cardEffects.Add(activateClass);
  301. string EffectDiscription()
  302. {
  303. return "[When Attacking] You may place 2 [ADR-02 Searcher]s from your trash under this Digimon in any order as its bottom digivolution cards to unsuspend this Digimon.";
  304. }
  305. bool CanSelectCardCondition(CardSource cardSource)
  306. {
  307. if (!cardSource.IsToken)
  308. {
  309. if (cardSource.CardNames.Contains("ADR-02 Searcher"))
  310. {
  311. return true;
  312. }
  313. if (cardSource.CardNames.Contains("ADR-02Searcher"))
  314. {
  315. return true;
  316. }
  317. }
  318. return false;
  319. }
  320. bool CanUseCondition(Hashtable hashtable)
  321. {
  322. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  323. }
  324. bool CanActivateCondition(Hashtable hashtable)
  325. {
  326. if (CardEffectCommons.IsExistOnBattleArea(card))
  327. {
  328. if (!card.PermanentOfThisCard().IsToken)
  329. {
  330. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  331. {
  332. return true;
  333. }
  334. }
  335. }
  336. return false;
  337. }
  338. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  339. {
  340. if (isExistOnField(card))
  341. {
  342. if (CardEffectCommons.IsExistOnBattleArea(card))
  343. {
  344. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  345. {
  346. List<CardSource> selectedCards = new List<CardSource>();
  347. int maxCount = 2;
  348. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  349. selectCardEffect.SetUp(
  350. canTargetCondition: CanSelectCardCondition,
  351. canTargetCondition_ByPreSelecetedList: null,
  352. canEndSelectCondition: null,
  353. canNoSelect: () => true,
  354. selectCardCoroutine: SelectCardCoroutine,
  355. afterSelectCardCoroutine: null,
  356. message: "Select cards to place in Digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  357. maxCount: maxCount,
  358. canEndNotMax: false,
  359. isShowOpponent: true,
  360. mode: SelectCardEffect.Mode.Custom,
  361. root: SelectCardEffect.Root.Trash,
  362. customRootCardList: null,
  363. canLookReverseCard: true,
  364. selectPlayer: card.Owner,
  365. cardEffect: activateClass);
  366. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  367. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  368. IEnumerator SelectCardCoroutine(CardSource cardSource)
  369. {
  370. selectedCards.Add(cardSource);
  371. yield return null;
  372. }
  373. if (selectedCards.Count >= 1)
  374. {
  375. if (CardEffectCommons.IsExistOnBattleArea(card))
  376. {
  377. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().
  378. AddDigivolutionCardsBottom(
  379. selectedCards,
  380. activateClass));
  381. if (selectedCards.Count == 2)
  382. {
  383. Permanent selectedPermanent = card.PermanentOfThisCard();
  384. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  385. new List<Permanent>() { selectedPermanent },
  386. activateClass).Unsuspend());
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. }
  395. return cardEffects;
  396. }
  397. }
  398. }