BT8_106.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT8_106 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. int maxCost = 15;
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] Reveal the top 3 cards of your deck. You may play any number of Digimon cards with [Mamemon] in their names whose play costs add up to 15 or less among them without paying their memory costs. Delete 1 of your opponent's Digimon with a memory cost of 6 or less for each Digimon played with this effect. Trash the remaining cards.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.ContainsCardName("Mamemon"))
  29. {
  30. if (cardSource.GetCostItself <= maxCost)
  31. {
  32. if (cardSource.IsDigimon)
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. bool CanSelectPermanentCondition(Permanent permanent)
  42. {
  43. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  44. {
  45. if (permanent.TopCard.GetCostItself <= 6)
  46. {
  47. if (permanent.CanSelectBySkill(activateClass))
  48. {
  49. if (permanent.TopCard.HasPlayCost)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. int maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
  65. List<CardSource> selectedCards = new List<CardSource>();
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  67. revealCount: 3,
  68. simplifiedSelectCardConditions:
  69. new SimplifiedSelectCardConditionClass[]
  70. {
  71. new SimplifiedSelectCardConditionClass(
  72. canTargetCondition:CanSelectCardCondition,
  73. message: "Select Digimon cards with [Mamemon] in their names whose play costs add up to 15 or less.",
  74. mode: SelectCardEffect.Mode.Custom,
  75. maxCount: maxCount,
  76. selectCardCoroutine: SelectCardCoroutine),
  77. },
  78. remainingCardsPlace: RemainingCardsPlace.Trash,
  79. activateClass: activateClass,
  80. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  81. canEndSelectCondition: CanEndSelectCondition,
  82. canNoSelect: true,
  83. canEndNotMax: true
  84. ));
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCards.Add(cardSource);
  88. yield return null;
  89. }
  90. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  91. {
  92. int sumCost = 0;
  93. foreach (CardSource cardSource1 in cardSources)
  94. {
  95. sumCost += cardSource1.GetCostItself;
  96. }
  97. sumCost += cardSource.GetCostItself;
  98. if (sumCost > maxCost)
  99. {
  100. return false;
  101. }
  102. return true;
  103. }
  104. bool CanEndSelectCondition(List<CardSource> cardSources)
  105. {
  106. if (cardSources.Count <= 0)
  107. {
  108. return false;
  109. }
  110. int sumCost = 0;
  111. foreach (CardSource cardSource1 in cardSources)
  112. {
  113. sumCost += cardSource1.GetCostItself;
  114. }
  115. if (sumCost > maxCost)
  116. {
  117. return false;
  118. }
  119. return true;
  120. }
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  122. cardSources: selectedCards,
  123. activateClass: activateClass,
  124. payCost: false,
  125. isTapped: false,
  126. root: SelectCardEffect.Root.Library,
  127. activateETB: true));
  128. int playedCount = selectedCards.Count(cardSource => CardEffectCommons.IsExistOnBattleArea(cardSource));
  129. maxCount = Math.Min(playedCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectPermanentCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: maxCount,
  137. canNoSelect: false,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: null,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Destroy,
  142. cardEffect: activateClass);
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. }
  145. }
  146. if (timing == EffectTiming.SecuritySkill)
  147. {
  148. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Reveal the top 3 cards of deck and delete Digimon");
  149. }
  150. return cardEffects;
  151. }
  152. }