EX7_042.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX7
  5. {
  6. public class EX7_042 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash 1 [Rock Dragon]/[Earth Dragon], <Draw 2>", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[On Play] By trashing 1 card with the [Rock Dragon]/[Earth Dragon] trait in your hand, <Draw 2>.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  25. }
  26. bool HasDragonInTrait(CardSource cardSource)
  27. {
  28. return cardSource.ContainsTraits("Rock Dragon") ||
  29. cardSource.ContainsTraits("Earth Dragon");
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  34. CardEffectCommons.HasMatchConditionOwnersHand(card, HasDragonInTrait);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  39. selectHandEffect.SetUp(
  40. canTargetCondition: HasDragonInTrait,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. canNoSelect: true,
  44. selectCardCoroutine: null,
  45. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  46. maxCount: 1,
  47. canEndNotMax: false,
  48. isShowOpponent: true,
  49. mode: SelectHandEffect.Mode.Discard,
  50. selectPlayer: card.Owner,
  51. cardEffect: activateClass);
  52. selectHandEffect.SetUpCustomMessage("Select 1 card with [Rock Dragon]/[Earth Dragon] trait to discard.",
  53. "The opponent is selecting 1 card with [Rock Dragon]/[Earth Dragon] trait to discard.");
  54. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  55. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  56. {
  57. if (cardSources.Count > 0)
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(
  60. new DrawClass(card.Owner, 2, activateClass).Draw());
  61. }
  62. }
  63. }
  64. }
  65. #endregion
  66. #region When Digivolving
  67. if (timing == EffectTiming.OnEnterFieldAnyone)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Play 1 Tamer with [Hina Kurihara] in its name from hand", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  72. cardEffects.Add(activateClass);
  73. string EffectDescription()
  74. {
  75. return
  76. "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Hina Kurihara] from your hand without paying the cost.";
  77. }
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  81. }
  82. bool IsHinaCardCondition(CardSource cardSource)
  83. {
  84. return cardSource.IsTamer &&
  85. (cardSource.EqualsCardName("Hina Kurihara") || cardSource.EqualsCardName("HinaKurihara")) &&
  86. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  87. }
  88. bool CanActivateCondition(Hashtable hashtable)
  89. {
  90. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  91. CardEffectCommons.HasMatchConditionOwnersHand(card, IsHinaCardCondition) &&
  92. card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsHinaCardCondition))
  97. {
  98. List<CardSource> selectedCards = new List<CardSource>();
  99. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  100. selectHandEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: IsHinaCardCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: 1,
  106. canNoSelect: true,
  107. canEndNotMax: false,
  108. isShowOpponent: true,
  109. selectCardCoroutine: SelectCardCoroutine,
  110. afterSelectCardCoroutine: null,
  111. mode: SelectHandEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  114. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  115. yield return StartCoroutine(selectHandEffect.Activate());
  116. IEnumerator SelectCardCoroutine(CardSource cardSource)
  117. {
  118. selectedCards.Add(cardSource);
  119. yield return null;
  120. }
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  122. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  123. root: SelectCardEffect.Root.Hand, activateETB: true));
  124. }
  125. }
  126. }
  127. #endregion
  128. #region Opponent's Turn - ESS
  129. if (timing == EffectTiming.None)
  130. {
  131. bool Condition()
  132. {
  133. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  134. CardEffectCommons.IsOpponentTurn(card);
  135. }
  136. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  137. changeValue: 2000,
  138. isInheritedEffect: true,
  139. card: card,
  140. condition: Condition));
  141. }
  142. #endregion
  143. return cardEffects;
  144. }
  145. }
  146. }