BT17_058.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_058 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Piercing
  12. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  13. {
  14. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. #endregion
  17. #region On Play/When Digivolving Shared
  18. bool IsSelectableSource(CardSource source)
  19. {
  20. if (source.IsDigimon)
  21. {
  22. if (source.HasCardColor(CardColor.Black))
  23. {
  24. if (source.HasLevel && source.Level <= 5)
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. #endregion
  31. #region On Play
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Reveal 3, Place 1 black level 5 or lower Digimon as bottom digivolution source", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[On Play] Reveal the top 3 cards of your deck. Place 1 level 5 or lower black Digimon card among them as this Digimon's bottom digivolution card. Trash the rest.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. return false;
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  57. revealCount: 3,
  58. simplifiedSelectCardConditions:
  59. new SimplifiedSelectCardConditionClass[]
  60. {
  61. new SimplifiedSelectCardConditionClass(
  62. canTargetCondition:IsSelectableSource,
  63. message: "Select 1 Black Level 5 or lower Digimon.",
  64. mode: SelectCardEffect.Mode.Custom,
  65. maxCount: 1,
  66. selectCardCoroutine: SelectedCardToSources),
  67. },
  68. remainingCardsPlace: RemainingCardsPlace.Trash,
  69. activateClass: activateClass,
  70. canNoSelect: false
  71. ));
  72. IEnumerator SelectedCardToSources(CardSource source)
  73. {
  74. if (source != null)
  75. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource> { source }, activateClass));
  76. }
  77. }
  78. }
  79. #endregion
  80. #region When Digivolving
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect("Reveal 3, Place 1 black level 5 or lower Digimon as bottom digivolution source", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[When Digivolving] Reveal the top 3 cards of your deck. Place 1 level 5 or lower black Digimon card among them as this Digimon's bottom digivolution card. Trash the rest.";
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  94. {
  95. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  96. }
  97. return false;
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable hashtable)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  106. revealCount: 3,
  107. simplifiedSelectCardConditions:
  108. new SimplifiedSelectCardConditionClass[]
  109. {
  110. new SimplifiedSelectCardConditionClass(
  111. canTargetCondition:IsSelectableSource,
  112. message: "Select 1 Black Level 5 or lower Digimon.",
  113. mode: SelectCardEffect.Mode.Custom,
  114. maxCount: 1,
  115. selectCardCoroutine: SelectedCardToSources),
  116. },
  117. remainingCardsPlace: RemainingCardsPlace.Trash,
  118. activateClass: activateClass,
  119. canNoSelect: false
  120. ));
  121. IEnumerator SelectedCardToSources(CardSource source)
  122. {
  123. if (source != null)
  124. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource> { source }, activateClass));
  125. }
  126. }
  127. }
  128. #endregion
  129. #region End Of Attack
  130. if (timing == EffectTiming.OnEndAttack)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Play 1 level 5 or lower digimon with [Machine] trait", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  135. activateClass.SetHashString("EndOfAttack_BT17_058");
  136. cardEffects.Add(activateClass);
  137. string EffectDiscription()
  138. {
  139. return "[End of Attack] [Once Per Turn] You may play 1 level 5 or lower Digimon card with the [Machine] trait from this Digimon's digivolution cards without paying the cost.";
  140. }
  141. bool CanSelectSourceCard(CardSource source)
  142. {
  143. if (source.IsDigimon)
  144. {
  145. if(source.HasLevel && source.Level <= 5)
  146. {
  147. if (source.CardTraits.Contains("Machine"))
  148. {
  149. if (CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass))
  150. {
  151. return true;
  152. }
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  161. {
  162. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable, card))
  163. return true;
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  170. {
  171. if(card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCard) > 0)
  172. return true;
  173. }
  174. return false;
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable hashtable)
  177. {
  178. Permanent permanent = card.PermanentOfThisCard();
  179. if (permanent.DigivolutionCards.Count(CanSelectSourceCard) >= 1)
  180. {
  181. List<CardSource> selectedCards = new List<CardSource>();
  182. int maxCount = 1;
  183. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  184. selectCardEffect.SetUp(
  185. canTargetCondition: CanSelectSourceCard,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. canNoSelect: () => true,
  189. selectCardCoroutine: SelectCardCoroutine,
  190. afterSelectCardCoroutine: null,
  191. message: "Select 1 card to play.",
  192. maxCount: maxCount,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. mode: SelectCardEffect.Mode.Custom,
  196. root: SelectCardEffect.Root.Custom,
  197. customRootCardList: permanent.DigivolutionCards,
  198. canLookReverseCard: true,
  199. selectPlayer: card.Owner,
  200. cardEffect: activateClass);
  201. selectCardEffect.SetUpCustomMessage(
  202. "Select 1 digivolution card to play.",
  203. "The opponent is selecting 1 digivolution card to play.");
  204. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  205. yield return StartCoroutine(selectCardEffect.Activate());
  206. IEnumerator SelectCardCoroutine(CardSource cardSource)
  207. {
  208. selectedCards.Add(cardSource);
  209. yield return null;
  210. }
  211. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  212. cardSources: selectedCards,
  213. activateClass: activateClass,
  214. payCost: false,
  215. isTapped: false,
  216. root: SelectCardEffect.Root.DigivolutionCards,
  217. activateETB: true));
  218. }
  219. }
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }