BT21_102.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 card 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. bool CanActivateCondition(Hashtable hashtable)
  57. => CardEffectCommons.IsExistOnBattleArea(card);
  58. bool CanSelectCard(CardSource source)
  59. => source.HasPlayCost &&
  60. source.BasePlayCostFromEntity <= AdjustedPlayCostMax(source)
  61. && (source.HasAdventureTraits || source.HasHeroTraits);
  62. int AdjustedPlayCostMax(CardSource cardSource)
  63. {
  64. var tamers = cardSource.Owner.GetBattleAreaPermanents().Filter(x => x.IsTamer).Select(x => x.TopCard).ToList();
  65. return 2 + Combinations.GetDifferenetColorCardCount(tamers);
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable hashtable)
  68. {
  69. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  70. selectHandEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectCard,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: 1,
  76. canNoSelect: true,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. selectCardCoroutine: SelectCardCoroutine,
  80. afterSelectCardCoroutine: null,
  81. mode: SelectHandEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  84. "The opponent is selecting 1 card to play.");
  85. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  86. yield return StartCoroutine(selectHandEffect.Activate());
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  90. cardSources: new List<CardSource>() { cardSource },
  91. activateClass: activateClass,
  92. payCost: false,
  93. isTapped: false,
  94. root: SelectCardEffect.Root.Hand,
  95. activateETB: true,
  96. isBreedingArea: false
  97. ));
  98. }
  99. var selectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
  100. DeckBottomBounceClass putLibraryBottomPermanent = new DeckBottomBounceClass(selectedPermanents, hashtable);
  101. putLibraryBottomPermanent.SetNotShowCards();
  102. yield return ContinuousController.instance.StartCoroutine(putLibraryBottomPermanent.DeckBounce());
  103. }
  104. }
  105. #endregion
  106. #region Security
  107. if (timing == EffectTiming.SecuritySkill) cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  108. #endregion
  109. return cardEffects;
  110. }
  111. }
  112. }