BT21_058.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. //Snatchmon
  8. public class BT21_058 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region OP/WD Shared
  14. string SharedEffectName = "Reveal 3, add 1 [Vemmon] in text, trash rest, place up to 2 [Vemmon] from trash under 1 Digimon.";
  15. string SharedEffectDescription(string tag) => $"[{tag}] Reveal the top 3 cards of your deck. Add 1 card with [Vemmon] in its text among them to the hand. Trash the rest. Then, you may place up to 2 [Vemmon] from your trash as 1 of your Digimon's bottom digivolution cards.";
  16. bool HasVemmonInText(CardSource cardSource)
  17. {
  18. return cardSource.HasText("Vemmon");
  19. }
  20. bool IsVemmon(CardSource cardSource)
  21. {
  22. return cardSource.EqualsCardName("Vemmon");
  23. }
  24. bool HasDigimonOnOwnerBattleArea(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  27. }
  28. bool SharedCanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  31. }
  32. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  33. {
  34. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  35. revealCount: 3,
  36. simplifiedSelectCardConditions:
  37. new SimplifiedSelectCardConditionClass[]
  38. {
  39. new SimplifiedSelectCardConditionClass(
  40. canTargetCondition:HasVemmonInText,
  41. message: "Select 1 card with [Vemmon] in text.",
  42. mode: SelectCardEffect.Mode.AddHand,
  43. maxCount: 1,
  44. selectCardCoroutine: null),
  45. },
  46. remainingCardsPlace: RemainingCardsPlace.Trash,
  47. activateClass: activateClass,
  48. canNoSelect: false
  49. ));
  50. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsVemmon))
  51. {
  52. List<CardSource> selectedCardsFromTrash = new List<CardSource>();
  53. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  54. int maxCountFromTrash = Math.Min(2, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsVemmon));
  55. selectCardEffect.SetUp(
  56. canTargetCondition: IsVemmon,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. canNoSelect: () => true,
  60. selectCardCoroutine: SelectCardCoroutine,
  61. afterSelectCardCoroutine: null,
  62. message: "Select up to 2 cards to place on bottom of digivolution cards.",
  63. maxCount: maxCountFromTrash,
  64. canEndNotMax: true,
  65. isShowOpponent: true,
  66. mode: SelectCardEffect.Mode.Custom,
  67. root: SelectCardEffect.Root.Trash,
  68. customRootCardList: null,
  69. canLookReverseCard: true,
  70. selectPlayer: card.Owner,
  71. cardEffect: activateClass);
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCardsFromTrash.Add(cardSource);
  75. yield return null;
  76. }
  77. selectCardEffect.SetUpCustomMessage("Select up to 2 cards to place on bottom of digivolution cards.", "The opponent is selecting up to 2 cards to place on bottom of digivolution cards.");
  78. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  79. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  80. Permanent selectedPermanent = null;
  81. if (selectedCardsFromTrash.Count != 0)
  82. {
  83. if (card.Owner.GetBattleAreaDigimons().Count(HasDigimonOnOwnerBattleArea) > 1)
  84. {
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: HasDigimonOnOwnerBattleArea,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: SelectPermanentCoroutine,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. selectedPermanent = permanent;
  101. yield return null;
  102. }
  103. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get the digivolution card(s).", "The opponent is selecting 1 Digimon that will get the digivolution card(s).");
  104. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  105. }
  106. else selectedPermanent = card.Owner.GetBattleAreaDigimons().FirstOrDefault();
  107. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(
  108. selectedPermanent.AddDigivolutionCardsBottom(selectedCardsFromTrash, activateClass));
  109. }
  110. }
  111. }
  112. #endregion
  113. #region On Play
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  118. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  119. cardEffects.Add(activateClass);
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  123. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  124. }
  125. }
  126. #endregion
  127. #region When Digivolving
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  132. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  133. cardEffects.Add(activateClass);
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  137. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  138. }
  139. }
  140. #endregion
  141. #region All Turns Inherited
  142. if (timing == EffectTiming.OnDigivolutionCardReturnToDeckBottom)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Delete 1 opponent Digimon with play cost 4 or less", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  147. activateClass.SetIsInheritedEffect(true);
  148. activateClass.SetHashString("Delete_BT21_058");
  149. cardEffects.Add(activateClass);
  150. string EffectDescription()
  151. {
  152. return "[All Turns] [Once Per Turn] When any [Vemmon] are returned to the bottom of the deck from this Digimon's digivolution cards, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  153. }
  154. bool CanSelectPermanentCondition(Permanent permanent)
  155. {
  156. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  157. return permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 4;
  158. return false;
  159. }
  160. bool CanUseCondition(Hashtable hashtable)
  161. {
  162. return CardEffectCommons.CanTriggerOnReturnToLibraryBottomDigivolutionCard(hashtable, cardSource => cardSource.EqualsCardName("Vemmon"), card);
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsExistOnBattleArea(card);
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  169. {
  170. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: CanSelectPermanentCondition,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: maxCount,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: null,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Destroy,
  183. cardEffect: activateClass);
  184. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  185. }
  186. }
  187. #endregion
  188. return cardEffects;
  189. }
  190. }
  191. }