BT17_020.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_020 : 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("Reveal the top 3 cards of deck", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  18. EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return
  23. "[On Play] Reveal the top 3 cards of your deck. Add 1 card with the [Hybrid]/[Ten Warriors] trait and 1 Tamer card with an inherited effect among them to the hand. Return the rest to the bottom of the deck.";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. return cardSource.HasHybridTenWarriorsTraits;
  28. }
  29. bool CanSelectTamerCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource.IsTamer)
  32. {
  33. if (cardSource.HasInheritedEffect)
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (card.Owner.LibraryCards.Count >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable hashtable)
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(
  58. CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  59. revealCount: 3,
  60. simplifiedSelectCardConditions:
  61. new SimplifiedSelectCardConditionClass[]
  62. {
  63. new(
  64. canTargetCondition: CanSelectCardCondition,
  65. message: "Select 1 card with the [Hybrid]/[Ten Warriors] trait.",
  66. mode: SelectCardEffect.Mode.AddHand,
  67. maxCount: 1,
  68. selectCardCoroutine: null),
  69. new(
  70. canTargetCondition: CanSelectTamerCardCondition,
  71. message: "Select 1 Tamer card with an inherited effect.",
  72. mode: SelectCardEffect.Mode.AddHand,
  73. maxCount: 1,
  74. selectCardCoroutine: null),
  75. },
  76. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  77. activateClass: activateClass
  78. ));
  79. }
  80. }
  81. #endregion
  82. #region When Attacking - ESS
  83. if (timing == EffectTiming.OnAllyAttack)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Play Tamer card from hand", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  88. EffectDescription());
  89. activateClass.SetIsInheritedEffect(true);
  90. cardEffects.Add(activateClass);
  91. string EffectDescription()
  92. {
  93. return
  94. "[When Attacking] [Once Per Turn] You may play 1 Tamer card with an inherited effect from your hand with the play cost reduced by 2.";
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  99. }
  100. bool CanSelectHandCardCondition(CardSource cardSource)
  101. {
  102. if (card.Owner.HandCards.Contains(cardSource))
  103. {
  104. if (cardSource.IsTamer)
  105. {
  106. if (cardSource.HasInheritedEffect)
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnBattleArea(card))
  117. {
  118. if (card.Owner.HandCards.Count(CanSelectHandCardCondition) >= 1)
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable hashtable)
  126. {
  127. #region Reduce Play Cost
  128. ChangeCostClass changeCostClass = new ChangeCostClass();
  129. changeCostClass.SetUpICardEffect($"Play Cost -2", _ => true, card);
  130. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CanSelectHandCardCondition,
  131. rootCondition: RootCondition, isUpDown: () => true, isCheckAvailability: () => false,
  132. isChangePayingCost: () => true);
  133. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  134. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  135. ICardEffect GetCardEffect(EffectTiming rcTiming)
  136. {
  137. if (rcTiming == EffectTiming.None)
  138. {
  139. return changeCostClass;
  140. }
  141. return null;
  142. }
  143. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  144. {
  145. if (CanSelectHandCardCondition(cardSource))
  146. {
  147. if (RootCondition(root))
  148. {
  149. if (PermanentsCondition(targetPermanents))
  150. {
  151. cost -= 2;
  152. }
  153. }
  154. }
  155. return cost;
  156. }
  157. bool PermanentsCondition(List<Permanent> targetPermanents)
  158. {
  159. if (targetPermanents == null)
  160. {
  161. return true;
  162. }
  163. return targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  164. }
  165. bool RootCondition(SelectCardEffect.Root root)
  166. {
  167. return true;
  168. }
  169. #endregion
  170. if (card.Owner.HandCards.Count(CanSelectHandCardCondition) >= 1)
  171. {
  172. List<CardSource> selectedCards = new List<CardSource>();
  173. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  174. selectHandEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanSelectHandCardCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: 1,
  180. canNoSelect: true,
  181. canEndNotMax: false,
  182. isShowOpponent: true,
  183. selectCardCoroutine: SelectCardCoroutine,
  184. afterSelectCardCoroutine: null,
  185. mode: SelectHandEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  188. "The opponent is selecting 1 Tamer card to play.");
  189. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  190. yield return StartCoroutine(selectHandEffect.Activate());
  191. IEnumerator SelectCardCoroutine(CardSource cardSource)
  192. {
  193. selectedCards.Add(cardSource);
  194. yield return null;
  195. }
  196. yield return ContinuousController.instance.StartCoroutine(
  197. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  198. payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  199. }
  200. #region Remove Reduce Cost effect
  201. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  202. #endregion
  203. }
  204. }
  205. #endregion
  206. return cardEffects;
  207. }
  208. }
  209. }