BT18_027.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_027 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Attacking
  13. if (timing == EffectTiming.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play Digimon from digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Attacking] You may play 1 blue level 3 Digimon card or 1 Tamer card from this Digimon's digivolution cards without paying the cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon && cardSource.HasLevel)
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  28. {
  29. if (cardSource.Level == 3 && cardSource.HasCardColor(CardColor.Blue))
  30. {
  31. if (cardSource.HasLevel)
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. if (cardSource.IsTamer)
  39. {
  40. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  54. {
  55. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. Permanent selectedPermanent = card.PermanentOfThisCard();
  65. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  66. List<CardSource> selectedCards = new List<CardSource>();
  67. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  68. selectCardEffect.SetUp(
  69. canTargetCondition: CanSelectCardCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. canNoSelect: () => true,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: null,
  75. message: "Select 1 digivolution card to play.",
  76. maxCount: maxCount,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. mode: SelectCardEffect.Mode.Custom,
  80. root: SelectCardEffect.Root.Custom,
  81. customRootCardList: selectedPermanent.DigivolutionCards,
  82. canLookReverseCard: true,
  83. selectPlayer: card.Owner,
  84. cardEffect: activateClass);
  85. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  86. yield return StartCoroutine(selectCardEffect.Activate());
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. selectedCards.Add(cardSource);
  90. yield return null;
  91. }
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  93. cardSources: selectedCards,
  94. activateClass: activateClass,
  95. payCost: false,
  96. isTapped: false,
  97. root: SelectCardEffect.Root.DigivolutionCards,
  98. activateETB: true));
  99. }
  100. }
  101. #endregion
  102. return cardEffects;
  103. }
  104. }
  105. }