EX5_018.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX5
  6. {
  7. public class EX5_018 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Garurumon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Draw 2, trash 2 cards from hand and gain Memory +1", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] <Draw 2> (Draw 2 cards from your deck). Then, trash 2 cards in your hand. If [Garurumon] or [X Antibody] is in this Digimon's digivolution cards, gain 1 memory.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (card.Owner.LibraryCards.Count >= 1)
  39. {
  40. return true;
  41. }
  42. if (card.Owner.HandCards.Count >= 1)
  43. {
  44. return true;
  45. }
  46. if (card.Owner.CanAddMemory(activateClass))
  47. {
  48. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  59. if (card.Owner.HandCards.Count >= 1)
  60. {
  61. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: (cardSource) => true,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: discardCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: null,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Discard,
  75. cardEffect: activateClass);
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. }
  78. if (CardEffectCommons.IsExistOnBattleArea(card))
  79. {
  80. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Garurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  83. }
  84. }
  85. }
  86. }
  87. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  92. activateClass.SetHashString("Substitute_EX5_018");
  93. activateClass.SetIsInheritedEffect(true);
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. 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.";
  98. }
  99. bool CanSelectCardCondition(CardSource cardSource)
  100. {
  101. return !cardSource.IsDigiEgg;
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. if (CardEffectCommons.IsExistOnBattleArea(card))
  106. {
  107. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  108. {
  109. if (CardEffectCommons.IsByBattle(hashtable))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanActivateCondition(Hashtable hashtable)
  118. {
  119. if (CardEffectCommons.IsExistOnBattleArea(card))
  120. {
  121. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  122. {
  123. if (card.PermanentOfThisCard().TopCard.HasGarurumonName)
  124. {
  125. return true;
  126. }
  127. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  128. {
  129. return true;
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  136. {
  137. Permanent thisCardPermanent = card.PermanentOfThisCard();
  138. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 2)
  139. {
  140. int maxCount = 2;
  141. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  142. selectCardEffect.SetUp(
  143. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. canNoSelect: () => true,
  147. selectCardCoroutine: null,
  148. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  149. 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).",
  150. maxCount: maxCount,
  151. canEndNotMax: false,
  152. isShowOpponent: false,
  153. mode: SelectCardEffect.Mode.Custom,
  154. root: SelectCardEffect.Root.Trash,
  155. customRootCardList: null,
  156. canLookReverseCard: true,
  157. selectPlayer: card.Owner,
  158. cardEffect: activateClass);
  159. selectCardEffect.SetNotShowCard();
  160. selectCardEffect.SetNotAddLog();
  161. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  162. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  163. {
  164. if (cardSources.Count == 2)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  167. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  168. if (thisCardPermanent.TopCard != null)
  169. {
  170. thisCardPermanent.willBeRemoveField = false;
  171. thisCardPermanent.HideDeleteEffect();
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. return cardEffects;
  179. }
  180. }
  181. }