BT25_059.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Ceresmon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_059 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasTSTraits
  19. || permanent.TopCard.EqualsTraits("Vegetation");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  22. }
  23. #endregion
  24. #region Shared Conditions
  25. bool IsSuspendedDigimon(Permanent permanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  28. && permanent.IsSuspended;
  29. }
  30. #endregion
  31. #region Reduce Play Cost
  32. if (timing == EffectTiming.None)
  33. {
  34. ChangeCostClass changeCostClass = new ChangeCostClass();
  35. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  36. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  37. changeCostClass.SetNotShowUI(true);
  38. cardEffects.Add(changeCostClass);
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.MatchConditionPermanentCount(IsSuspendedDigimon) >= 2;
  42. }
  43. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  44. List<Permanent> targetPermanents)
  45. {
  46. if (CardSourceCondition(cardSource) &&
  47. RootCondition(root) &&
  48. PermanentsCondition(targetPermanents))
  49. {
  50. cost -= 5;
  51. }
  52. return cost;
  53. }
  54. bool PermanentsCondition(List<Permanent> targetPermanents)
  55. {
  56. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  57. }
  58. bool CardSourceCondition(CardSource cardSource)
  59. {
  60. return cardSource == card;
  61. }
  62. bool RootCondition(SelectCardEffect.Root root)
  63. {
  64. return true;
  65. }
  66. bool isUpDown()
  67. {
  68. return true;
  69. }
  70. }
  71. #endregion
  72. #region Shared OP / WD
  73. string SharedEffectName = "You may suspend 2 digimon. Your suspended [Vegetation]/[TS] Digimon are immune to opponent's Digimon Effects until end of opponents turn";
  74. string SharedEffectDescription(string tag)
  75. => $"[{tag}] You may suspend up to 2 Digimon. Then, none of your suspended [Vegetation] or [TS] trait Digimon are affected by your opponent's Digimon effects until their turn ends.";
  76. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  77. {
  78. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon));
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. selectPermanentEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: maxCount,
  86. canNoSelect: true,
  87. canEndNotMax: true,
  88. selectPermanentCoroutine: null,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Tap,
  91. cardEffect: activateClass);
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. #region Effect Immunity
  94. bool CanUseCondition1(Hashtable hashtable)
  95. {
  96. return true;
  97. }
  98. bool CardCondition(CardSource cardSource)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource)
  101. && cardSource == cardSource.PermanentOfThisCard().TopCard
  102. && cardSource.PermanentOfThisCard().IsSuspended
  103. && (cardSource.HasTSTraits || cardSource.EqualsTraits("Vegetation"));
  104. }
  105. bool SkillCondition(ICardEffect cardEffect)
  106. {
  107. return CardEffectCommons.IsOpponentEffect(cardEffect, card)
  108. && cardEffect.IsDigimonEffect;
  109. }
  110. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  111. canNotAffectedClass.SetUpICardEffect("Not affected by opponent's Digimon's effects", CanUseCondition1, card);
  112. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  113. CardEffectCommons.AddEffectToPlayer(EffectDuration.UntilOpponentTurnEnd, card, canNotAffectedClass, EffectTiming.None);
  114. #endregion
  115. }
  116. CardEffectFactory.ActivateClassesForSharedEffects
  117. (ref cardEffects, timing, card,
  118. SharedEffectName,
  119. SharedActivateCoroutine,
  120. SharedEffectDescription,
  121. optional: false,
  122. onPlay: true,
  123. whenDigivolving: true);
  124. #endregion
  125. #region All turns
  126. if (timing == EffectTiming.OnTappedAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("-3k to 1 enemy digimon per suspended digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription1());
  131. activateClass.SetHashString("BT25_059_AT");
  132. cardEffects.Add(activateClass);
  133. string EffectDescription1()
  134. {
  135. return "[All Turns] [Once Per Turn] When any Digimon suspend, to 1 of your opponent's Digimon, give -3000 DP until their ends for each suspended Digimon.";
  136. }
  137. bool CanSelectPermanentCondition(Permanent permanent)
  138. {
  139. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  140. }
  141. bool CanTriggerPermanent(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  148. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, CanTriggerPermanent);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  153. }
  154. IEnumerator ActivateCoroutine(Hashtable hashtable)
  155. {
  156. int reduction = -3000 * CardEffectCommons.MatchConditionPermanentCount(IsSuspendedDigimon);
  157. if (reduction < 0 && 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($"Choose a digimon to give {reduction} DP.", $"Opponent is choosing a digimon to give {reduction} DP.");
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  177. targetPermanent: permanent,
  178. changeValue: reduction,
  179. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  180. activateClass: activateClass));
  181. }
  182. }
  183. }
  184. }
  185. #endregion
  186. return cardEffects;
  187. }
  188. }
  189. }