EX12_027.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // TeslaJellymon
  5. namespace DCGO.CardEffects.EX12
  6. {
  7. public class EX12_027 : 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 Cost
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Jellymon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.None)
  22. {
  23. bool PermanentCondition(Permanent targetPermanent)
  24. {
  25. return targetPermanent.TopCard.EqualsTraits("DS");
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null, level: 3));
  28. }
  29. #endregion
  30. #region Main
  31. if (timing == EffectTiming.OnDeclaration)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("May play/use 1 card with [Jellymon] in text/[DS] trait from hand for 2 less", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
  36. activateClass.SetHashString("EX12_013_Main");
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. => "[Main] [Once Per Turn] You may play or use 1 card with [Jellymon] in its text or the [DS] trait from your hand with the cost reduced by 2.";
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleArea(card)
  43. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  44. }
  45. bool CanSelectCardCondition(CardSource cardSource)
  46. {
  47. return (cardSource.HasText("Jellymon")
  48. || cardSource.EqualsTraits("DS"))
  49. && ((cardSource.IsOption
  50. && !cardSource.CanNotPlayThisOption)
  51. || (cardSource.HasPlayCost
  52. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass, fixedCost: cardSource.GetCostItself - 2)));
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. bool isUsed = false;
  57. CardSource selectedCard = null;
  58. #region Selected card in hand to play/use
  59. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  60. selectHandEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectCardCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: 1,
  66. canNoSelect: true,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. selectCardCoroutine: SelectCardCoroutine,
  70. afterSelectCardCoroutine: null,
  71. mode: SelectHandEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. selectedCard = cardSource;
  76. yield return null;
  77. }
  78. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  79. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  80. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  81. #endregion
  82. if (selectedCard != null)
  83. {
  84. isUsed = true;
  85. #region Reduce Cost
  86. IEnumerator ReduceCost(string type)
  87. {
  88. if (card.Owner.CanReduceCost(null, card))
  89. {
  90. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  91. }
  92. Hashtable hashtable = new Hashtable
  93. {
  94. { "CardEffect", activateClass }
  95. };
  96. ChangeCostClass changeCostClass = new ChangeCostClass();
  97. changeCostClass.SetUpICardEffect($"{type} cost: -2", CanUseCondition1, card);
  98. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  99. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  101. bool CanUseCondition1(Hashtable hashtable)
  102. {
  103. return true;
  104. }
  105. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  106. {
  107. if (CardSourceCondition(cardSource) &&
  108. RootCondition(root) &&
  109. PermanentsCondition(targetPermanents))
  110. {
  111. cost -= 2;
  112. }
  113. return cost;
  114. }
  115. bool PermanentsCondition(List<Permanent> targetPermanents)
  116. {
  117. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  118. }
  119. bool CardSourceCondition(CardSource cardSource)
  120. {
  121. return cardSource != null
  122. && cardSource.Owner == card.Owner;
  123. }
  124. bool RootCondition(SelectCardEffect.Root root)
  125. {
  126. return true;
  127. }
  128. bool isUpDown()
  129. {
  130. return true;
  131. }
  132. }
  133. #endregion
  134. if (selectedCard.IsOption)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Use"));
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  138. cardSources: new List<CardSource>() { selectedCard },
  139. activateClass: activateClass,
  140. payCost: true,
  141. root: SelectCardEffect.Root.Hand));
  142. }
  143. else
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Play"));
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  147. cardSources: new List<CardSource>() { selectedCard },
  148. activateClass: activateClass,
  149. payCost: true,
  150. isTapped: false,
  151. root: SelectCardEffect.Root.Hand,
  152. activateETB: true));
  153. }
  154. }
  155. if (!isUsed) activateClass.RemoveUse();
  156. }
  157. }
  158. #endregion
  159. #region Inherited
  160. if (timing == EffectTiming.OnAllyAttack)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("<Draw 1>, then if 7 or more in hand, trash 1", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  165. activateClass.SetIsInheritedEffect(true);
  166. activateClass.SetHashString("EX12_0273_Inherited");
  167. cardEffects.Add(activateClass);
  168. string EffectDescription()
  169. => "[When Attacking] [Once Per Turn] <Draw 1>. Then, if your hand has 7 or more cards, trash 1 card in your hand.";
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  173. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass);
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable hashtable)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  182. if (card.Owner.HandCards.Count >= 7)
  183. {
  184. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  185. selectHandEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: (cardSource) => true,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. maxCount: 1,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. isShowOpponent: true,
  194. selectCardCoroutine: null,
  195. afterSelectCardCoroutine: null,
  196. mode: SelectHandEffect.Mode.Discard,
  197. cardEffect: activateClass);
  198. yield return StartCoroutine(selectHandEffect.Activate());
  199. }
  200. }
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }