EX11_051.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Necromon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_051 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Piercing
  13. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  14. {
  15. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region Execute
  19. if (timing == EffectTiming.OnEndTurn)
  20. {
  21. cardEffects.Add(CardEffectFactory.ExecuteSelfEffect(isInheritedEffect: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region OP/WD/OD Shared
  25. string SharedEffectName()
  26. {
  27. return "Delete 1 opponent's lowest level, then play level 4 or lower [Ghost] trait from trash for free.";
  28. }
  29. string SharedEffectDescription(string tag)
  30. {
  31. return $"[{tag}] Delete 1 of your opponent's Digimon with the lowest level. Then, you may play 1 level 4 or lower [Ghost] trait Digimon card from your trash without paying the cost.";
  32. }
  33. bool SharedCanActivateCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  36. }
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  40. }
  41. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  42. {
  43. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  44. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  45. selectPermanentEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: CanSelectPermanentCondition,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: maxCount,
  51. canNoSelect: false,
  52. canEndNotMax: false,
  53. selectPermanentCoroutine: null,
  54. afterSelectPermanentCoroutine: null,
  55. mode: SelectPermanentEffect.Mode.Destroy,
  56. cardEffect: activateClass);
  57. selectPermanentEffect.SetUpCustomMessage("Select a digimon to delete.", "The opponent is selecting a digimon to delete.");
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. bool HasCorrectTrait(CardSource cardSource)
  60. {
  61. return cardSource.IsDigimon
  62. && cardSource.EqualsTraits("Ghost")
  63. && cardSource.HasLevel
  64. && cardSource.Level <= 4
  65. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  66. }
  67. CardSource selectedCard = null;
  68. #region Select Digimon
  69. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  70. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasCorrectTrait));
  71. selectCardEffect.SetUp(
  72. canTargetCondition: HasCorrectTrait,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. canNoSelect: () => true,
  76. selectCardCoroutine: SelectCardCoroutine,
  77. afterSelectCardCoroutine: null,
  78. message: "Select 1 Digimon card to play.",
  79. maxCount: maxCount1,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. mode: SelectCardEffect.Mode.Custom,
  83. root: SelectCardEffect.Root.Trash,
  84. customRootCardList: null,
  85. canLookReverseCard: true,
  86. selectPlayer: card.Owner,
  87. cardEffect: activateClass);
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCard = cardSource;
  91. yield return null;
  92. }
  93. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  94. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  95. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  96. #endregion
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  98. cardSources: new List<CardSource>() { selectedCard },
  99. activateClass: activateClass,
  100. payCost: false,
  101. isTapped: false,
  102. root: SelectCardEffect.Root.Trash,
  103. activateETB: true)
  104. );
  105. }
  106. #endregion
  107. #region On Play
  108. if (timing == EffectTiming.OnEnterFieldAnyone)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  112. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  113. cardEffects.Add(activateClass);
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  117. && CardEffectCommons.IsExistOnBattleArea(card);
  118. }
  119. }
  120. #endregion
  121. #region When Digivolving
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  126. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  127. cardEffects.Add(activateClass);
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  131. && CardEffectCommons.IsExistOnBattleArea(card);
  132. }
  133. }
  134. #endregion
  135. #region On Deletion
  136. if (timing == EffectTiming.OnDestroyedAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Deletion"));
  141. cardEffects.Add(activateClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  149. }
  150. }
  151. #endregion
  152. #region On Deletion 1
  153. if (timing == EffectTiming.OnDestroyedAnyone)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Digivolve a [Ghost] Digimon to a [Ghost] for free", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  158. cardEffects.Add(activateClass);
  159. string EffectDescription()
  160. {
  161. return "[On Deletion] 1 of your [Ghost] trait Digimon may digivolve into a [Ghost] trait Digimon card in the hand without paying the cost.";
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  170. }
  171. bool CanSelectPermanentCondition1(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  174. && permanent.TopCard.EqualsTraits("Ghost");
  175. }
  176. bool CanSelectCardCondition(CardSource cardSource)
  177. {
  178. return cardSource.IsDigimon
  179. && cardSource.EqualsTraits("Ghost");
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  184. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: CanSelectPermanentCondition1,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. maxCount: maxCount,
  191. canNoSelect: true,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: SelectPermanentCoroutine,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.Custom,
  196. cardEffect: activateClass);
  197. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "Opponent is selecting a Digimon to digivolve.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  202. targetPermanent: permanent,
  203. cardCondition: CanSelectCardCondition,
  204. payCost: false,
  205. reduceCostTuple: null,
  206. fixedCostTuple: null,
  207. ignoreDigivolutionRequirementFixedCost: -1,
  208. isHand: true,
  209. activateClass: activateClass,
  210. successProcess: null
  211. ));
  212. }
  213. }
  214. }
  215. #endregion
  216. return cardEffects;
  217. }
  218. }
  219. }