EX4_031.cs 10.0 KB

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