EX12_041.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Thundermon
  5. namespace DCGO.CardEffects.EX12
  6. {
  7. public class EX12_041 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("ME");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null,
  25. level: 3)
  26. );
  27. }
  28. #endregion
  29. #region Main
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("May play/use 1 card with [Mutant]/[ME] trait from hand for 2 less", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
  35. activateClass.SetHashString("EX12_041_Main");
  36. cardEffects.Add(activateClass);
  37. string EffectDescription()
  38. => "[Main] [Once Per Turn] You may play or use 1 card with the [Mutant] or [ME] trait from your hand with the cost reduced by 2.";
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. return (cardSource.EqualsTraits("Mutant")
  47. || cardSource.EqualsTraits("ME"))
  48. && ((cardSource.IsOption
  49. && !cardSource.CanNotPlayThisOption)
  50. || (cardSource.HasPlayCost
  51. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass, fixedCost: cardSource.GetCostItself - 2)));
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. bool isUsed = false;
  56. CardSource selectedCard = null;
  57. #region Selected card in hand to play/use
  58. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  59. selectHandEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: CanSelectCardCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: 1,
  65. canNoSelect: true,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. selectCardCoroutine: SelectCardCoroutine,
  69. afterSelectCardCoroutine: null,
  70. mode: SelectHandEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCard = cardSource;
  75. yield return null;
  76. }
  77. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  78. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  79. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  80. #endregion
  81. if (selectedCard != null)
  82. {
  83. isUsed = true;
  84. #region Reduce Cost
  85. IEnumerator ReduceCost(string type)
  86. {
  87. if (card.Owner.CanReduceCost(null, card))
  88. {
  89. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  90. }
  91. Hashtable hashtable = new Hashtable
  92. {
  93. { "CardEffect", activateClass }
  94. };
  95. ChangeCostClass changeCostClass = new ChangeCostClass();
  96. changeCostClass.SetUpICardEffect($"{type} cost: -2", CanUseCondition1, card);
  97. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  98. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  99. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  100. bool CanUseCondition1(Hashtable hashtable)
  101. {
  102. return true;
  103. }
  104. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  105. {
  106. if (CardSourceCondition(cardSource) &&
  107. RootCondition(root) &&
  108. PermanentsCondition(targetPermanents))
  109. {
  110. cost -= 2;
  111. }
  112. return cost;
  113. }
  114. bool PermanentsCondition(List<Permanent> targetPermanents)
  115. {
  116. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  117. }
  118. bool CardSourceCondition(CardSource cardSource)
  119. {
  120. return cardSource != null
  121. && cardSource.Owner == card.Owner;
  122. }
  123. bool RootCondition(SelectCardEffect.Root root)
  124. {
  125. return true;
  126. }
  127. bool isUpDown()
  128. {
  129. return true;
  130. }
  131. }
  132. #endregion
  133. if (selectedCard.IsOption)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Use"));
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  137. cardSources: new List<CardSource>() { selectedCard },
  138. activateClass: activateClass,
  139. payCost: true,
  140. root: SelectCardEffect.Root.Hand));
  141. }
  142. else
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Play"));
  145. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  146. cardSources: new List<CardSource>() { selectedCard },
  147. activateClass: activateClass,
  148. payCost: true,
  149. isTapped: false,
  150. root: SelectCardEffect.Root.Hand,
  151. activateETB: true));
  152. }
  153. }
  154. if (!isUsed) activateClass.RemoveUse();
  155. }
  156. }
  157. #endregion
  158. #region Rule
  159. if (timing == EffectTiming.None)
  160. {
  161. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  162. changeCardNamesClass.SetUpICardEffect("Also treated as including [Mamemon]", CanUseCondition, card);
  163. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  164. cardEffects.Add(changeCardNamesClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return true;
  168. }
  169. List<string> changeCardNames(CardSource cardSource, List<string> cardNames)
  170. {
  171. if (cardSource == card)
  172. {
  173. for (int i = 0; i < cardNames.Count; i++)
  174. {
  175. if (!cardNames[i].Contains("Mamemon"))
  176. {
  177. cardNames[i] = $"Mamemon {cardNames[i]}";
  178. }
  179. }
  180. }
  181. return cardNames;
  182. }
  183. }
  184. #endregion
  185. #region Inherited
  186. if (timing == EffectTiming.OnAllyAttack)
  187. {
  188. ActivateClass activateClass = new ActivateClass();
  189. activateClass.SetUpICardEffect("1 enemy Digimon gets -2K DP for turn", CanUseCondition, card);
  190. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  191. activateClass.SetHashString("EX12_041_Inherited");
  192. activateClass.SetIsInheritedEffect(true);
  193. cardEffects.Add(activateClass);
  194. string EffectDescription()
  195. {
  196. return "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon gets -2000 DP for the turn.";
  197. }
  198. bool CanUseCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  201. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  202. }
  203. bool CanActivateCondition(Hashtable hashtable)
  204. {
  205. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass);
  206. }
  207. bool CanSelectPermanentCondition(Permanent permanent)
  208. {
  209. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  210. }
  211. IEnumerator ActivateCoroutine(Hashtable hashtable)
  212. {
  213. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  214. {
  215. Permanent selectedPermament = null;
  216. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  217. selectPermanentEffect.SetUp(
  218. selectPlayer: card.Owner,
  219. canTargetCondition: CanSelectPermanentCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. maxCount: 1,
  223. canNoSelect: false,
  224. canEndNotMax: false,
  225. selectPermanentCoroutine: SelectPermanentCoroutine,
  226. afterSelectPermanentCoroutine: null,
  227. mode: SelectPermanentEffect.Mode.Custom,
  228. cardEffect: activateClass);
  229. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  230. {
  231. selectedPermament = permanent;
  232. yield return null;
  233. }
  234. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -2K DP", "The opponent is selecting 1 Digimon to -2K DP");
  235. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  236. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  237. targetPermanent: selectedPermament,
  238. changeValue: -2000,
  239. effectDuration: EffectDuration.UntilEachTurnEnd,
  240. activateClass: activateClass
  241. ));
  242. }
  243. }
  244. }
  245. #endregion
  246. return cardEffects;
  247. }
  248. }
  249. }