EX4_010.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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_010 : 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.ContainsCardName("Growlmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Both players trash the top 3 cards of their decks and delete Digimon", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] Trash the top 3 cards of both players' decks. Then, choose any number of your opponent's Digimon so that their DP total is up to 3000 and delete them. For every 10 total cards in both players' trashes, add 2000 to the maximum this DP-based deletion effect can delete.";
  29. }
  30. int maxDP()
  31. {
  32. int maxDP = 3000;
  33. int trashSum = 0;
  34. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  35. {
  36. trashSum += player.TrashCards.Count;
  37. }
  38. maxDP += 2000 * (trashSum / 10);
  39. return maxDP;
  40. }
  41. bool CanSelectPermanentCondition(Permanent permanent)
  42. {
  43. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  44. {
  45. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (isExistOnField(card))
  59. {
  60. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  61. {
  62. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.LibraryCards.Count >= 1) >= 1)
  63. {
  64. return true;
  65. }
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. return false;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. if (isExistOnField(card))
  77. {
  78. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  79. {
  80. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  81. {
  82. if (player.LibraryCards.Count >= 1)
  83. {
  84. IAddTrashCardsFromLibraryTop addTrashCard = new IAddTrashCardsFromLibraryTop(3, player, activateClass);
  85. addTrashCard.SetNotShowCards();
  86. yield return ContinuousController.instance.StartCoroutine(addTrashCard.AddTrashCardsFromLibraryTop());
  87. if (player.isYou)
  88. {
  89. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(addTrashCard.discardedCards, "Your Discarded Cards", true, true));
  90. }
  91. else
  92. {
  93. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(addTrashCard.discardedCards, "Opponent's Discarded Cards", true, true));
  94. }
  95. }
  96. }
  97. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  98. {
  99. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectPermanentCondition,
  104. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  105. canEndSelectCondition: CanEndSelectCondition,
  106. maxCount: maxCount,
  107. canNoSelect: false,
  108. canEndNotMax: true,
  109. selectPermanentCoroutine: null,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Destroy,
  112. cardEffect: activateClass);
  113. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  114. bool CanEndSelectCondition(List<Permanent> permanents)
  115. {
  116. if (permanents.Count <= 0)
  117. {
  118. return false;
  119. }
  120. int sumDP = 0;
  121. foreach (Permanent permanent1 in permanents)
  122. {
  123. sumDP += permanent1.DP;
  124. }
  125. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  126. {
  127. return false;
  128. }
  129. return true;
  130. }
  131. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  132. {
  133. int sumDP = 0;
  134. foreach (Permanent permanent1 in permanents)
  135. {
  136. sumDP += permanent1.DP;
  137. }
  138. sumDP += permanent.DP;
  139. if (sumDP > card.Owner.MaxDP_DeleteEffect(maxDP(), activateClass))
  140. {
  141. return false;
  142. }
  143. return true;
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. return cardEffects;
  151. }
  152. }
  153. }