BT22_043.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Terriermon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_043 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 0,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Your Turn
  29. if (timing == EffectTiming.OnAddDigivolutionCards)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Play 1 [CS] Tamer", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  34. activateClass.SetHashString("PlayTamer_BT22_043");
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[Your Turn] [Once Per Turn] When effects place Digimon cards with the [CS] trait in this Digimon's digivolution cards, if you have 1 or fewer Tamers, you may play 1 Tamer card with the [CS] trait from your hand without paying the cost.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnAddDigivolutionCard(hashtable, IsThisPermanent, null, IsCsDigimon);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  47. && CardEffectCommons.IsOwnerTurn(card)
  48. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectTamer)
  49. && card.Owner.GetBattleAreaPermanents().Filter(x => x.IsTamer).Count <= 1;
  50. }
  51. bool IsThisPermanent(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) && permanent == card.PermanentOfThisCard();
  54. }
  55. bool IsCsDigimon(CardSource cardSource)
  56. {
  57. return cardSource.IsDigimon && cardSource.HasCSTraits;
  58. }
  59. bool CanSelectTamer(CardSource cardSource)
  60. {
  61. return cardSource.IsTamer
  62. && cardSource.HasCSTraits
  63. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectTamer))
  68. {
  69. CardSource selectedCard = null;
  70. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectTamer));
  71. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  72. selectHandEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectTamer,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: true,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. selectCardCoroutine: SelectCardCoroutine,
  82. afterSelectCardCoroutine: null,
  83. mode: SelectHandEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  86. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCard = cardSource;
  91. yield return null;
  92. }
  93. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  94. }
  95. }
  96. }
  97. #endregion
  98. #region ESS
  99. if (timing == EffectTiming.OnDeclaration)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Place the top card of this Digimon at the bottom of digivolution cards to Draw 1", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  104. activateClass.SetIsInheritedEffect(true);
  105. activateClass.SetHashString("ReturnDigivolutionCards_BT22_043");
  106. cardEffects.Add(activateClass);
  107. string EffectDiscription()
  108. {
  109. return "[Main] [Once Per Turn] By placing this [CS] trait Digimon's top stacked card as its bottom digivolution card, <Draw 1> (Draw 1 card from your deck).";
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  114. && card.PermanentOfThisCard().DigivolutionCards.Count >= 1
  115. && card.PermanentOfThisCard().TopCard.HasCSTraits;
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. if (CardEffectCommons.IsExistOnBattleArea(card) && card.PermanentOfThisCard().DigivolutionCards.Count >= 1)
  120. {
  121. CardSource topCard = card.PermanentOfThisCard().TopCard;
  122. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { topCard }, activateClass));
  123. if (card.Owner.LibraryCards.Count >= 1) yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  124. }
  125. }
  126. }
  127. #endregion
  128. return cardEffects;
  129. }
  130. }
  131. }