EX10_026.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //SkullKnightmon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_026 : 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.HasText("Knightmon") &&
  18. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 play cost 4 or less Digimon", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] By trashing 1 card in your hand, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  37. permanent.TopCard.HasLevel && permanent.TopCard.GetCostItself <= 4;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  42. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  47. card.Owner.HandCards.Count >= 1;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. bool discarded = false;
  52. int discardCount = 1;
  53. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  54. selectHandEffect.SetUp(
  55. selectPlayer: card.Owner,
  56. canTargetCondition: (cardSource) => true,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. maxCount: discardCount,
  60. canNoSelect: true,
  61. canEndNotMax: false,
  62. isShowOpponent: true,
  63. selectCardCoroutine: null,
  64. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  65. mode: SelectHandEffect.Mode.Discard,
  66. cardEffect: activateClass);
  67. yield return StartCoroutine(selectHandEffect.Activate());
  68. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  69. {
  70. if (cardSources.Count >= 1)
  71. {
  72. discarded = true;
  73. yield return null;
  74. }
  75. }
  76. if (discarded)
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: maxCount,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: null,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Destroy,
  93. cardEffect: activateClass);
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. }
  96. }
  97. }
  98. }
  99. #endregion
  100. #region When Digivolving
  101. if (timing == EffectTiming.OnEnterFieldAnyone)
  102. {
  103. ActivateClass activateClass = new ActivateClass();
  104. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 play cost 4 or less Digimon", CanUseCondition, card);
  105. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  106. cardEffects.Add(activateClass);
  107. string EffectDiscription()
  108. {
  109. return "[When Digivolving] By trashing 1 card in your hand, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  110. }
  111. bool CanSelectPermanentCondition(Permanent permanent)
  112. {
  113. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  114. permanent.TopCard.HasLevel && permanent.TopCard.GetCostItself <= 4;
  115. }
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  119. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  124. card.Owner.HandCards.Count >= 1;
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  127. {
  128. bool discarded = false;
  129. int discardCount = 1;
  130. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  131. selectHandEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: (cardSource) => true,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: discardCount,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. selectCardCoroutine: null,
  141. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  142. mode: SelectHandEffect.Mode.Discard,
  143. cardEffect: activateClass);
  144. yield return StartCoroutine(selectHandEffect.Activate());
  145. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  146. {
  147. if (cardSources.Count >= 1)
  148. {
  149. discarded = true;
  150. yield return null;
  151. }
  152. }
  153. if (discarded)
  154. {
  155. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  156. {
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: null,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Destroy,
  170. cardEffect: activateClass);
  171. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  172. }
  173. }
  174. }
  175. }
  176. #endregion
  177. #region Save
  178. if (timing == EffectTiming.OnDestroyedAnyone)
  179. {
  180. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  181. }
  182. #endregion
  183. #region Blocker - ESS
  184. if (timing == EffectTiming.None)
  185. {
  186. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  187. isInheritedEffect: true,
  188. card: card,
  189. condition: null));
  190. }
  191. #endregion
  192. return cardEffects;
  193. }
  194. }
  195. }