BT19_096.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_096 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Option Main
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Place 1 [Royal Base] face up as bottom security, delete up to 8 play cost total", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] You may place 1 [Royal Base] trait Digimon card from your trash face up as your bottom security card. Then, delete up to 8 play cost's total worth of your opponent's Digimon. For each of your face up security cards, add 2 to the maximum play cost you may choose with this effect.";
  21. }
  22. int MaxCost()
  23. {
  24. int maxCost = 8;
  25. maxCost += card.Owner.SecurityCards.Count(source => !source.IsFlipped) * 2;
  26. return maxCost;
  27. }
  28. bool IsRoyalBaseDigimon(CardSource card)
  29. {
  30. return card.IsDigimon &&
  31. card.EqualsTraits("Royal Base");
  32. }
  33. bool IsOpponenetsDigimon(Permanent permanent)
  34. {
  35. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  36. {
  37. if (permanent.TopCard.GetCostItself <= MaxCost())
  38. {
  39. if (permanent.TopCard.HasPlayCost)
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. if(CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsRoyalBaseDigimon) && card.Owner.CanAddSecurity(activateClass))
  54. {
  55. CardSource selectedCard = null;
  56. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  57. selectCardEffect.SetUp(
  58. canTargetCondition: IsRoyalBaseDigimon,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. canNoSelect: () => true,
  62. selectCardCoroutine: SelectCardCoroutine,
  63. afterSelectCardCoroutine: null,
  64. message: "Select 1 card to place as face up bottom security.",
  65. maxCount: 1,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. mode: SelectCardEffect.Mode.Custom,
  69. root: SelectCardEffect.Root.Trash,
  70. customRootCardList: null,
  71. canLookReverseCard: true,
  72. selectPlayer: card.Owner,
  73. cardEffect: activateClass);
  74. yield return StartCoroutine(selectCardEffect.Activate());
  75. IEnumerator SelectCardCoroutine(CardSource cardSource)
  76. {
  77. selectedCard = cardSource;
  78. yield return null;
  79. }
  80. if (selectedCard != null)
  81. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard, false, true));
  82. }
  83. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponenetsDigimon))
  84. {
  85. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(IsOpponenetsDigimon);
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. selectPermanentEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: IsOpponenetsDigimon,
  90. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  91. canEndSelectCondition: CanEndSelectCondition,
  92. maxCount: maxCount,
  93. canNoSelect: false,
  94. canEndNotMax: true,
  95. selectPermanentCoroutine: null,
  96. afterSelectPermanentCoroutine: null,
  97. mode: SelectPermanentEffect.Mode.Destroy,
  98. cardEffect: activateClass);
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. bool CanEndSelectCondition(List<Permanent> permanents)
  101. {
  102. if (permanents.Count <= 0)
  103. {
  104. return false;
  105. }
  106. int sumCost = 0;
  107. foreach (Permanent permanent1 in permanents)
  108. {
  109. sumCost += permanent1.TopCard.GetCostItself;
  110. }
  111. if (sumCost > MaxCost())
  112. {
  113. return false;
  114. }
  115. return true;
  116. }
  117. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  118. {
  119. int sumCost = 0;
  120. foreach (Permanent permanent1 in permanents)
  121. {
  122. sumCost += permanent1.TopCard.GetCostItself;
  123. }
  124. sumCost += permanent.TopCard.GetCostItself;
  125. if (sumCost > MaxCost())
  126. {
  127. return false;
  128. }
  129. return true;
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region Security Effect
  136. if (timing == EffectTiming.SecuritySkill)
  137. {
  138. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Delete opponent's all Digimon with the highest play cost");
  139. }
  140. #endregion
  141. return cardEffects;
  142. }
  143. }
  144. }