BT14_076.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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_076 : 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.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasGreymonName && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Trash 1 card from hand to delete Digimon", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] By trashing 1 card in your hand, delete 1 of your Digimon with the lowest level and 1 of your opponent's Digimon with the lowest level.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsMinLevel(permanent, card.Owner);
  37. }
  38. bool CanSelectPermanentCondition1(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.HandCards.Count >= 1)
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. if (card.Owner.HandCards.Count >= 1)
  56. {
  57. bool discarded = false;
  58. int discardCount = 1;
  59. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  60. selectHandEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: cardSource => true,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: discardCount,
  66. canNoSelect: true,
  67. canEndNotMax: false,
  68. isShowOpponent: true,
  69. selectCardCoroutine: null,
  70. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  71. mode: SelectHandEffect.Mode.Discard,
  72. cardEffect: activateClass);
  73. yield return StartCoroutine(selectHandEffect.Activate());
  74. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  75. {
  76. if (cardSources.Count >= 1)
  77. {
  78. discarded = true;
  79. yield return null;
  80. }
  81. }
  82. if (discarded)
  83. {
  84. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  85. {
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: null,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Destroy,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. }
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  103. {
  104. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  105. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  106. selectPermanentEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectPermanentCondition1,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: false,
  113. canEndNotMax: false,
  114. selectPermanentCoroutine: null,
  115. afterSelectPermanentCoroutine: null,
  116. mode: SelectPermanentEffect.Mode.Destroy,
  117. cardEffect: activateClass);
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. }
  120. }
  121. }
  122. }
  123. }
  124. if (timing == EffectTiming.OnDestroyedAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("Play 1 [Agumon] from trash", CanUseCondition, card);
  128. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  129. cardEffects.Add(activateClass);
  130. string EffectDiscription()
  131. {
  132. return "[On Deletion] You may play 1 [Agumon] from your trash without paying the cost. If you have a Tamer with [Tai Kamiya] in its name, that Digimon gains <Rush> for the turn.";
  133. }
  134. bool CanSelectCardCondition(CardSource cardSource)
  135. {
  136. if (cardSource.CardNames.Contains("Agumon"))
  137. {
  138. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. bool PermanentCondition(Permanent permanent)
  146. {
  147. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  148. {
  149. if (permanent.IsTamer)
  150. {
  151. if (permanent.TopCard.ContainsCardName("Tai Kamiya"))
  152. {
  153. return true;
  154. }
  155. }
  156. }
  157. return false;
  158. }
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnTrash(card))
  166. {
  167. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  175. {
  176. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  177. {
  178. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  179. List<CardSource> selectedCards = new List<CardSource>();
  180. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  181. selectCardEffect.SetUp(
  182. canTargetCondition: CanSelectCardCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. canNoSelect: () => true,
  186. selectCardCoroutine: SelectCardCoroutine,
  187. afterSelectCardCoroutine: null,
  188. message: "Select 1 card to play.",
  189. maxCount: maxCount,
  190. canEndNotMax: false,
  191. isShowOpponent: true,
  192. mode: SelectCardEffect.Mode.Custom,
  193. root: SelectCardEffect.Root.Trash,
  194. customRootCardList: null,
  195. canLookReverseCard: true,
  196. selectPlayer: card.Owner,
  197. cardEffect: activateClass);
  198. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  199. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  200. yield return StartCoroutine(selectCardEffect.Activate());
  201. IEnumerator SelectCardCoroutine(CardSource cardSource)
  202. {
  203. selectedCards.Add(cardSource);
  204. yield return null;
  205. }
  206. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  207. cardSources: selectedCards,
  208. activateClass: activateClass,
  209. payCost: false,
  210. isTapped: false,
  211. root: SelectCardEffect.Root.Trash,
  212. activateETB: true));
  213. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  214. {
  215. foreach (CardSource cardSource in selectedCards)
  216. {
  217. Permanent permanent = cardSource.PermanentOfThisCard();
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  219. targetPermanent: permanent,
  220. effectDuration: EffectDuration.UntilEachTurnEnd,
  221. activateClass: activateClass));
  222. }
  223. }
  224. }
  225. }
  226. }
  227. return cardEffects;
  228. }
  229. }
  230. }