BT14_079.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_079 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 Digimon from trash", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] You may play 1 level 3 or lower card with the [Dark Animal] or [SoC] trait from your trash without paying the cost. If [Eiji Nagasumi] is in this Digimon's digivolution cards, add 1 to the level this effect may choose.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. int maxLevel = 3;
  25. if (CardEffectCommons.IsExistOnBattleArea(card))
  26. {
  27. if (card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("Eiji Nagasumi")) || card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("EijiNagasumi")))
  28. {
  29. maxLevel += 1;
  30. }
  31. }
  32. if (cardSource.Level <= maxLevel && !cardSource.IsLevel2)
  33. {
  34. if (!cardSource.IsDigiEgg)
  35. {
  36. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  37. {
  38. if (cardSource.HasLevel)
  39. {
  40. if (cardSource.CardTraits.Contains("Dark Animal") || cardSource.CardTraits.Contains("DarkAnimal") || cardSource.CardTraits.Contains("SoC"))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleArea(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  68. List<CardSource> selectedCards = new List<CardSource>();
  69. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  70. selectCardEffect.SetUp(
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. canNoSelect: () => true,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. message: "Select 1 card to play.",
  78. maxCount: maxCount,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. mode: SelectCardEffect.Mode.Custom,
  82. root: SelectCardEffect.Root.Trash,
  83. customRootCardList: null,
  84. canLookReverseCard: true,
  85. selectPlayer: card.Owner,
  86. cardEffect: activateClass);
  87. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  88. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  89. yield return StartCoroutine(selectCardEffect.Activate());
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCards.Add(cardSource);
  93. yield return null;
  94. }
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  96. }
  97. }
  98. if (timing == EffectTiming.OnAllyAttack)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect("Trash 1 card from hand to gain Memory +1", CanUseCondition, card);
  102. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  103. cardEffects.Add(activateClass);
  104. string EffectDiscription()
  105. {
  106. return "[When Attacking] By trashing 1 card in your hand, gain 1 memory.";
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. if (CardEffectCommons.IsExistOnBattleArea(card))
  115. {
  116. if (card.Owner.HandCards.Count >= 1)
  117. {
  118. return true;
  119. }
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. if (card.Owner.HandCards.Count >= 1)
  126. {
  127. bool discarded = false;
  128. int discardCount = 1;
  129. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  130. selectHandEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: (cardSource) => true,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: discardCount,
  136. canNoSelect: true,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. selectCardCoroutine: null,
  140. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  141. mode: SelectHandEffect.Mode.Discard,
  142. cardEffect: activateClass);
  143. yield return StartCoroutine(selectHandEffect.Activate());
  144. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  145. {
  146. if (cardSources.Count >= 1)
  147. {
  148. discarded = true;
  149. yield return null;
  150. }
  151. }
  152. if (discarded)
  153. {
  154. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  155. }
  156. }
  157. }
  158. }
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  164. activateClass.SetIsInheritedEffect(true);
  165. activateClass.SetHashString("Unsupend_BT14_079");
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[Your Turn][Once Per Turn] When you play a card with the [Dark Animal] or [SoC] trait, you may unsuspend this Digimon.";
  170. }
  171. bool PermanentCondition(Permanent permanent)
  172. {
  173. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  174. {
  175. if (permanent.TopCard.CardTraits.Contains("Dark Animal") || permanent.TopCard.CardTraits.Contains("DarkAnimal") || permanent.TopCard.CardTraits.Contains("SoC"))
  176. {
  177. return true;
  178. }
  179. }
  180. return false;
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleArea(card))
  185. {
  186. if (CardEffectCommons.IsOwnerTurn(card))
  187. {
  188. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  189. {
  190. return true;
  191. }
  192. }
  193. }
  194. return false;
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleArea(card))
  199. {
  200. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  201. {
  202. return true;
  203. }
  204. }
  205. return false;
  206. }
  207. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  208. {
  209. Permanent selectedPermanent = card.PermanentOfThisCard();
  210. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  211. }
  212. }
  213. return cardEffects;
  214. }
  215. }
  216. }