BT25_074.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Tankdramon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_074 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("D-Brigade")
  19. || targetPermanent.TopCard.EqualsTraits("ACCEL");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 4));
  22. }
  23. #endregion
  24. #region WD/WA Shared
  25. string SharedEffectName = "Reveal 3, may play 1 12 cost or lower [D-Brigade]/[ACCEL] trait with cost reduced by 5, trash rest";
  26. string SharedHashString = "BT25_074_WD_WA";
  27. CardEffectFactory.ActivateClassesForSharedEffects
  28. (ref cardEffects, timing, card,
  29. SharedEffectName,
  30. SharedActivateCoroutine,
  31. SharedEffectDescription,
  32. optional: false,
  33. maxCountPerTurn: 1,
  34. hashValue: SharedHashString,
  35. whenDigivolving: true,
  36. whenAttacking: true);
  37. string SharedEffectDescription(string tag)
  38. {
  39. return $"[{tag}] [Once Per Turn] Reveal the top 3 cards of your deck. You may play 1 cost 12 or lower [D-Brigade] or [ACCEL] trait card among them with the cost reduced by 5. Trash the rest.";
  40. }
  41. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  42. {
  43. bool CanSelectCardCondition(CardSource cardSource)
  44. {
  45. return cardSource.IsDigimon
  46. && cardSource.HasPlayCost
  47. && cardSource.GetCostItself <= 12
  48. && (cardSource.EqualsTraits("D-Brigade")
  49. || cardSource.EqualsTraits("ACCEL"))
  50. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: Math.Max(0, cardSource.GetCostItself - 5));
  51. }
  52. List<CardSource> selectedCards = new List<CardSource>();
  53. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  54. revealCount: 3,
  55. simplifiedSelectCardConditions:
  56. new SimplifiedSelectCardConditionClass[]
  57. {
  58. new SimplifiedSelectCardConditionClass(
  59. canTargetCondition:CanSelectCardCondition,
  60. message: "Select 1 play cost 12 or lower [D-Brigade] or [ACCEL] trait Digimon card to play with the cost reduced by 5.",
  61. mode: SelectCardEffect.Mode.Custom,
  62. maxCount: 1,
  63. selectCardCoroutine: SelectCardCoroutine),
  64. },
  65. remainingCardsPlace: RemainingCardsPlace.Trash,
  66. activateClass: activateClass,
  67. canNoSelect: true
  68. ));
  69. IEnumerator SelectCardCoroutine(CardSource cardSource)
  70. {
  71. selectedCards.Add(cardSource);
  72. yield return null;
  73. }
  74. #region reduce play cost
  75. ChangeCostClass changeCostClass = new ChangeCostClass();
  76. changeCostClass.SetUpICardEffect($"Play Cost -5", CanUseCondition1, card);
  77. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  78. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  79. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  80. ICardEffect GetCardEffect(EffectTiming _timing)
  81. {
  82. if (_timing == EffectTiming.None)
  83. {
  84. return changeCostClass;
  85. }
  86. return null;
  87. }
  88. bool CanUseCondition1(Hashtable hashtable) => true;
  89. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  90. {
  91. if (CardSourceCondition(cardSource)
  92. && RootCondition(root)
  93. && PermanentsCondition(targetPermanents))
  94. {
  95. Cost -= 5;
  96. }
  97. return Cost;
  98. }
  99. bool PermanentsCondition(List<Permanent> targetPermanents)
  100. {
  101. return targetPermanents == null || targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0;
  102. }
  103. bool CardSourceCondition(CardSource cardSource)
  104. {
  105. return true;
  106. }
  107. bool RootCondition(SelectCardEffect.Root root) => true;
  108. bool isUpDown() => true;
  109. #endregion
  110. #region Play the card
  111. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  112. cardSources: selectedCards,
  113. activateClass: activateClass,
  114. payCost: true,
  115. isTapped: false,
  116. root: SelectCardEffect.Root.Library,
  117. activateETB: true));
  118. #endregion
  119. #region release effect reducing play cost
  120. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  121. #endregion
  122. }
  123. #endregion
  124. #region All Turns
  125. if (timing == EffectTiming.OnEnterFieldAnyone)
  126. {
  127. ActivateClass activateClass = new ActivateClass();
  128. activateClass.SetUpICardEffect("1 enemy Digimon can't digivolve until their turn end", CanUseCondition, card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  130. activateClass.SetHashString("BT25_074_AT");
  131. cardEffects.Add(activateClass);
  132. string EffectDescription()
  133. {
  134. return "[All Turns] [Once Per Turn] When any of your [D-Brigade] or [ACCEL] trait Digimon are played, 1 of your opponent's Digimon can't digivolve until their turn ends.";
  135. }
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.IsExistOnBattleArea(card)
  139. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PlayedPermanentCondition);
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleArea(card);
  144. }
  145. bool PlayedPermanentCondition(Permanent permanent)
  146. {
  147. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  148. && (permanent.TopCard.EqualsTraits("D-Brigade")
  149. || permanent.TopCard.EqualsTraits("ACCEL"));
  150. }
  151. bool CanSelectPermanentCondition(Permanent targetPermanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card);
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  158. {
  159. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. selectPermanentEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: CanSelectPermanentCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: 1,
  166. canNoSelect: false,
  167. canEndNotMax: false,
  168. selectPermanentCoroutine: SelectPermanentCoroutine,
  169. afterSelectPermanentCoroutine: null,
  170. mode: SelectPermanentEffect.Mode.Custom,
  171. cardEffect: activateClass);
  172. selectPermanentEffect.SetUpCustomMessage("Select 1 card to prevent from digivolving.", "Opponent is selecting 1 card to prevent from digivolving.");
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. IEnumerator SelectPermanentCoroutine(Permanent selectedPermanent)
  175. {
  176. CanNotDigivolveClass canNotPutFieldClass = new CanNotDigivolveClass();
  177. canNotPutFieldClass.SetUpICardEffect("Can't Digivolve", CanUseCondition1, card);
  178. canNotPutFieldClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  179. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  180. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().DebuffSE);
  181. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  182. bool CanUseCondition1(Hashtable hashtable) => true;
  183. bool PermanentCondition(Permanent permanent)
  184. {
  185. return permanent == selectedPermanent
  186. && permanent.TopCard != null
  187. && !permanent.TopCard.CanNotBeAffected(canNotPutFieldClass);
  188. }
  189. bool CardCondition(CardSource cardSource)
  190. {
  191. return cardSource.Owner == card.Owner.Enemy
  192. && !cardSource.CanNotBeAffected(canNotPutFieldClass);
  193. }
  194. ICardEffect GetCardEffect(EffectTiming _timing)
  195. {
  196. if (_timing == EffectTiming.None)
  197. {
  198. return canNotPutFieldClass;
  199. }
  200. return null;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. #endregion
  207. #region Inherited - Opponent's turn Reboot and Blocker
  208. if (timing == EffectTiming.None)
  209. {
  210. bool Condition()
  211. {
  212. return CardEffectCommons.IsExistOnBattleArea(card)
  213. && CardEffectCommons.IsOpponentTurn(card)
  214. && (card.PermanentOfThisCard().TopCard.ContainsCardName("Chaosmon")
  215. || card.PermanentOfThisCard().TopCard.EqualsTraits("D-Brigade")
  216. || card.PermanentOfThisCard().TopCard.EqualsTraits("ACCEL"));
  217. }
  218. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  219. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }