EX7_009.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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_009 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] Return 1 card with the [Machine Dragon]/[Sky Dragon] trait or 1 [Hina Kurihara] from your trash to your hand.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.IsDigimon)
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (cardSource.ContainsTraits("Machine Dragon") || cardSource.ContainsTraits("Sky Dragon"))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. if (cardSource.IsTamer)
  38. {
  39. if (cardSource.Owner == card.Owner)
  40. {
  41. if (cardSource.EqualsCardName("Hina Kurihara"))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  53. {
  54. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  55. {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  64. {
  65. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  73. {
  74. if (isExistOnField(card))
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  77. {
  78. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  79. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  80. selectCardEffect.SetUp(
  81. canTargetCondition: CanSelectCardCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. canNoSelect: () => false,
  85. selectCardCoroutine: null,
  86. afterSelectCardCoroutine: null,
  87. message: "Select 1 card to add to your hand.",
  88. maxCount: maxCount,
  89. canEndNotMax: false,
  90. isShowOpponent: true,
  91. mode: SelectCardEffect.Mode.AddHand,
  92. root: SelectCardEffect.Root.Trash,
  93. customRootCardList: null,
  94. canLookReverseCard: true,
  95. selectPlayer: card.Owner,
  96. cardEffect: activateClass);
  97. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  98. }
  99. }
  100. }
  101. }
  102. #endregion
  103. #region When Digivolving
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Play 1 [Hina Kurihara] from hand", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[When Digivolving] If you have 1 or less Tamers, you may play 1 [Hina Kurihara] from your hand without paying the cost.";
  113. }
  114. bool CanSelectCardCondition(CardSource cardSource)
  115. {
  116. if (cardSource != null)
  117. {
  118. if (cardSource.EqualsCardName("Hina Kurihara"))
  119. {
  120. if (cardSource.Owner == card.Owner)
  121. {
  122. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  134. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  135. return false;
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  140. {
  141. if (card.Owner.HandCards.Count >= 1)
  142. {
  143. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.IsTamer) <= 1)
  144. {
  145. return true;
  146. }
  147. }
  148. }
  149. return false;
  150. }
  151. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  152. {
  153. List<CardSource> selectedCards = new List<CardSource>();
  154. int maxCount = 1;
  155. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  156. selectHandEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectCardCondition,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: true,
  163. canEndNotMax: false,
  164. isShowOpponent: true,
  165. selectCardCoroutine: SelectCardCoroutine,
  166. afterSelectCardCoroutine: null,
  167. mode: SelectHandEffect.Mode.Custom,
  168. cardEffect: activateClass);
  169. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  170. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  171. yield return StartCoroutine(selectHandEffect.Activate());
  172. IEnumerator SelectCardCoroutine(CardSource cardSource)
  173. {
  174. selectedCards.Add(cardSource);
  175. yield return null;
  176. }
  177. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  178. }
  179. }
  180. #endregion
  181. #region Inherit
  182. if (timing == EffectTiming.None)
  183. {
  184. bool Condition()
  185. {
  186. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  187. {
  188. if (CardEffectCommons.IsOwnerTurn(card))
  189. {
  190. return true;
  191. }
  192. }
  193. return false;
  194. }
  195. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  196. changeValue: 2000,
  197. isInheritedEffect: true,
  198. card: card,
  199. condition: Condition));
  200. }
  201. #endregion
  202. return cardEffects;
  203. }
  204. }
  205. }