BT25_020.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Marsmon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_020 : 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.EqualsTraits("TS");
  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. ChangeCostClass changeCostClass = new ChangeCostClass();
  26. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  27. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  28. changeCostClass.SetNotShowUI(true);
  29. cardEffects.Add(changeCostClass);
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.HasMatchConditionPermanent(WouldPlayCondition);
  33. }
  34. bool WouldPlayCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  37. && permanent.HasDP
  38. && permanent.DP >= 13000;
  39. }
  40. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  41. List<Permanent> targetPermanents)
  42. {
  43. if (CardSourceCondition(cardSource) &&
  44. RootCondition(root) &&
  45. PermanentsCondition(targetPermanents))
  46. {
  47. cost -= 5;
  48. }
  49. return cost;
  50. }
  51. bool PermanentsCondition(List<Permanent> targetPermanents)
  52. {
  53. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  54. }
  55. bool CardSourceCondition(CardSource cardSource)
  56. {
  57. return cardSource == card;
  58. }
  59. bool RootCondition(SelectCardEffect.Root root)
  60. {
  61. return true;
  62. }
  63. bool isUpDown()
  64. {
  65. return true;
  66. }
  67. }
  68. #endregion
  69. #region Shared OP / WD / WA
  70. string SharedEffectName = "+3K DP to one of your digimon, 1 of your Digimon may battle an opponent's Digimon";
  71. string SharedEffectDescription(string tag) => $"[{tag}] 1 of your Digimon gets +3000 DP for the turn. Then, 1 of your Digimon may battle 1 of your opponent's Digimon.";
  72. CardEffectFactory.ActivateClassesForSharedEffects
  73. (ref cardEffects, timing, card,
  74. SharedEffectName,
  75. SharedActivateCoroutine,
  76. SharedEffectDescription,
  77. optional: false,
  78. onPlay: true,
  79. whenDigivolving: true,
  80. whenAttacking: true);
  81. bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  82. bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  83. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  84. {
  85. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
  86. {
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: IsYourDigimon,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: 1,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP +3000.", "The opponent is selecting 1 Digimon that will get DP +3000.");
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: 3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  105. }
  106. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimon))
  107. {
  108. //Select attacker
  109. Permanent selectedAttacker = null;
  110. SelectPermanentEffect selectAttackerEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectAttackerEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: IsYourDigimon,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: 1,
  117. canNoSelect: true,
  118. canEndNotMax: false,
  119. selectPermanentCoroutine: SelectAttackerCoroutine,
  120. afterSelectPermanentCoroutine: null,
  121. mode: SelectPermanentEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectAttackerEffect.SetUpCustomMessage("Select 1 of your Digimon to battle.", "The opponent is selecting Digimon to battle.");
  124. yield return ContinuousController.instance.StartCoroutine(selectAttackerEffect.Activate());
  125. IEnumerator SelectAttackerCoroutine(Permanent permanent)
  126. {
  127. selectedAttacker = permanent;
  128. yield return null;
  129. }
  130. if (selectedAttacker != null)
  131. {
  132. //select defender
  133. Permanent selectedDefender = null;
  134. SelectPermanentEffect selectDefenderEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectDefenderEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: IsEnemyDigimon,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: 1,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectDefenderCoroutine,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectDefenderEffect.SetUpCustomMessage("Select 1 enemy Digimon to battle.", "The opponent is selecting Digimon to battle.");
  148. yield return ContinuousController.instance.StartCoroutine(selectDefenderEffect.Activate());
  149. IEnumerator SelectDefenderCoroutine(Permanent permanent)
  150. {
  151. selectedDefender = permanent;
  152. yield return null;
  153. }
  154. if (selectedDefender != null)
  155. {
  156. yield return ContinuousController.instance.StartCoroutine(new IBattle(selectedAttacker, selectedDefender, null, true).Battle());
  157. }
  158. }
  159. }
  160. }
  161. }
  162. #endregion
  163. #region All Turns
  164. if (timing == EffectTiming.OnEndBattle)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect("Trash opponent's top security", CanUseCondition, card);
  168. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  169. activateClass.SetHashString("BT25_020_AT");
  170. cardEffects.Add(activateClass);
  171. string EffectDescription()
  172. {
  173. return "[All Turns] [Once Per Turn] When any of your [TS] trait Digimon win a battle, trash your opponent's top security card.";
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleArea(card))
  178. {
  179. bool WinnerCondition(Permanent permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.HasTSTraits;
  180. if (CardEffectCommons.CanTriggerWhenWinBattle(
  181. hashtable: hashtable,
  182. winnerCondition: WinnerCondition))
  183. {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable hashtable)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  196. player: card.Owner.Enemy,
  197. destroySecurityCount: 1,
  198. cardEffect: activateClass,
  199. fromTop: true).DestroySecurity());
  200. }
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }