EX10_017.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Mienumon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_017 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alternative Digivolution Condition - Stnd.
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasStandardAppTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region App Fusion (Mirrormon & Kabemon & Copipemon)
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() {"Mirrormon", "Kabemon","Copipemon"},card));
  28. }
  29. #endregion
  30. #region Link
  31. if (timing == EffectTiming.OnDeclaration)
  32. {
  33. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  34. }
  35. #endregion
  36. #region Link Condition
  37. if (timing == EffectTiming.None)
  38. {
  39. static bool PermanentCondition(Permanent targetPermanent)
  40. {
  41. return targetPermanent.TopCard.HasAppmonTraits;
  42. }
  43. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  44. }
  45. #endregion
  46. #region Jamming
  47. if (timing == EffectTiming.None)
  48. {
  49. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  50. }
  51. #endregion
  52. #region Retaliation
  53. if (timing == EffectTiming.OnDestroyedAnyone)
  54. {
  55. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  56. }
  57. #endregion
  58. #endregion
  59. #region When Linked
  60. if (timing == EffectTiming.WhenLinked)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Play 1 Tamer with [Leviathan] trait", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  65. activateClass.SetHashString("EX10_017_WhenLinked");
  66. cardEffects.Add(activateClass);
  67. string EffectDiscription()
  68. {
  69. return "[Your Turn] [Once Per Turn] When this Digimon gets linked, if you have 1 or fewer Tamers, you may play 1 Tamer card with the [Leviathan] trait from your hand without paying the cost.";
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  74. && CardEffectCommons.CanTriggerWhenLinked(hashtable, perm => perm == card.PermanentOfThisCard(), null);
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  79. && CardEffectCommons.IsOwnerTurn(card)
  80. && CardEffectCommons.OwnerHas1OrLessTamers(card)
  81. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  82. }
  83. bool CanSelectCardCondition(CardSource cardSource)
  84. {
  85. return cardSource.IsTamer
  86. && cardSource.HasLeviathanTraits
  87. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  88. }
  89. IEnumerator ActivateCoroutine(Hashtable hashtable)
  90. {
  91. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  92. {
  93. CardSource selectedCard = null;
  94. #region Select Tamer
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  96. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  97. selectHandEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: false,
  104. canEndNotMax: false,
  105. isShowOpponent: true,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. mode: SelectHandEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. IEnumerator SelectCardCoroutine(CardSource cardSource)
  111. {
  112. selectedCard = cardSource;
  113. yield return null;
  114. }
  115. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  116. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  117. yield return StartCoroutine(selectHandEffect.Activate());
  118. #endregion
  119. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  120. cardSources: new List<CardSource>() { selectedCard },
  121. activateClass: activateClass,
  122. payCost: false,
  123. isTapped: false,
  124. root: SelectCardEffect.Root.Hand,
  125. activateETB: true));
  126. }
  127. }
  128. }
  129. #endregion
  130. #region Link Effect
  131. if (timing == EffectTiming.OnTappedAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("By trashing 1 link card, draw 1 & gain 1 memory", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  136. activateClass.SetIsLinkedEffect(true);
  137. cardEffects.Add(activateClass);
  138. string EffectDiscription()
  139. {
  140. return "[All Turns] When any of your opponent's Digimon suspend, by trashing 1 of this Digimon's link cards, <Draw 1> (Draw 1 card from your deck.) and gain 1 memory.";
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermamentCondition);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleArea(card)
  150. && HasLinkedCards(card.PermanentOfThisCard().TopCard.PermanentOfThisCard());
  151. }
  152. bool PermamentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  155. }
  156. bool HasLinkedCards(Permanent permanent)
  157. {
  158. return !permanent.HasNoLinkCards;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable hashtable)
  161. {
  162. Permanent thisCardPermament = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  163. if (HasLinkedCards(thisCardPermament))
  164. {
  165. CardSource selectedCard = null;
  166. #region Select Link Card
  167. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. selectCardEffect.SetUp(
  170. canTargetCondition: _ => true,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. canNoSelect: () => true,
  174. selectCardCoroutine: SelectCardCoroutine,
  175. afterSelectCardCoroutine: null,
  176. message: "Select 1 linked card to trash.",
  177. maxCount: maxCount,
  178. canEndNotMax: false,
  179. isShowOpponent: true,
  180. mode: SelectCardEffect.Mode.Custom,
  181. root: SelectCardEffect.Root.Custom,
  182. customRootCardList: thisCardPermament.LinkedCards,
  183. canLookReverseCard: true,
  184. selectPlayer: card.Owner,
  185. cardEffect: activateClass);
  186. IEnumerator SelectCardCoroutine(CardSource cardSource)
  187. {
  188. selectedCard = cardSource;
  189. yield return null;
  190. }
  191. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  192. yield return StartCoroutine(selectCardEffect.Activate());
  193. #endregion
  194. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  195. targetPermanent: thisCardPermament,
  196. targetLinkCards: new List<CardSource>() { selectedCard },
  197. activateClass: activateClass,
  198. successProcess: SuccessProcess,
  199. failureProcess: null));
  200. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  201. {
  202. if (trashedLinkCards.Any())
  203. {
  204. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  205. if (card.Owner.CanAddMemory(activateClass)) yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  206. }
  207. }
  208. }
  209. }
  210. }
  211. #endregion
  212. return cardEffects;
  213. }
  214. }
  215. }