BT11_056.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_056 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Digivolving] Reveal the top 3 cards of your deck. You may play 1 Tamer card among them without paying the cost. Place the rest at the top or bottom of your deck in any order.";
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource)
  22. {
  23. if (cardSource.IsTamer)
  24. {
  25. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (card.Owner.LibraryCards.Count >= 1)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. List<CardSource> selectedCards = new List<CardSource>();
  50. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  51. revealCount: 3,
  52. simplifiedSelectCardConditions:
  53. new SimplifiedSelectCardConditionClass[]
  54. {
  55. new SimplifiedSelectCardConditionClass(
  56. canTargetCondition:CanSelectCardCondition,
  57. message: "Select 1 Tamer card.",
  58. mode: SelectCardEffect.Mode.Custom,
  59. maxCount: 1,
  60. selectCardCoroutine: SelectCardCoroutine),
  61. },
  62. remainingCardsPlace: RemainingCardsPlace.DeckTopOrBottom,
  63. activateClass: activateClass,
  64. canNoSelect: true
  65. ));
  66. IEnumerator SelectCardCoroutine(CardSource cardSource)
  67. {
  68. selectedCards.Add(cardSource);
  69. yield return null;
  70. }
  71. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  72. cardSources: selectedCards,
  73. activateClass: activateClass,
  74. payCost: false,
  75. isTapped: false,
  76. root: SelectCardEffect.Root.Library,
  77. activateETB: true));
  78. }
  79. }
  80. if (timing == EffectTiming.OnAllyAttack)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect("Reveal the top cards of deck and play Digimon", CanUseCondition, card);
  84. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  85. activateClass.SetHashString("Reveal_BT11_056");
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[When Attacking][Once Per Turn] For each green or black Tamer you have in play, reveal 1 card from the top of your deck. You may play any number of green or black Digimon cards whose total play costs add up to 10 or less among them without paying the costs. Place the rest at the bottom of your deck in any order.";
  90. }
  91. bool CanSelectCardCondition(CardSource cardSource)
  92. {
  93. if (cardSource.IsDigimon)
  94. {
  95. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  96. {
  97. if (cardSource.GetCostItself <= 10)
  98. {
  99. if (cardSource.HasPlayCost)
  100. {
  101. if (cardSource.HasCardColor(CardColor.Green) || cardSource.HasCardColor(CardColor.Black))
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.IsExistOnBattleArea(card))
  118. {
  119. return true;
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. int revealCount = card.Owner.GetBattleAreaPermanents().Count((permanent) => (permanent.TopCard.CardColors.Contains(CardColor.Green) || permanent.TopCard.CardColors.Contains(CardColor.Black)) && permanent.IsTamer);
  126. int maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
  127. List<CardSource> selectedCards = new List<CardSource>();
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  129. revealCount: revealCount,
  130. simplifiedSelectCardConditions:
  131. new SimplifiedSelectCardConditionClass[]
  132. {
  133. new SimplifiedSelectCardConditionClass(
  134. canTargetCondition:CanSelectCardCondition,
  135. message: "Select green or black Digimon cards whose total play costs add up to 10 or less.",
  136. mode: SelectCardEffect.Mode.Custom,
  137. maxCount: maxCount,
  138. selectCardCoroutine: SelectCardCoroutine),
  139. },
  140. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  141. activateClass: activateClass,
  142. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  143. canEndSelectCondition: CanEndSelectCondition,
  144. canNoSelect: true,
  145. canEndNotMax: true
  146. ));
  147. IEnumerator SelectCardCoroutine(CardSource cardSource)
  148. {
  149. selectedCards.Add(cardSource);
  150. yield return null;
  151. }
  152. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  153. {
  154. int sumCost = 0;
  155. foreach (CardSource cardSource1 in cardSources)
  156. {
  157. sumCost += cardSource1.GetCostItself;
  158. }
  159. sumCost += cardSource.GetCostItself;
  160. if (sumCost > 10)
  161. {
  162. return false;
  163. }
  164. return true;
  165. }
  166. bool CanEndSelectCondition(List<CardSource> cardSources)
  167. {
  168. if (maxCount >= 1)
  169. {
  170. if (cardSources.Count <= 0)
  171. {
  172. return false;
  173. }
  174. }
  175. int sumCost = 0;
  176. foreach (CardSource cardSource1 in cardSources)
  177. {
  178. sumCost += cardSource1.GetCostItself;
  179. }
  180. if (sumCost > 10)
  181. {
  182. return false;
  183. }
  184. return true;
  185. }
  186. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  187. cardSources: selectedCards,
  188. activateClass: activateClass,
  189. payCost: false,
  190. isTapped: false,
  191. root: SelectCardEffect.Root.Library,
  192. activateETB: true));
  193. }
  194. }
  195. return cardEffects;
  196. }
  197. }
  198. }