EX8_060.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Myotismon
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_060 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("NSo");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null,
  24. level: 4)
  25. );
  26. }
  27. #endregion
  28. #region When Attacking
  29. if (timing == EffectTiming.OnAllyAttack)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("You may play 1 3 cost or less NSo Digimon", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  34. activateClass.SetIsSkippable(true);
  35. cardEffects.Add(activateClass);
  36. string EffectDescription()
  37. {
  38. return "[When Attacking] You may play 1 [NSo] trait Digimon card with a play cost of 3 or less from your trash without paying the cost.";
  39. }
  40. bool DigimonToPlay(CardSource cardSource)
  41. {
  42. return cardSource.IsDigimon
  43. && cardSource.HasPlayCost
  44. && cardSource.GetCostItself <= 3
  45. && cardSource.EqualsTraits("NSo")
  46. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, SelectCardEffect.Root.Trash);
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  51. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  56. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigimonToPlay);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. List<CardSource> selectedCards = new List<CardSource>();
  61. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  62. selectCardEffect.SetUp(
  63. canTargetCondition: DigimonToPlay,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. canNoSelect: () => true,
  67. selectCardCoroutine: null,
  68. afterSelectCardCoroutine: SelectCardCoroutine,
  69. message: "Select 1 Digimon card to play.",
  70. maxCount: 1,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. mode: SelectCardEffect.Mode.Custom,
  74. root: SelectCardEffect.Root.Trash,
  75. customRootCardList: null,
  76. canLookReverseCard: true,
  77. selectPlayer: card.Owner,
  78. cardEffect: activateClass);
  79. selectCardEffect.SetUpCustomMessage(
  80. "Select 1 Digimon card to play.",
  81. "The opponent is selecting 1 Digimon card to play.");
  82. selectCardEffect.SetUpCustomMessage_ShowCard("Play Card");
  83. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  84. IEnumerator SelectCardCoroutine(List<CardSource> sources)
  85. {
  86. selectedCards = sources;
  87. yield return null;
  88. }
  89. if (selectedCards.Count > 0)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  92. cardSources: selectedCards,
  93. activateClass: activateClass,
  94. payCost: false,
  95. isTapped: false,
  96. root: SelectCardEffect.Root.Trash,
  97. activateETB: true));
  98. }
  99. }
  100. }
  101. #endregion
  102. #region Your Turn
  103. if (timing == EffectTiming.OnEnterFieldAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("DNA Digivolve.", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  108. activateClass.SetHashString("DNADigivolve_EX8_060");
  109. cardEffects.Add(activateClass);
  110. string EffectDescription()
  111. {
  112. return "[Your Turn] [Once Per Turn] When your Digimon are played or digivolve, if any of them have the [NSo] trait, 2 of your Digimon may DNA digivolve into a Digimon card with the [NSo] trait in the hand. Then, that DNA digivolved Digimon may attack.";
  113. }
  114. bool PermanentConditionNSoEnterField(Permanent permanent)
  115. {
  116. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  117. && permanent.TopCard.CardTraits.Contains("NSo");
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  122. && CardEffectCommons.IsOwnerTurn(card)
  123. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentConditionNSoEnterField)
  124. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentConditionNSoEnterField));
  125. }
  126. bool CanActivateCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  129. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACardCondition);
  130. }
  131. bool CanSelectDNACardCondition(CardSource cardSource)
  132. {
  133. return cardSource.IsDigimon
  134. && cardSource.CanPlayJogress(true)
  135. && cardSource.ContainsTraits("NSo");
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  138. {
  139. yield return ContinuousController.instance.StartCoroutine(
  140. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  141. CanSelectDNACardCondition,
  142. payCost: true,
  143. isHand: true,
  144. activateClass,
  145. successProcess: OnDNASuccess
  146. ));
  147. IEnumerator OnDNASuccess(CardSource cardSource)
  148. {
  149. if (cardSource.PermanentOfThisCard().CanAttack(activateClass))
  150. {
  151. SelectAttackEffect selectAttackEffect =
  152. GManager.instance.GetComponent<SelectAttackEffect>();
  153. selectAttackEffect.SetUp(
  154. attacker: cardSource.PermanentOfThisCard(),
  155. canAttackPlayerCondition: () => true,
  156. defenderCondition: (permanent) => true,
  157. cardEffect: activateClass);
  158. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect
  159. .Activate());
  160. }
  161. }
  162. }
  163. }
  164. #endregion
  165. #region Inherited Effect
  166. if (timing == EffectTiming.OnAllyAttack)
  167. {
  168. ActivateClass activateClass = new ActivateClass();
  169. activateClass.SetUpICardEffect("Delete your another Digimon to unsuspend this Digimon", CanUseCondition, card);
  170. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  171. activateClass.SetIsSkippable(true);
  172. activateClass.SetIsInheritedEffect(true);
  173. activateClass.SetHashString("Unsuspend_EX8_060");
  174. cardEffects.Add(activateClass);
  175. string EffectDescription()
  176. {
  177. return "[When Attacking] [Once Per Turn] By deleting 1 of your other Digimon, this Digimon unsuspends.";
  178. }
  179. bool CanSelectPermanentCondition(Permanent permanent)
  180. {
  181. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  182. && permanent != card.PermanentOfThisCard();
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  187. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  192. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  195. {
  196. bool isUsed = false;
  197. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  198. {
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: CanSelectPermanentCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: 1,
  206. canNoSelect: true,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: SelectPermanentCoroutine,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  215. {
  216. if (permanent != null)
  217. {
  218. isUsed = true;
  219. Permanent thisCardPermanent = card.PermanentOfThisCard();
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent },
  221. activateClass: activateClass,
  222. successProcess: permanents => SuccessProcess(),
  223. failureProcess: null));
  224. IEnumerator SuccessProcess()
  225. {
  226. if (thisCardPermanent.TopCard != null)
  227. {
  228. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { thisCardPermanent }, activateClass).Unsuspend());
  229. }
  230. }
  231. }
  232. }
  233. }
  234. if (!isUsed) activateClass.RemoveUse();
  235. }
  236. }
  237. #endregion
  238. return cardEffects;
  239. }
  240. }
  241. }