BT14_037.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_037 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnCounterTiming)
  12. {
  13. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  14. }
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Recovery +1 and opponent's 1 Digimon reduces DP", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[On Play] If you have 5 or fewer security cards, <Recovery +1 (Deck)>. Then, for the turn, 1 of your opponent's Digimon gets -1000 DP for each card in your security stack.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (card.Owner.SecurityCards.Count <= 5)
  38. {
  39. if (card.Owner.CanAddSecurity(activateClass))
  40. {
  41. if (card.Owner.LibraryCards.Count >= 1)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. if (card.Owner.SecurityCards.Count >= 1)
  48. {
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (card.Owner.SecurityCards.Count <= 5)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  62. }
  63. int minusDP = 1000 * card.Owner.SecurityCards.Count;
  64. if (minusDP > 0)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: SelectPermanentCoroutine,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{minusDP}.", $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  87. targetPermanent: permanent,
  88. changeValue: -minusDP,
  89. effectDuration: EffectDuration.UntilEachTurnEnd,
  90. activateClass: activateClass));
  91. }
  92. }
  93. }
  94. }
  95. }
  96. if (timing == EffectTiming.OnEnterFieldAnyone)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("Recovery +1 and opponent's 1 Digimon reduces DP", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[When Digivolving] If you have 5 or fewer security cards, <Recovery +1 (Deck)>. Then, for the turn, 1 of your opponent's Digimon gets -1000 DP for each card in your security stack.";
  105. }
  106. bool CanSelectPermanentCondition(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnBattleArea(card))
  117. {
  118. if (card.Owner.SecurityCards.Count <= 5)
  119. {
  120. if (card.Owner.CanAddSecurity(activateClass))
  121. {
  122. if (card.Owner.LibraryCards.Count >= 1)
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. if (card.Owner.SecurityCards.Count >= 1)
  129. {
  130. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  131. {
  132. return true;
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  139. {
  140. if (card.Owner.SecurityCards.Count <= 5)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  143. }
  144. int minusDP = 1000 * card.Owner.SecurityCards.Count;
  145. if (minusDP > 0)
  146. {
  147. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  148. {
  149. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: SelectPermanentCoroutine,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.Custom,
  162. cardEffect: activateClass);
  163. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{minusDP}.", $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  168. targetPermanent: permanent,
  169. changeValue: -minusDP,
  170. effectDuration: EffectDuration.UntilEachTurnEnd,
  171. activateClass: activateClass));
  172. }
  173. }
  174. }
  175. }
  176. }
  177. return cardEffects;
  178. }
  179. }
  180. }