BT25_077.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Bacchusmon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent permanent)
  16. {
  17. return permanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  20. }
  21. #endregion
  22. #region Reduce Play Cost
  23. if (timing == EffectTiming.None)
  24. {
  25. bool Condition()
  26. {
  27. int totalLevels = GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  28. .Map(player => player.GetBattleAreaPermanents())
  29. .Flat()
  30. .Map(LevelFromPermanent)
  31. .Sum();
  32. return totalLevels >= 12;
  33. }
  34. int LevelFromPermanent(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  37. && permanent.TopCard.HasLevel)
  38. {
  39. return permanent.Level;
  40. }
  41. return 0;
  42. }
  43. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  44. }
  45. #endregion
  46. #region Shared OP / WD
  47. string SharedEffectName = "You may play 1 [TS] Digimon with 6k or less DP";
  48. string SharedEffectDescription(string tag)
  49. => $"[{tag}] You may play 1 [TS] trait Digimon card with 6000 DP or less from your hand without paying the cost.";
  50. bool CanPlayTSDigimonCondition(CardSource cardSource, ActivateClass activateClass)
  51. {
  52. return cardSource.IsDigimon
  53. && cardSource.HasPlayCost
  54. && cardSource.HasTSTraits
  55. && cardSource.HasDP
  56. && cardSource.CardDP <= 6000
  57. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  58. }
  59. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. return CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanPlayTSDigimonCondition(cardSource, activateClass));
  62. }
  63. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  66. canTargetCondition: cardSource => CanPlayTSDigimonCondition(cardSource, activateClass),
  67. SelectCardEffect.Root.Hand,
  68. activateClass,
  69. payCost: false
  70. ));
  71. }
  72. CardEffectFactory.ActivateClassesForSharedEffects
  73. (ref cardEffects, timing, card,
  74. SharedEffectName,
  75. SharedActivateCoroutine,
  76. SharedEffectDescription,
  77. additionalActivateCondition: AdditionalActivateCondition,
  78. optional: false,
  79. isSkippable: true,
  80. onPlay: true,
  81. whenDigivolving: true);
  82. #endregion
  83. #region All Turns
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("May suspend 1 Digimon. By Effect: Delete lowest DP enemy digimon", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  89. activateClass.SetIsSkippableFunction(IsOptional);
  90. activateClass.SetHashString("BT25_077_AT");
  91. cardEffects.Add(activateClass);
  92. string EffectDescription()
  93. => "[All Turns] [Once Per Turn] When any Digimon are played or digivolve, you may suspend 1 Digimon. Then, if played or digivolved by an effect, delete 1 of your opponent's lowest DP Digimon.";
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.IsExistOnBattleArea(card)
  97. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsDigimonCondition)
  98. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, IsDigimonCondition));
  99. }
  100. bool IsOptional(Hashtable hashtable)
  101. {
  102. return !CardEffectCommons.IsByEffect(hashtable, null);
  103. }
  104. bool IsDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  105. bool IsOpponentsWeakestDigimon(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  106. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  107. IEnumerator ActivateCoroutine(Hashtable hashtable)
  108. {
  109. bool isByEffect = CardEffectCommons.IsByEffect(hashtable, null);
  110. bool executed = false;
  111. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonCondition))
  112. {
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: IsDigimonCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: 1,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: null,
  123. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  124. mode: SelectPermanentEffect.Mode.Tap,
  125. cardEffect: activateClass);
  126. string message = isByEffect ? "Select a Digimon to suspend. Triggered by effect: After you will delete 1 enemy digimon." : "Select a Digimon to suspend. Not triggered by effect: Select \"No Selection\" to not expend the once per turn.";
  127. selectPermanentEffect.SetUpCustomMessage(message, "Opponent is selecting a Digimon to suspend.");
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  130. {
  131. if (permanents.Count > 0)
  132. executed = true;
  133. yield return null;
  134. }
  135. }
  136. if (isByEffect)
  137. {
  138. executed = true;
  139. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsWeakestDigimon))
  140. {
  141. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectPermanentEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: IsOpponentsWeakestDigimon,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: 1,
  148. canNoSelect: false,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: null,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Destroy,
  153. cardEffect: activateClass);
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. }
  156. }
  157. if (!executed) activateClass.RemoveUse();
  158. }
  159. }
  160. #endregion
  161. return cardEffects;
  162. }
  163. }
  164. }