EX12_055.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Andromon
  4. namespace DCGO.CardEffects.EX12
  5. {
  6. public class EX12_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Machine")
  17. || targetPermanent.TopCard.EqualsTraits("ME");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null,
  25. level: 4)
  26. );
  27. }
  28. #endregion
  29. #region DNA Digivolution
  30. if (timing == EffectTiming.None)
  31. {
  32. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  33. addJogressConditionClass.SetUpICardEffect("DNA Digivolution", CanUseCondition, card);
  34. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  35. addJogressConditionClass.SetNotShowUI(true);
  36. cardEffects.Add(addJogressConditionClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return true;
  40. }
  41. JogressCondition GetJogress(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. bool PermanentCondition1(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  48. && (permanent.TopCard.CardColors.Contains(CardColor.Black)
  49. || permanent.TopCard.CardColors.Contains(CardColor.Purple))
  50. && permanent.Levels_ForJogress(card).Contains(4);
  51. }
  52. bool PermanentCondition2(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  55. && (permanent.TopCard.CardColors.Contains(CardColor.Red)
  56. || permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  57. && permanent.Levels_ForJogress(card).Contains(4);
  58. }
  59. JogressConditionElement[] elements = new JogressConditionElement[]
  60. {
  61. new JogressConditionElement(PermanentCondition1, "a level 4 Black or Purple Digimon"),
  62. new JogressConditionElement(PermanentCondition2, "a level 4 Red or Yellow Digimon"),
  63. };
  64. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  65. return jogressCondition;
  66. }
  67. return null;
  68. }
  69. }
  70. #endregion
  71. #region Shared OP/WD
  72. string SharedEffectName = "Reveal 3, may play 1 5 cost or lower [Machine]/[Cyborg]/[ME] among them for free, trash the rest";
  73. CardEffectFactory.ActivateClassesForSharedEffects
  74. (ref cardEffects, timing, card,
  75. SharedEffectName,
  76. SharedActivateCoroutine,
  77. SharedEffectDescription,
  78. optional: false,
  79. onPlay: true,
  80. whenDigivolving: true);
  81. string SharedEffectDescription(string tag)
  82. {
  83. return $"[{tag}] Reveal the top 3 cards of your deck. You may play 1 play cost 5 or lower [Machine], [Cyborg] or [ME] trait card among them without paying the cost. Trash the rest.";
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. return cardSource.HasPlayCost
  88. && cardSource.GetCostItself <= 5
  89. && (cardSource.EqualsTraits("Machine")
  90. || cardSource.EqualsTraits("Cyborg")
  91. || cardSource.EqualsTraits("ME"));
  92. }
  93. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  94. {
  95. CardSource selectedCard = null;
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  97. revealCount: 3,
  98. simplifiedSelectCardConditions:
  99. new SimplifiedSelectCardConditionClass[]
  100. {
  101. new SimplifiedSelectCardConditionClass(
  102. canTargetCondition:CanSelectCardCondition,
  103. message: "May select 1 5 cost or less [Machine]/[Cyborg]/[ME] card to play for free.",
  104. mode: SelectCardEffect.Mode.Custom,
  105. maxCount: 1,
  106. selectCardCoroutine: SelectCardCoroutine),
  107. },
  108. remainingCardsPlace: RemainingCardsPlace.Trash,
  109. activateClass: activateClass,
  110. canNoSelect: true
  111. ));
  112. IEnumerator SelectCardCoroutine(CardSource cardSource)
  113. {
  114. selectedCard = cardSource;
  115. yield return null;
  116. }
  117. if (selectedCard != null)
  118. {
  119. if (CardEffectCommons.CanPlayAsNewPermanent(selectedCard, false, activateClass, SelectCardEffect.Root.Library))
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  122. cardSources: new List<CardSource> { selectedCard },
  123. activateClass: activateClass,
  124. payCost: false,
  125. isTapped: false,
  126. root: SelectCardEffect.Root.Library,
  127. activateETB: true));
  128. }
  129. else
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(new ITrashDeckCards(new List<CardSource> { selectedCard }, activateClass).TrashDeckCards());
  132. }
  133. }
  134. }
  135. #endregion
  136. #region Counter
  137. if (timing == EffectTiming.OnCounterTiming)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("1 other Digimon may digivolve into lvl 6 or less [ME] in hand for free", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  142. activateClass.SetIsSkippable(true);
  143. activateClass.SetHashString("EX12_055_Counter");
  144. activateClass.SetIsCounterEffect(true);
  145. cardEffects.Add(activateClass);
  146. string EffectDescription()
  147. {
  148. return "[Counter] [Once Per Turn] 1 of your other Digimon may digivolve into a level 6 or lower [ME] trait Digimon card in the hand without paying the cost.";
  149. }
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  153. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card));
  154. }
  155. bool CanActivateCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  158. }
  159. bool CanSelectPermanentCondition(Permanent permanent)
  160. {
  161. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  162. && permanent != card.PermanentOfThisCard();
  163. }
  164. bool CanSelectDigivolveCardCondition(CardSource cardSource)
  165. {
  166. return cardSource.IsDigimon
  167. && cardSource.HasLevel
  168. && cardSource.Level <= 6
  169. && cardSource.EqualsTraits("ME");
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  174. {
  175. Permanent selectedPermanent = null;
  176. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  177. selectPermanentEffect.SetUp(
  178. selectPlayer: card.Owner,
  179. canTargetCondition: CanSelectPermanentCondition,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. maxCount: 1,
  183. canNoSelect: true,
  184. canEndNotMax: false,
  185. selectPermanentCoroutine: SelectPermanentCoroutine,
  186. afterSelectPermanentCoroutine: null,
  187. mode: SelectPermanentEffect.Mode.Custom,
  188. cardEffect: activateClass);
  189. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  192. {
  193. selectedPermanent = permanent;
  194. yield return null;
  195. }
  196. if (selectedPermanent != null)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  199. targetPermanent: selectedPermanent,
  200. cardCondition: CanSelectDigivolveCardCondition,
  201. payCost: false,
  202. reduceCostTuple: null,
  203. fixedCostTuple: null,
  204. ignoreDigivolutionRequirementFixedCost: -1,
  205. isHand: true,
  206. activateClass: activateClass,
  207. successProcess: null));
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Inherited
  214. if (timing == EffectTiming.OnAllyAttack)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("Change attack target to this Digimon", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  219. activateClass.SetHashString("EX12_056_Inherited");
  220. activateClass.SetIsInheritedEffect(true);
  221. cardEffects.Add(activateClass);
  222. string EffectDescription()
  223. {
  224. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  225. }
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  229. && CardEffectCommons.IsOpponentTurn(card)
  230. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  231. }
  232. bool CanActivateCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
  235. && GManager.instance.attackProcess.IsAttacking
  236. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  237. }
  238. bool PermanentCondition(Permanent permanent)
  239. {
  240. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  243. {
  244. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  245. activateClass,
  246. false,
  247. card.PermanentOfThisCard()));
  248. }
  249. }
  250. #endregion
  251. return cardEffects;
  252. }
  253. }
  254. }