BT14_060.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_060 : 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.None)
  12. {
  13. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  14. changeCardNamesClass.SetUpICardEffect("Also treated as [Commandramon]", CanUseCondition, card);
  15. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  16. cardEffects.Add(changeCardNamesClass);
  17. bool CanUseCondition(Hashtable hashtable)
  18. {
  19. return true;
  20. }
  21. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  22. {
  23. if (cardSource == card)
  24. {
  25. CardNames.Add("Commandramon");
  26. }
  27. return CardNames;
  28. }
  29. }
  30. if (timing == EffectTiming.OnAllyAttack)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[When Attacking] Reveal the top 3 cards of your deck. You may play 1 card with the [D-Brigade] or [DigiPolice] trait and a play cost of 3 or less among them without paying the cost. Return the rest to the bottom of the deck.";
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  43. {
  44. if (cardSource.GetCostItself <= 3)
  45. {
  46. if (cardSource.HasPlayCost)
  47. {
  48. if (cardSource.CardTraits.Contains("D-Brigade"))
  49. {
  50. return true;
  51. }
  52. if (cardSource.CardTraits.Contains("DigiPolice"))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnBattleArea(card))
  68. {
  69. if (card.Owner.LibraryCards.Count >= 1)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. List<CardSource> selectedCards = new List<CardSource>();
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  80. revealCount: 3,
  81. simplifiedSelectCardConditions:
  82. new SimplifiedSelectCardConditionClass[]
  83. {
  84. new SimplifiedSelectCardConditionClass(
  85. canTargetCondition:CanSelectCardCondition,
  86. message: "Select 1 card with the [D-Brigade] or [DigiPolice] trait and a play cost of 3 or less.",
  87. mode: SelectCardEffect.Mode.Custom,
  88. maxCount: 1,
  89. selectCardCoroutine: SelectCardCoroutine),
  90. },
  91. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  92. activateClass: activateClass,
  93. canNoSelect: true
  94. ));
  95. IEnumerator SelectCardCoroutine(CardSource cardSource)
  96. {
  97. selectedCards.Add(cardSource);
  98. yield return null;
  99. }
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  101. cardSources: selectedCards,
  102. activateClass: activateClass,
  103. payCost: false,
  104. isTapped: false,
  105. root: SelectCardEffect.Root.Library,
  106. activateETB: true));
  107. }
  108. }
  109. if (timing == EffectTiming.WhenRemoveField)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Delete your 1 other Digimon to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  114. activateClass.SetIsInheritedEffect(true);
  115. activateClass.SetHashString("Substitute_BT14_060");
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[All Turns][Once Per Turn] When this Digimon would leave the battle area other than by one of your effects, by deleting 1 of your other Digimon with the [D-Brigade] trait, prevent it from leaving.";
  120. }
  121. bool CanSelectPermanentCondition(Permanent permanent)
  122. {
  123. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  124. {
  125. if (permanent != card.PermanentOfThisCard())
  126. {
  127. if (permanent.TopCard.CardTraits.Contains("D-Brigade"))
  128. {
  129. return true;
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  140. {
  141. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. return false;
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleArea(card))
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. Permanent thisCardPermanent = card.PermanentOfThisCard();
  165. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  166. {
  167. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectPermanentCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: maxCount,
  175. canNoSelect: true,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  186. targetPermanents: new List<Permanent>() { permanent },
  187. activateClass: activateClass,
  188. successProcess: permanents => SuccessProcess(),
  189. failureProcess: null));
  190. IEnumerator SuccessProcess()
  191. {
  192. thisCardPermanent.willBeRemoveField = false;
  193. thisCardPermanent.HideDeleteEffect();
  194. thisCardPermanent.HideHandBounceEffect();
  195. thisCardPermanent.HideDeckBounceEffect();
  196. thisCardPermanent.HideWillRemoveFieldEffect();
  197. yield return null;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. return cardEffects;
  205. }
  206. }
  207. }