EX7_048.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Gundramon
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_048 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Three Musketeers");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 4,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null,
  25. level: 5)
  26. );
  27. }
  28. #endregion
  29. #region Blocker
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  33. isInheritedEffect: false,
  34. card: card,
  35. condition: null));
  36. }
  37. #endregion
  38. #region Shared OP / WD
  39. string SharedEffectName = "Reveal the top 6 cards of deck, use an Option card";
  40. CardEffectFactory.ActivateClassesForSharedEffects
  41. (ref cardEffects, timing, card,
  42. SharedEffectName,
  43. SharedActivateCoroutine,
  44. SharedEffectDescription,
  45. optional: false,
  46. onPlay: true,
  47. whenDigivolving: true);
  48. string SharedEffectDescription(string tag) => $"[{tag}] Reveal the top 6 cards of your deck. You may use 1 Option card with the [Three Musketeers] trait among them without paying the cost. Return the rest to the top or bottom of the deck.";
  49. bool CanSelectCardSharedCondition(CardSource cardSource)
  50. {
  51. return cardSource.IsOption &&
  52. !cardSource.CanNotPlayThisOption &&
  53. cardSource.ContainsTraits("Three Musketeers");
  54. }
  55. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  58. revealCount: 6,
  59. simplifiedSelectCardConditions:
  60. new SimplifiedSelectCardConditionClass[]
  61. {
  62. new SimplifiedSelectCardConditionClass(
  63. canTargetCondition: CanSelectCardSharedCondition,
  64. message: "Select 1 Option card with the [Three Musketeers] trait.",
  65. mode: SelectCardEffect.Mode.Custom,
  66. maxCount: 1,
  67. selectCardCoroutine: SelectCardCoroutine),
  68. },
  69. remainingCardsPlace: RemainingCardsPlace.DeckTopOrBottom,
  70. activateClass: activateClass,
  71. canNoSelect: true
  72. ));
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(
  76. CardEffectCommons.PlayOptionCards(
  77. cardSources: new List<CardSource>() { cardSource },
  78. activateClass: activateClass,
  79. payCost: false,
  80. root: SelectCardEffect.Root.Library
  81. )
  82. );
  83. yield return null;
  84. }
  85. }
  86. #endregion
  87. #region All Turns
  88. if (timing == EffectTiming.WhenRemoveField)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect(
  92. "Trash 1 Option card in this Digimon's digivolution cards to prevent your Digimon from leaving Battle Area",
  93. CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  95. activateClass.SetHashString("Substitute_EX7_48");
  96. cardEffects.Add(activateClass);
  97. string EffectDescription()
  98. {
  99. return
  100. "[All Turns] When your Digimon with the [Three Musketeers] trait would leave the battle area other than by your effects, by trashing 1 Option card in this Digimon's digivolution cards, prevent it.";
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  105. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition) &&
  106. !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  107. }
  108. bool IsOwnerPermanentCondition(Permanent permanent)
  109. {
  110. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  111. permanent.TopCard.ContainsTraits("Three Musketeers");
  112. }
  113. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  114. {
  115. return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField;
  116. }
  117. bool CanSelectCardCondition(CardSource cardSource)
  118. {
  119. return cardSource.IsOption &&
  120. !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  125. card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  130. {
  131. Permanent thisCardPermanent = card.PermanentOfThisCard();
  132. Permanent selectedPermanent = null;
  133. SelectPermanentEffect selectPermanentEffect =
  134. GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: 1,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectPermanentCoroutine,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectPermanentEffect.SetUpCustomMessage(
  148. "Select 1 Digimon to prevent the deletion of.",
  149. "The opponent is selecting 1 Digimon to prevent the deletion of.");
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  152. {
  153. selectedPermanent = permanent;
  154. yield return null;
  155. }
  156. if (selectedPermanent != null && thisCardPermanent.DigivolutionCards.Some(CanSelectCardCondition))
  157. {
  158. List<CardSource> selectedCards = new List<CardSource>();
  159. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  160. selectCardEffect.SetUp(
  161. canTargetCondition: CanSelectCardCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. canNoSelect: () => true,
  165. selectCardCoroutine: SelectCardCoroutine,
  166. afterSelectCardCoroutine: null,
  167. message: "Select 1 Digivolution card to trash.",
  168. maxCount: 1,
  169. canEndNotMax: false,
  170. isShowOpponent: true,
  171. mode: SelectCardEffect.Mode.Custom,
  172. root: SelectCardEffect.Root.Custom,
  173. customRootCardList: thisCardPermanent.DigivolutionCards,
  174. canLookReverseCard: true,
  175. selectPlayer: card.Owner,
  176. cardEffect: activateClass);
  177. selectCardEffect.SetNotShowCard();
  178. yield return StartCoroutine(selectCardEffect.Activate());
  179. IEnumerator SelectCardCoroutine(CardSource cardSource)
  180. {
  181. selectedCards.Add(cardSource);
  182. yield return null;
  183. }
  184. if (selectedCards.Count == 1)
  185. {
  186. selectedPermanent.willBeRemoveField = false;
  187. selectedPermanent.HideDeleteEffect();
  188. selectedPermanent.HideHandBounceEffect();
  189. selectedPermanent.HideDeckBounceEffect();
  190. selectedPermanent.HideWillRemoveFieldEffect();
  191. yield return ContinuousController.instance.StartCoroutine(
  192. new ITrashDigivolutionCards(thisCardPermanent, selectedCards, activateClass)
  193. .TrashDigivolutionCards());
  194. }
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. return cardEffects;
  201. }
  202. }
  203. }