EX7_043.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Tankmon
  6. namespace DCGO.CardEffects.EX7
  7. {
  8. public class EX7_043 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasText("Three Musketeers");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 2,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Shared OP / WD
  30. string SharedEffectName = "Return cards from trash to De-Digivolve 1.";
  31. string SharedEffectDescription(string tag) => $"[{tag}] By returning 3 cards with the [Three Musketeers] trait from your hand or trash to the top of the deck, <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  32. int cardCount()
  33. {
  34. int cardCount = 0;
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. cardCount += card.Owner.HandCards.Count(CanSelectCardSharedCondition);
  38. cardCount += card.Owner.TrashCards.Count(CanSelectCardSharedCondition);
  39. }
  40. return cardCount;
  41. }
  42. bool SharedCanActivateCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  45. && cardCount() >= 3;
  46. }
  47. bool CanSelectCardSharedCondition(CardSource cardSource)
  48. {
  49. return cardSource.ContainsTraits("Three Musketeers");
  50. }
  51. bool CanSelectPermanentSharedCondition(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  54. }
  55. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  56. {
  57. List<CardSource> selectedCards = new List<CardSource>();
  58. if (card.Owner.HandCards.Count(CanSelectCardSharedCondition) >= 1)
  59. {
  60. int maxCount = Math.Min(3, card.Owner.HandCards.Count(CanSelectCardSharedCondition));
  61. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  62. selectHandEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectCardSharedCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: true,
  69. canEndNotMax: true,
  70. isShowOpponent: true,
  71. selectCardCoroutine: SelectCardCoroutine,
  72. afterSelectCardCoroutine: null,
  73. mode: SelectHandEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectHandEffect.SetUpCustomMessage("Select cards to return to top of deck.", "The opponent is selecting cards.");
  76. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. }
  83. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardSharedCondition))
  84. {
  85. int maxCount = 3 - selectedCards.Count;
  86. if (maxCount >= 1)
  87. {
  88. SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
  89. selectCardEffect1.SetUp(
  90. canTargetCondition: CanSelectCardSharedCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. canNoSelect: () => true,
  94. selectCardCoroutine: SelectCardCoroutine,
  95. afterSelectCardCoroutine: null,
  96. message: "Select cards to return to top of deck.",
  97. maxCount: maxCount,
  98. canEndNotMax: true,
  99. isShowOpponent: true,
  100. mode: SelectCardEffect.Mode.Custom,
  101. root: SelectCardEffect.Root.Trash,
  102. customRootCardList: null,
  103. canLookReverseCard: true,
  104. selectPlayer: card.Owner,
  105. cardEffect: activateClass);
  106. yield return ContinuousController.instance.StartCoroutine(selectCardEffect1.Activate());
  107. IEnumerator SelectCardCoroutine(CardSource cardSource)
  108. {
  109. selectedCards.Add(cardSource);
  110. yield return null;
  111. }
  112. }
  113. }
  114. if (selectedCards.Count == 3)
  115. {
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: (cardSource) => true,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => false,
  122. selectCardCoroutine: null,
  123. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  124. message: "Specify the order to place the cards in the top of the deck\n(cards will be placed so that cards with lower numbers are on top).",
  125. maxCount: selectedCards.Count,
  126. canEndNotMax: false,
  127. isShowOpponent: true,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.Custom,
  130. customRootCardList: selectedCards,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  135. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  136. {
  137. foreach (CardSource selectedCard in selectedCards)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  140. }
  141. cardSources.Reverse();
  142. yield return ContinuousController.instance.StartCoroutine(
  143. CardObjectController.AddLibraryTopCards(cardSources));
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentSharedCondition))
  145. {
  146. SelectPermanentEffect selectPermanentEffect =
  147. GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: CanSelectPermanentSharedCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: 1,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: SelectPermanentCoroutine,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Custom,
  159. cardEffect: activateClass);
  160. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  161. "The opponent is selecting 1 Digimon to De-Digivolve.");
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(
  166. new IDegeneration(permanent, 1, activateClass).Degeneration());
  167. }
  168. }
  169. }
  170. }
  171. }
  172. #endregion
  173. #region On Play
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  178. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("On Play"));
  179. cardEffects.Add(activateClass);
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  183. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  184. }
  185. }
  186. #endregion
  187. #region When Digivolving
  188. if (timing == EffectTiming.OnEnterFieldAnyone)
  189. {
  190. ActivateClass activateClass = new ActivateClass();
  191. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  192. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  193. cardEffects.Add(activateClass);
  194. bool CanUseCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  197. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  198. }
  199. }
  200. #endregion
  201. #region Reboot - ESS
  202. if (timing == EffectTiming.None)
  203. {
  204. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(
  205. isInheritedEffect: true,
  206. card: card,
  207. condition: null));
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }