BT25_020.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. bool Condition()
  26. {
  27. return CardEffectCommons.HasMatchConditionPermanent(WouldPlayCondition);
  28. }
  29. bool WouldPlayCondition(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  32. && permanent.HasDP
  33. && permanent.DP >= 13000;
  34. }
  35. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  36. }
  37. #endregion
  38. #region Shared OP / WD / WA
  39. string SharedEffectName = "+3K DP to one of your digimon, 1 of your Digimon may battle an opponent's Digimon";
  40. 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.";
  41. CardEffectFactory.ActivateClassesForSharedEffects
  42. (ref cardEffects, timing, card,
  43. SharedEffectName,
  44. SharedActivateCoroutine,
  45. SharedEffectDescription,
  46. optional: false,
  47. onPlay: true,
  48. whenDigivolving: true,
  49. whenAttacking: true);
  50. bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  51. bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
  55. {
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: IsYourDigimon,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP +3000.", "The opponent is selecting 1 Digimon that will get DP +3000.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: 3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  74. }
  75. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimon))
  76. {
  77. //Select attacker
  78. Permanent selectedAttacker = null;
  79. SelectPermanentEffect selectAttackerEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. selectAttackerEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: IsYourDigimon,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. selectPermanentCoroutine: SelectAttackerCoroutine,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Custom,
  91. cardEffect: activateClass);
  92. selectAttackerEffect.SetUpCustomMessage("Select 1 of your Digimon to battle.", "The opponent is selecting Digimon to battle.");
  93. yield return ContinuousController.instance.StartCoroutine(selectAttackerEffect.Activate());
  94. IEnumerator SelectAttackerCoroutine(Permanent permanent)
  95. {
  96. selectedAttacker = permanent;
  97. yield return null;
  98. }
  99. if (selectedAttacker != null)
  100. {
  101. //select defender
  102. Permanent selectedDefender = null;
  103. SelectPermanentEffect selectDefenderEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  104. selectDefenderEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: IsEnemyDigimon,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: 1,
  110. canNoSelect: true,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: SelectDefenderCoroutine,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Custom,
  115. cardEffect: activateClass);
  116. selectDefenderEffect.SetUpCustomMessage("Select 1 enemy Digimon to battle.", "The opponent is selecting Digimon to battle.");
  117. yield return ContinuousController.instance.StartCoroutine(selectDefenderEffect.Activate());
  118. IEnumerator SelectDefenderCoroutine(Permanent permanent)
  119. {
  120. selectedDefender = permanent;
  121. yield return null;
  122. }
  123. if (selectedDefender != null)
  124. {
  125. yield return ContinuousController.instance.StartCoroutine(new IBattle(selectedAttacker, selectedDefender, null, true).Battle());
  126. }
  127. }
  128. }
  129. }
  130. }
  131. #endregion
  132. #region All Turns
  133. if (timing == EffectTiming.OnEndBattle)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Trash opponent's top security", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  138. activateClass.SetHashString("BT25_020_AT");
  139. cardEffects.Add(activateClass);
  140. string EffectDescription()
  141. {
  142. return "[All Turns] [Once Per Turn] When any of your [TS] trait Digimon win a battle, trash your opponent's top security card.";
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass))
  147. {
  148. bool WinnerCondition(Permanent permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.HasTSTraits;
  149. if (CardEffectCommons.CanTriggerWhenWinBattle(
  150. hashtable: hashtable,
  151. winnerCondition: WinnerCondition))
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  165. player: card.Owner.Enemy,
  166. destroySecurityCount: 1,
  167. cardEffect: activateClass,
  168. fromTop: true).DestroySecurity());
  169. }
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }