BT14_098.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_098 : 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.OptionSkill)
  13. {
  14. int maxCost = 6;
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] <De-Digivolve 1> 1 of your opponent's Digimon. Then, by returning 3 cards with the [D-Brigade] or [DigiPolice] trait from your trash to the top of the deck, delete up to 6 play cost's total worth of your opponent's Digimon.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. if (cardSource.CardTraits.Contains("D-Brigade"))
  30. {
  31. return true;
  32. }
  33. if (cardSource.CardTraits.Contains("DigiPolice"))
  34. {
  35. return true;
  36. }
  37. return false;
  38. }
  39. bool CanSelectPermanentCondition1(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  42. {
  43. if (permanent.TopCard.GetCostItself <= maxCost)
  44. {
  45. if (permanent.TopCard.HasPlayCost)
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: SelectPermanentCoroutine,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  78. {
  79. Permanent selectedPermanent = permanent;
  80. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  81. }
  82. }
  83. bool returned = false;
  84. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 3)
  85. {
  86. int maxCount = 3;
  87. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  88. selectCardEffect.SetUp(
  89. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. canNoSelect: () => true,
  93. selectCardCoroutine: null,
  94. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  95. message: "Select cards to place at the top of the deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  96. maxCount: maxCount,
  97. canEndNotMax: false,
  98. isShowOpponent: false,
  99. mode: SelectCardEffect.Mode.Custom,
  100. root: SelectCardEffect.Root.Trash,
  101. customRootCardList: null,
  102. canLookReverseCard: true,
  103. selectPlayer: card.Owner,
  104. cardEffect: activateClass);
  105. selectCardEffect.SetNotAddLog();
  106. selectCardEffect.SetUpCustomMessage_ShowCard("Deck Top Cards");
  107. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  108. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  109. {
  110. if (cardSources.Count == 3)
  111. {
  112. cardSources.Reverse();
  113. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(cardSources));
  114. returned = true;
  115. }
  116. }
  117. }
  118. if (returned)
  119. {
  120. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  121. {
  122. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1);
  123. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  124. selectPermanentEffect.SetUp(
  125. selectPlayer: card.Owner,
  126. canTargetCondition: CanSelectPermanentCondition1,
  127. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  128. canEndSelectCondition: CanEndSelectCondition,
  129. maxCount: maxCount,
  130. canNoSelect: false,
  131. canEndNotMax: true,
  132. selectPermanentCoroutine: null,
  133. afterSelectPermanentCoroutine: null,
  134. mode: SelectPermanentEffect.Mode.Destroy,
  135. cardEffect: activateClass);
  136. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  137. bool CanEndSelectCondition(List<Permanent> permanents)
  138. {
  139. if (permanents.Count <= 0)
  140. {
  141. return false;
  142. }
  143. int sumCost = 0;
  144. foreach (Permanent permanent1 in permanents)
  145. {
  146. sumCost += permanent1.TopCard.GetCostItself;
  147. }
  148. if (sumCost > maxCost)
  149. {
  150. return false;
  151. }
  152. return true;
  153. }
  154. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  155. {
  156. int sumCost = 0;
  157. foreach (Permanent permanent1 in permanents)
  158. {
  159. sumCost += permanent1.TopCard.GetCostItself;
  160. }
  161. sumCost += permanent.TopCard.GetCostItself;
  162. if (sumCost > maxCost)
  163. {
  164. return false;
  165. }
  166. return true;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. if (timing == EffectTiming.SecuritySkill)
  173. {
  174. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"De-Digivolve 1 on 1 Digimon and return cards from trash to deck top to delete Digimon");
  175. }
  176. return cardEffects;
  177. }
  178. }
  179. }