EX5_069.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_069 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OptionSkill)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("By Trashing 1 card, delete level 6 or lower", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[Main] By trashing 1 card in your hand, delete 1 of your opponent's level 6 or lower Digimon. If this effect trashed a card with the [Seven Great Demon Lords] trait, place this card in the battle area.";
  19. }
  20. bool CanSelectPermanentCondition(Permanent permanent)
  21. {
  22. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  23. {
  24. if (permanent.Level <= 6)
  25. {
  26. if (permanent.TopCard.HasLevel)
  27. {
  28. return true;
  29. }
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (card.Owner.HandCards.Count >= 1)
  41. {
  42. bool discarded = false;
  43. CardSource discardedCard = null;
  44. int discardCount = 1;
  45. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  46. selectHandEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: cardSource => true,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: discardCount,
  52. canNoSelect: true,
  53. canEndNotMax: false,
  54. isShowOpponent: true,
  55. selectCardCoroutine: null,
  56. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  57. mode: SelectHandEffect.Mode.Discard,
  58. cardEffect: activateClass);
  59. yield return StartCoroutine(selectHandEffect.Activate());
  60. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  61. {
  62. if (cardSources.Count == 1)
  63. {
  64. discarded = true;
  65. discardedCard = cardSources[0];
  66. yield return null;
  67. }
  68. }
  69. if (discarded)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Destroy,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. }
  89. }
  90. if (discardedCard != null)
  91. {
  92. if (discardedCard.CardTraits.Contains("Seven Great Demon Lords") || discardedCard.CardTraits.Contains("SevenGreatDemonLords"))
  93. {
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(
  95. card: card,
  96. cardEffect: activateClass));
  97. }
  98. }
  99. }
  100. }
  101. }
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Play 1 [Leviamon] from trash", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription()
  109. {
  110. return "[All Turns] When an effect plays an opponent's Digimon, <Delay> (After this card is placed, by trashing it the next turn or later, activate the effect below.) - You may play 1 [Leviamon] from your trash without paying the cost.";
  111. }
  112. bool PermanentCondition(Permanent permanent)
  113. {
  114. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  115. }
  116. bool CanSelectCardCondition(CardSource cardSource)
  117. {
  118. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  119. {
  120. if (cardSource.CardNames.Contains("Leviamon"))
  121. {
  122. return true;
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleArea(card))
  130. {
  131. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  132. {
  133. if (CardEffectCommons.IsByEffect(hashtable, null))
  134. {
  135. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  136. {
  137. return true;
  138. }
  139. }
  140. }
  141. }
  142. return false;
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
  149. {
  150. return true;
  151. }
  152. }
  153. return false;
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  158. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  159. activateClass: activateClass,
  160. successProcess: permanents => SuccessProcess(),
  161. failureProcess: null));
  162. IEnumerator SuccessProcess()
  163. {
  164. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  165. {
  166. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  167. List<CardSource> selectedCards = new List<CardSource>();
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. selectCardEffect.SetUp(
  170. canTargetCondition: CanSelectCardCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. canNoSelect: () => true,
  174. selectCardCoroutine: SelectCardCoroutine,
  175. afterSelectCardCoroutine: null,
  176. message: "Select 1 card to play.",
  177. maxCount: maxCount,
  178. canEndNotMax: false,
  179. isShowOpponent: true,
  180. mode: SelectCardEffect.Mode.Custom,
  181. root: SelectCardEffect.Root.Trash,
  182. customRootCardList: null,
  183. canLookReverseCard: true,
  184. selectPlayer: card.Owner,
  185. cardEffect: activateClass);
  186. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  187. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  188. yield return StartCoroutine(selectCardEffect.Activate());
  189. IEnumerator SelectCardCoroutine(CardSource cardSource)
  190. {
  191. selectedCards.Add(cardSource);
  192. yield return null;
  193. }
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  195. cardSources: selectedCards,
  196. activateClass: activateClass,
  197. payCost: false,
  198. isTapped: false,
  199. root: SelectCardEffect.Root.Trash,
  200. activateETB: true));
  201. }
  202. }
  203. }
  204. }
  205. if (timing == EffectTiming.SecuritySkill)
  206. {
  207. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects,
  208. effectName: $"Trash 1 card from hand to delete 1 level 4 or lower Digimon and place this card on battle area");
  209. }
  210. return cardEffects;
  211. }
  212. }