EX9_059.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Ogremon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_059 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel3 &&
  18. targetPermanent.TopCard.EqualsTraits("DM");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Training
  24. if (timing == EffectTiming.OnDeclaration)
  25. {
  26. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  27. }
  28. #endregion
  29. #region When Digivolving
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Place 1 card in hand FD as bottom source, delete 1 level 4 or lower", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  35. activateClass.SetHashString("EX9_059_Deletion");
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] [Once Per Turn] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, delete 1 of your opponent's level 4 or lower Digimon.";
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  48. card.Owner.HandCards.Count > 0;
  49. }
  50. bool CanSelectPermanentCondition(Permanent permanent)
  51. {
  52. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  53. permanent.Level <= 4;
  54. }
  55. bool SelectCardCondition(CardSource source)
  56. {
  57. return true;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable hashtable)
  60. {
  61. CardSource selectedCard = null;
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: SelectCardCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: true,
  70. canEndNotMax: true,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCard = cardSource;
  80. yield return null;
  81. }
  82. if (selectedCard != null)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  85. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  86. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  87. {
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: 1,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: null,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Destroy,
  100. cardEffect: activateClass);
  101. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete.", "The opponent is selecting 1 digimon to delete.");
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Attacking
  109. if (timing == EffectTiming.OnAllyAttack)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Place 1 card in hand FD as bottom source, delete 1 level 4 or lower", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  114. activateClass.SetHashString("EX9_059_Deletion");
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. return "[When Attacking] [Once Per Turn] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, delete 1 of your opponent's level 4 or lower Digimon.";
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  127. card.Owner.HandCards.Count > 0;
  128. }
  129. bool CanSelectPermanentCondition(Permanent permanent)
  130. {
  131. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  132. permanent.Level <= 4;
  133. }
  134. bool SelectCardCondition(CardSource source)
  135. {
  136. return true;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable hashtable)
  139. {
  140. CardSource selectedCard = null;
  141. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  142. selectHandEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: SelectCardCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: 1,
  148. canNoSelect: true,
  149. canEndNotMax: true,
  150. isShowOpponent: true,
  151. selectCardCoroutine: SelectCardCoroutine,
  152. afterSelectCardCoroutine: null,
  153. mode: SelectHandEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. yield return StartCoroutine(selectHandEffect.Activate());
  156. IEnumerator SelectCardCoroutine(CardSource cardSource)
  157. {
  158. selectedCard = cardSource;
  159. yield return null;
  160. }
  161. if (selectedCard != null)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  164. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  165. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  166. {
  167. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: CanSelectPermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: 1,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: null,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Destroy,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete.", "The opponent is selecting 1 digimon to delete.");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. }
  183. }
  184. }
  185. }
  186. #endregion
  187. #region ESS
  188. if (timing == EffectTiming.OnAllyAttack)
  189. {
  190. ActivateClass activateClass = new ActivateClass();
  191. activateClass.SetUpICardEffect("Draw 1, Trash 1", CanUseCondition, card);
  192. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  193. activateClass.SetHashString("EX9_059_ESS");
  194. activateClass.SetIsInheritedEffect(true);
  195. cardEffects.Add(activateClass);
  196. string EffectDiscription()
  197. {
  198. return "[When Attacking] [Once Per Turn] <Draw 1> (Draw 1 card from your deck) and trash 1 card in your hand.";
  199. }
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  207. }
  208. bool CanSelectCard(CardSource source)
  209. {
  210. return true;
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable hashtable)
  213. {
  214. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  215. if (card.Owner.HandCards.Count >= 1)
  216. {
  217. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  218. selectHandEffect.SetUp(
  219. selectPlayer: card.Owner,
  220. canTargetCondition: CanSelectCard,
  221. canTargetCondition_ByPreSelecetedList: null,
  222. canEndSelectCondition: null,
  223. maxCount: 1,
  224. canNoSelect: false,
  225. canEndNotMax: false,
  226. isShowOpponent: true,
  227. selectCardCoroutine: null,
  228. afterSelectCardCoroutine: null,
  229. mode: SelectHandEffect.Mode.Discard,
  230. cardEffect: activateClass);
  231. yield return StartCoroutine(selectHandEffect.Activate());
  232. }
  233. }
  234. }
  235. #endregion
  236. return cardEffects;
  237. }
  238. }
  239. }