EX7_062.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_062 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5)
  18. {
  19. if (targetPermanent.TopCard.EqualsTraits("Dark Dragon") || targetPermanent.TopCard.EqualsTraits("Evil Dragon"))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region When Digivolving
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Trash 2 cards from hand and delete a Digimon", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[When Digivolving] Trash 2 cards in your hand. Then, delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  43. {
  44. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  45. }
  46. return false;
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  51. {
  52. if (card.Owner.HandCards.Count >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanSelectPermanentCondition(Permanent permanent)
  60. {
  61. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  62. {
  63. if (permanent.IsDigimon)
  64. {
  65. if (permanent.DP <= card.PermanentOfThisCard().DP)
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (card.Owner.HandCards.Count >= 1)
  76. {
  77. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  78. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  79. selectHandEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: (cardSource) => true,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: discardCount,
  85. canNoSelect: false,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: null,
  90. mode: SelectHandEffect.Mode.Discard,
  91. cardEffect: activateClass);
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. }
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  95. {
  96. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  97. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  98. selectPermanentEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: CanSelectPermanentCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: maxCount,
  104. canNoSelect: false,
  105. canEndNotMax: false,
  106. selectPermanentCoroutine: null,
  107. afterSelectPermanentCoroutine: null,
  108. mode: SelectPermanentEffect.Mode.Destroy,
  109. cardEffect: activateClass);
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. }
  112. }
  113. }
  114. #endregion
  115. #region End of Your Turn
  116. if (timing == EffectTiming.OnEndTurn)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Play 1 Digimon with a play cost of 8 or less from your trash", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  121. activateClass.SetHashString("PlayFromTrash_EX7_062");
  122. cardEffects.Add(activateClass);
  123. string EffectDiscription()
  124. {
  125. return "[End of Your Turn] [Once Per Turn] You may play 1 card with the [Evil]/[Dark Dragon]/[Evil Dragon] trait and a play cost of 8 or less from your trash without paying the cost. For each card in your hand, reduce 1 from this effect's play cost maximum.";
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  130. {
  131. if (CardEffectCommons.IsOwnerTurn(card))
  132. {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. bool CanSelectCardInTrash(CardSource cardSource)
  139. {
  140. int maxCost = 8 - card.Owner.HandCards.Count();
  141. if (cardSource.IsDigimon)
  142. {
  143. if (cardSource.EqualsTraits("Evil") || cardSource.EqualsTraits("Dark Dragon") || cardSource.EqualsTraits("Evil Dragon"))
  144. {
  145. if (cardSource.GetCostItself <= maxCost)
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. return false;
  152. }
  153. bool CanActivateCondition(Hashtable hashtable)
  154. {
  155. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  156. {
  157. return true;
  158. }
  159. return true;
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  164. {
  165. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  166. List<CardSource> selectedCards = new List<CardSource>();
  167. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  168. selectCardEffect.SetUp(
  169. canTargetCondition: CanSelectCardInTrash,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. canNoSelect: () => true,
  173. selectCardCoroutine: SelectCardCoroutine,
  174. afterSelectCardCoroutine: null,
  175. message: "Select 1 card to play.",
  176. maxCount: maxCount,
  177. canEndNotMax: false,
  178. isShowOpponent: true,
  179. mode: SelectCardEffect.Mode.Custom,
  180. root: SelectCardEffect.Root.Trash,
  181. customRootCardList: null,
  182. canLookReverseCard: true,
  183. selectPlayer: card.Owner,
  184. cardEffect: activateClass);
  185. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  186. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  187. yield return StartCoroutine(selectCardEffect.Activate());
  188. IEnumerator SelectCardCoroutine(CardSource cardSource)
  189. {
  190. selectedCards.Add(cardSource);
  191. yield return null;
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  194. cardSources: selectedCards,
  195. activateClass: activateClass,
  196. payCost: false,
  197. isTapped: false,
  198. root: SelectCardEffect.Root.Trash,
  199. activateETB: true));
  200. }
  201. }
  202. }
  203. #endregion
  204. return cardEffects;
  205. }
  206. }
  207. }