EX4_049.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX4
  8. {
  9. public class EX4_049 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.CardNames.Contains("WereGarurumon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Choose 1 effect", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] Activate 1 of the effects below. -Choose any number of your opponent's Digimon so that their play cost total is up to 6 and return them to the bottom of the deck. -1 of your other Digimon digivolves into a level 6 or lower Digimon card with [Greymon] in its name in your hand without paying the cost. -This Digimon and one of your other Digimon may DNA digivolve into a Digimon card in your hand for the cost.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. if (isExistOnField(card))
  47. {
  48. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  49. {
  50. yield return GManager.instance.photonWaitController.StartWait("Kuresgarurumon_Select_ETB");
  51. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  52. {
  53. new SelectionElement<int>(message: $"Deck Bounce", value : 0, spriteIndex: 0),
  54. new SelectionElement<int>(message: $"Your other 1 Digimon digivolves", value : 1, spriteIndex: 0),
  55. new SelectionElement<int>(message: $"DNA Digivolution", value : 2, spriteIndex: 0),
  56. };
  57. string selectPlayerMessage = "Which effect will you activate?";
  58. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  59. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  61. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  62. switch (actionID)
  63. {
  64. case 0:
  65. bool CanSelectPermanentCondition(Permanent permanent)
  66. {
  67. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  68. {
  69. if (permanent.TopCard.GetCostItself <= 6)
  70. {
  71. if (permanent.TopCard.HasPlayCost)
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  80. {
  81. List<Permanent> selectedPermanents = new List<Permanent>();
  82. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition);
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition,
  87. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  88. canEndSelectCondition: CanEndSelectCondition,
  89. maxCount: maxCount,
  90. canNoSelect: false,
  91. canEndNotMax: true,
  92. selectPermanentCoroutine: SelectPermanentCoroutine,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermanents.Add(permanent);
  100. yield return null;
  101. }
  102. bool CanEndSelectCondition(List<Permanent> permanents)
  103. {
  104. if (permanents.Count <= 0)
  105. {
  106. return false;
  107. }
  108. int sumCost = 0;
  109. foreach (Permanent permanent1 in permanents)
  110. {
  111. sumCost += permanent1.TopCard.GetCostItself;
  112. }
  113. if (sumCost > 6)
  114. {
  115. return false;
  116. }
  117. return true;
  118. }
  119. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  120. {
  121. int sumCost = 0;
  122. foreach (Permanent permanent1 in permanents)
  123. {
  124. sumCost += permanent1.TopCard.GetCostItself;
  125. }
  126. sumCost += permanent.TopCard.GetCostItself;
  127. if (sumCost > 6)
  128. {
  129. return false;
  130. }
  131. return true;
  132. }
  133. if (selectedPermanents.Count >= 1)
  134. {
  135. Hashtable hashtable = new Hashtable();
  136. hashtable.Add("CardEffect", activateClass);
  137. if (selectedPermanents.Count == 1)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(selectedPermanents, hashtable).DeckBounce());
  140. }
  141. else
  142. {
  143. List<CardSource> cardSources = new List<CardSource>();
  144. foreach (Permanent permanent in selectedPermanents)
  145. {
  146. cardSources.Add(permanent.TopCard);
  147. }
  148. List<SkillInfo> skillInfos = new List<SkillInfo>();
  149. foreach (CardSource cardSource in cardSources)
  150. {
  151. ICardEffect cardEffect = new ChangeBaseDPClass();
  152. cardEffect.SetUpICardEffect(" ", null, cardSource);
  153. skillInfos.Add(new SkillInfo(cardEffect, null, EffectTiming.None));
  154. }
  155. List<CardSource> selectedCards = new List<CardSource>();
  156. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  157. selectCardEffect.SetUp(
  158. canTargetCondition: (cardSource) => true,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. canNoSelect: () => false,
  162. selectCardCoroutine: null,
  163. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  164. message: "Specify the order to place the card at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  165. maxCount: cardSources.Count,
  166. canEndNotMax: false,
  167. isShowOpponent: false,
  168. mode: SelectCardEffect.Mode.Custom,
  169. root: SelectCardEffect.Root.Custom,
  170. customRootCardList: cardSources,
  171. canLookReverseCard: true,
  172. selectPlayer: card.Owner,
  173. cardEffect: activateClass);
  174. selectCardEffect.SetNotShowCard();
  175. selectCardEffect.SetNotAddLog();
  176. selectCardEffect.SetUpSkillInfos(skillInfos);
  177. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  178. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  179. {
  180. if (cardSources.Count >= 1)
  181. {
  182. foreach (CardSource cardSource in cardSources)
  183. {
  184. selectedCards.Add(cardSource);
  185. }
  186. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  187. }
  188. }
  189. if (selectedCards.Count >= 1)
  190. {
  191. List<Permanent> libraryPermanets = new List<Permanent>();
  192. foreach (CardSource cardSource in selectedCards)
  193. {
  194. libraryPermanets.Add(cardSource.PermanentOfThisCard());
  195. }
  196. if (libraryPermanets.Count >= 1)
  197. {
  198. DeckBottomBounceClass putLibraryBottomPermanent = new DeckBottomBounceClass(libraryPermanets, hashtable);
  199. putLibraryBottomPermanent.SetNotShowCards();
  200. yield return ContinuousController.instance.StartCoroutine(putLibraryBottomPermanent.DeckBounce());
  201. }
  202. }
  203. }
  204. }
  205. }
  206. break;
  207. case 1:
  208. bool CanSelectPermanentCondition1(Permanent permanent)
  209. {
  210. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  211. {
  212. if (permanent != card.PermanentOfThisCard())
  213. {
  214. foreach (CardSource cardSource in card.Owner.HandCards)
  215. {
  216. if (CanSelectCardCondition(cardSource))
  217. {
  218. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  219. {
  220. return true;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. return false;
  227. }
  228. bool CanSelectCardCondition(CardSource cardSource)
  229. {
  230. return cardSource.IsDigimon && cardSource.HasGreymonName && cardSource.Level <= 6 && cardSource.HasLevel;
  231. }
  232. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  233. {
  234. Permanent selectedPermanent = null;
  235. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  236. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  237. selectPermanentEffect.SetUp(
  238. selectPlayer: card.Owner,
  239. canTargetCondition: CanSelectPermanentCondition1,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. maxCount: maxCount,
  243. canNoSelect: true,
  244. canEndNotMax: false,
  245. selectPermanentCoroutine: SelectPermanentCoroutine,
  246. afterSelectPermanentCoroutine: null,
  247. mode: SelectPermanentEffect.Mode.Custom,
  248. cardEffect: activateClass);
  249. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  250. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  251. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  252. {
  253. selectedPermanent = permanent;
  254. yield return null;
  255. }
  256. if (selectedPermanent != null)
  257. {
  258. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  259. targetPermanent: selectedPermanent,
  260. cardCondition: CanSelectCardCondition,
  261. payCost: false,
  262. reduceCostTuple: null,
  263. fixedCostTuple: null,
  264. ignoreDigivolutionRequirementFixedCost: -1,
  265. isHand: true,
  266. activateClass: activateClass,
  267. successProcess: null));
  268. }
  269. }
  270. break;
  271. case 2:
  272. bool CanSelectCardCondition1(CardSource cardSource)
  273. {
  274. if (cardSource != null)
  275. {
  276. if (cardSource.IsDigimon)
  277. {
  278. if (cardSource.Owner == card.Owner)
  279. {
  280. if (cardSource.CanPlayJogress(true))
  281. {
  282. if (isExistOnField(card))
  283. {
  284. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  285. {
  286. return true;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. return false;
  294. }
  295. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  296. {
  297. yield return ContinuousController.instance.StartCoroutine(
  298. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  299. CanSelectCardCondition1,
  300. payCost: true,
  301. isHand: true,
  302. activateClass,
  303. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() }));
  304. }
  305. break;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. if (timing == EffectTiming.OnAllyAttack)
  312. {
  313. ActivateClass activateClass = new ActivateClass();
  314. activateClass.SetUpICardEffect("Return 1 level 5 or lower Digimon to the bottom of deck", CanUseCondition, card);
  315. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  316. activateClass.SetIsInheritedEffect(true);
  317. activateClass.SetHashString("DeckBounce_EX4_049");
  318. cardEffects.Add(activateClass);
  319. string EffectDiscription()
  320. {
  321. return "[When Attacking][Once Per Turn] If this Digimon has [Omnimon] in its name, return 1 of your opponent's level 5 or lower Digimon to the bottom of its owner's deck.";
  322. }
  323. bool CanSelectPermanentCondition(Permanent permanent)
  324. {
  325. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  326. {
  327. if (permanent.Level <= 5)
  328. {
  329. if (permanent.TopCard.HasLevel)
  330. {
  331. return true;
  332. }
  333. }
  334. }
  335. return false;
  336. }
  337. bool CanUseCondition(Hashtable hashtable)
  338. {
  339. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  340. }
  341. bool CanActivateCondition(Hashtable hashtable)
  342. {
  343. if (CardEffectCommons.IsExistOnBattleArea(card))
  344. {
  345. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  346. {
  347. return true;
  348. }
  349. }
  350. return false;
  351. }
  352. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  353. {
  354. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  355. {
  356. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  357. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  358. selectPermanentEffect.SetUp(
  359. selectPlayer: card.Owner,
  360. canTargetCondition: CanSelectPermanentCondition,
  361. canTargetCondition_ByPreSelecetedList: null,
  362. canEndSelectCondition: null,
  363. maxCount: maxCount,
  364. canNoSelect: false,
  365. canEndNotMax: false,
  366. selectPermanentCoroutine: null,
  367. afterSelectPermanentCoroutine: null,
  368. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  369. cardEffect: activateClass);
  370. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  371. }
  372. }
  373. }
  374. return cardEffects;
  375. }
  376. }
  377. }