EX5_015.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX5
  5. {
  6. public class EX5_015 : 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.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.CardNames.Contains("Tsunomon") || targetPermanent.TopCard.CardNames.Contains("Gabumon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Reveal the top 4 cards of deck", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] Reveal the top 4 cards of your deck. Add 2 cards with [Garurumon]/[X Antibody] in their names among them to the hand. Place the rest at the bottom of the deck. If you added cards, trash 1 card in your hand.";
  28. }
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource.HasGarurumonName)
  32. {
  33. return true;
  34. }
  35. if (cardSource.HasXAntiBodyName)
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (card.Owner.LibraryCards.Count >= 1)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. bool added = false;
  59. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  60. revealCount: 4,
  61. simplifiedSelectCardConditions:
  62. new SimplifiedSelectCardConditionClass[]
  63. {
  64. new SimplifiedSelectCardConditionClass(
  65. canTargetCondition:CanSelectCardCondition,
  66. message: "Select 2 cards with [Garurumon]/[X Antibody] in their names.",
  67. mode: SelectCardEffect.Mode.AddHand,
  68. maxCount: 2,
  69. selectCardCoroutine: null),
  70. },
  71. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  72. activateClass: activateClass,
  73. revealedCardsCoroutine: RevealedCardsCoroutine
  74. ));
  75. IEnumerator RevealedCardsCoroutine(List<CardSource> revealedCards)
  76. {
  77. added = revealedCards.Count(CanSelectCardCondition) >= 1;
  78. yield return null;
  79. }
  80. if (added)
  81. {
  82. if (card.Owner.HandCards.Count >= 1)
  83. {
  84. int discardCount = 1;
  85. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectHandEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: (cardSource) => true,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: discardCount,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: null,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Discard,
  98. cardEffect: activateClass);
  99. yield return StartCoroutine(selectHandEffect.Activate());
  100. }
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Reveal the top 4 cards of deck", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[When Digivolving] Reveal the top 4 cards of your deck. Add 2 cards with [Garurumon]/[X Antibody] in their names among them to the hand. Place the rest at the bottom of the deck. If you added cards, trash 1 card in your hand.";
  113. }
  114. bool CanSelectCardCondition(CardSource cardSource)
  115. {
  116. if (cardSource.HasGarurumonName)
  117. {
  118. return true;
  119. }
  120. if (cardSource.HasXAntiBodyName)
  121. {
  122. return true;
  123. }
  124. return false;
  125. }
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. if (card.Owner.LibraryCards.Count >= 1)
  135. {
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  142. {
  143. bool added = false;
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  145. revealCount: 4,
  146. simplifiedSelectCardConditions:
  147. new SimplifiedSelectCardConditionClass[]
  148. {
  149. new SimplifiedSelectCardConditionClass(
  150. canTargetCondition:CanSelectCardCondition,
  151. message: "Select 2 cards with [Garurumon]/[X Antibody] in their names.",
  152. mode: SelectCardEffect.Mode.AddHand,
  153. maxCount: 2,
  154. selectCardCoroutine: null),
  155. },
  156. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  157. activateClass: activateClass,
  158. revealedCardsCoroutine: RevealedCardsCoroutine
  159. ));
  160. IEnumerator RevealedCardsCoroutine(List<CardSource> revealedCards)
  161. {
  162. added = revealedCards.Count(CanSelectCardCondition) >= 1;
  163. yield return null;
  164. }
  165. if (added)
  166. {
  167. if (card.Owner.HandCards.Count >= 1)
  168. {
  169. int discardCount = 1;
  170. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  171. selectHandEffect.SetUp(
  172. selectPlayer: card.Owner,
  173. canTargetCondition: (cardSource) => true,
  174. canTargetCondition_ByPreSelecetedList: null,
  175. canEndSelectCondition: null,
  176. maxCount: discardCount,
  177. canNoSelect: false,
  178. canEndNotMax: false,
  179. isShowOpponent: true,
  180. selectCardCoroutine: null,
  181. afterSelectCardCoroutine: null,
  182. mode: SelectHandEffect.Mode.Discard,
  183. cardEffect: activateClass);
  184. yield return StartCoroutine(selectHandEffect.Activate());
  185. }
  186. }
  187. }
  188. }
  189. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  190. {
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  194. activateClass.SetHashString("Substitute_EX5_015");
  195. activateClass.SetIsInheritedEffect(true);
  196. cardEffects.Add(activateClass);
  197. string EffectDiscription()
  198. {
  199. return "[All Turns] [Once Per Turn] When this Digimon with [Garurumon]/[Omnimon] in its name would be deleted in battle, by returning 2 non-Digi-Egg cards from your trash to the bottom of the deck, prevent that deletion.";
  200. }
  201. bool CanSelectCardCondition(CardSource cardSource)
  202. {
  203. return !cardSource.IsDigiEgg;
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleArea(card))
  208. {
  209. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  210. {
  211. if (CardEffectCommons.IsByBattle(hashtable))
  212. {
  213. return true;
  214. }
  215. }
  216. }
  217. return false;
  218. }
  219. bool CanActivateCondition(Hashtable hashtable)
  220. {
  221. if (CardEffectCommons.IsExistOnBattleArea(card))
  222. {
  223. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  224. {
  225. if (card.PermanentOfThisCard().TopCard.HasGarurumonName)
  226. {
  227. return true;
  228. }
  229. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  230. {
  231. return true;
  232. }
  233. }
  234. }
  235. return false;
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  238. {
  239. Permanent thisCardPermanent = card.PermanentOfThisCard();
  240. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  241. {
  242. int maxCount = 2;
  243. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  244. selectCardEffect.SetUp(
  245. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. canNoSelect: () => true,
  249. selectCardCoroutine: null,
  250. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  251. message: "Select cards to place 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).",
  252. maxCount: maxCount,
  253. canEndNotMax: false,
  254. isShowOpponent: false,
  255. mode: SelectCardEffect.Mode.Custom,
  256. root: SelectCardEffect.Root.Trash,
  257. customRootCardList: null,
  258. canLookReverseCard: true,
  259. selectPlayer: card.Owner,
  260. cardEffect: activateClass);
  261. selectCardEffect.SetNotShowCard();
  262. selectCardEffect.SetNotAddLog();
  263. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  264. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  265. {
  266. if (cardSources.Count == 2)
  267. {
  268. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  269. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  270. if (thisCardPermanent.TopCard != null)
  271. {
  272. thisCardPermanent.willBeRemoveField = false;
  273. thisCardPermanent.HideDeleteEffect();
  274. }
  275. }
  276. }
  277. }
  278. }
  279. }
  280. return cardEffects;
  281. }
  282. }
  283. }