BT21_102.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Tai Kamiya
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_102 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Turn
  13. if (timing == EffectTiming.OnStartTurn) cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  14. #endregion
  15. #region Your Turn
  16. if (timing == EffectTiming.OnAllyAttack)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Suspend to draw 1", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. => "When one of your Digimon attacks, by suspending this Tamer, <Draw 1>";
  24. bool CanUseCondition(Hashtable hashtable)
  25. => CardEffectCommons.IsExistOnBattleArea(card)
  26. && CardEffectCommons.IsOwnerTurn(card)
  27. && CardEffectCommons.CanActivateSuspendCostEffect(card)
  28. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  29. bool PermanentCondition(Permanent permanent)
  30. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  31. bool CanActivateCondition(Hashtable hashtable)
  32. => CardEffectCommons.IsExistOnBattleArea(card);
  33. IEnumerator ActivateCoroutine(Hashtable hashtable)
  34. {
  35. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  36. if (card.Owner.LibraryCards.Count >= 1)
  37. {
  38. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  39. }
  40. }
  41. }
  42. #endregion
  43. #region Main
  44. if (timing == EffectTiming.OnDeclaration)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Play Adventure/Hero Digimon for reduced cost", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  49. activateClass.SetHashString("Play_BT21_102");
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. => "[Main] [Once Per Turn] You may play 1 [ADVENTURE]/[Hero] trait card with a play cost of 2 or less from your hand without paying the cost. For each of your Tamers' colors, add 1 to this effect's play cost maximum. Then, return this Tamer to the bottom of the deck.";
  53. bool CanUseCondition(Hashtable hashtable)
  54. => CardEffectCommons.IsExistOnBattleArea(card)
  55. && CardEffectCommons.IsOwnerTurn(card)
  56. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCard);
  57. bool CanActivateCondition(Hashtable hashtable)
  58. => CardEffectCommons.IsExistOnBattleArea(card);
  59. bool CanSelectCard(CardSource source)
  60. => source.HasPlayCost &&
  61. source.BasePlayCostFromEntity <= AdjustedPlayCostMax(source)
  62. && (source.HasAdventureTraits || source.HasHeroTraits);
  63. int AdjustedPlayCostMax(CardSource cardSource)
  64. {
  65. var tamers = cardSource.Owner.GetBattleAreaPermanents().Filter(x => x.IsTamer).Select(x => x.TopCard).ToList();
  66. return 2 + Combinations.GetDifferenetColorCardCount(tamers);
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  71. selectHandEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectCard,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. selectCardCoroutine: SelectCardCoroutine,
  81. afterSelectCardCoroutine: null,
  82. mode: SelectHandEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play.",
  85. "The opponent is selecting 1 digimon to play.");
  86. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  91. cardSources: new List<CardSource>() { cardSource },
  92. activateClass: activateClass,
  93. payCost: false,
  94. isTapped: false,
  95. root: SelectCardEffect.Root.Hand,
  96. activateETB: true,
  97. isBreedingArea: false
  98. ));
  99. }
  100. var selectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
  101. DeckBottomBounceClass putLibraryBottomPermanent = new DeckBottomBounceClass(selectedPermanents, hashtable);
  102. putLibraryBottomPermanent.SetNotShowCards();
  103. yield return ContinuousController.instance.StartCoroutine(putLibraryBottomPermanent.DeckBounce());
  104. }
  105. }
  106. #endregion
  107. #region Security
  108. if (timing == EffectTiming.SecuritySkill) cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  109. #endregion
  110. return cardEffects;
  111. }
  112. }
  113. }