BT25_018.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Apollomon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_018 : 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. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  21. }
  22. #endregion
  23. #region Reduce Play Cost
  24. if (timing == EffectTiming.None)
  25. {
  26. ChangeCostClass changeCostClass = new ChangeCostClass();
  27. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  28. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  29. changeCostClass.SetNotShowUI(true);
  30. cardEffects.Add(changeCostClass);
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.HasMatchConditionOpponentsPermanent(card, Level6EnemyDigimon);
  34. }
  35. bool Level6EnemyDigimon(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  38. && permanent.HasDP
  39. && permanent.DP >= 12000;
  40. }
  41. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  42. List<Permanent> targetPermanents)
  43. {
  44. if (CardSourceCondition(cardSource) &&
  45. RootCondition(root) &&
  46. PermanentsCondition(targetPermanents))
  47. {
  48. cost -= 5;
  49. }
  50. return cost;
  51. }
  52. bool PermanentsCondition(List<Permanent> targetPermanents)
  53. {
  54. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  55. }
  56. bool CardSourceCondition(CardSource cardSource)
  57. {
  58. return cardSource == card;
  59. }
  60. bool RootCondition(SelectCardEffect.Root root)
  61. {
  62. return true;
  63. }
  64. bool isUpDown()
  65. {
  66. return true;
  67. }
  68. }
  69. #endregion
  70. #region Shared Condition and Deletion
  71. bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  72. bool CanDeleteCondition(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  75. && permanent.HasDP
  76. && permanent.DP < card.PermanentOfThisCard().DP;
  77. }
  78. IEnumerator DeleteWeakerDigimon(ActivateClass activateClass)
  79. {
  80. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanDeleteCondition))
  81. {
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanDeleteCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: 1,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Destroy,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. }
  97. }
  98. #endregion
  99. #region Shared OP / WD
  100. string SharedEffectName = "-2k for each of your Digimon to all opponent's digimon until end of the turn. Delete 1 enemy Digimon with equal or less DP than this digimon";
  101. string SharedEffectDescription(string tag)
  102. => $"[{tag}] For the turn, all of your opponent's Digimon get -2000 DP for each of your Digimon. Then, delete 1 of their Digimon with as much DP as this Digimon or less.";
  103. bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  104. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  105. {
  106. int reduction = -2000 * CardEffectCommons.MatchConditionPermanentCount(IsYourDigimon);
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  108. permanentCondition: IsEnemyDigimon,
  109. changeValue: reduction,
  110. effectDuration: EffectDuration.UntilEachTurnEnd,
  111. activateClass: activateClass));
  112. yield return ContinuousController.instance.StartCoroutine(DeleteWeakerDigimon(activateClass));
  113. }
  114. CardEffectFactory.ActivateClassesForSharedEffects
  115. (ref cardEffects, timing, card,
  116. SharedEffectName,
  117. SharedActivateCoroutine,
  118. SharedEffectDescription,
  119. optional: false,
  120. onPlay: true,
  121. whenDigivolving: true);
  122. #endregion
  123. #region End of your Turn
  124. if (timing == EffectTiming.OnEndTurn)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("DNA digivolve into [GraceNovamon]. 1 of your Digimon may attack.", CanUseCondition, card);
  128. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  129. cardEffects.Add(activateClass);
  130. string EffectDescription()
  131. => "[End of Your Turn] 2 of your Digimon may DNA digivolve into [GraceNovamon] in the hand. Then, 1 of your Digimon may attack.";
  132. bool CanSelectDNACardCondition(CardSource cardSource)
  133. {
  134. return cardSource.IsDigimon
  135. && cardSource.CanPlayJogress(true)
  136. && cardSource.EqualsCardName("GraceNovamon");
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleArea(card)
  141. && CardEffectCommons.IsOwnerTurn(card);
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleArea(card);
  146. }
  147. bool YourDigimonThatCanAttack(Permanent permanent)
  148. {
  149. return IsYourDigimon(permanent)
  150. && permanent.CanAttack(activateClass);
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable hashtable)
  153. {
  154. #region DNA digivolve
  155. yield return ContinuousController.instance.StartCoroutine(
  156. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  157. CanSelectDNACardCondition,
  158. payCost: true,
  159. isHand: true,
  160. activateClass
  161. ));
  162. #endregion
  163. #region May Attack
  164. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, YourDigimonThatCanAttack))
  165. {
  166. SelectPermanentEffect selectPermanentEffect =
  167. GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: YourDigimonThatCanAttack,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: 1,
  174. canNoSelect: true,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: null,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Attack,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  181. "The opponent is selecting 1 Digimon that will attack.");
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. }
  184. #endregion
  185. }
  186. }
  187. #endregion
  188. #region When Attacking ESS
  189. if (timing == EffectTiming.OnAllyAttack)
  190. {
  191. ActivateClass activateClass = new ActivateClass();
  192. activateClass.SetUpICardEffect("Delete 1 enemy digimon with DP equal or less", CanUseCondition, card);
  193. activateClass.SetUpActivateClass(CanActivateCondition, _ => DeleteWeakerDigimon(activateClass), 1, false, EffectDescription());
  194. activateClass.SetIsInheritedEffect(true);
  195. activateClass.SetHashString("BT25_018_WA_ESS");
  196. cardEffects.Add(activateClass);
  197. string EffectDescription()
  198. => "[When Attacking] [Once Per Turn] Delete 1 of your opponent's Digimon with as much DP as this Digimon or less.";
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsExistOnBattleArea(card)
  202. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleArea(card);
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }