BT13_032.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT13
  5. {
  6. public class BT13_032 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  14. }
  15. if (timing == EffectTiming.OnAllyAttack)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Opponent's Turn] When an opponent's Digimon attacks, you may play 1 level 5 or lower Digimon card from this Digimon's digivolution cards without paying the cost.";
  24. }
  25. bool CanSelectCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource.IsDigimon)
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. if (cardSource.HasLevel)
  32. {
  33. if (cardSource.Level <= 5)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool PermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (CardEffectCommons.IsOpponentTurn(card))
  51. {
  52. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.IsExistOnBattleArea(card))
  63. {
  64. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. if (CardEffectCommons.IsExistOnBattleArea(card))
  74. {
  75. Permanent selectedPermanent = card.PermanentOfThisCard();
  76. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  77. {
  78. List<CardSource> selectedCards = new List<CardSource>();
  79. int maxCount = 1;
  80. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  81. selectCardEffect.SetUp(
  82. canTargetCondition: CanSelectCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. canNoSelect: () => true,
  86. selectCardCoroutine: SelectCardCoroutine,
  87. afterSelectCardCoroutine: null,
  88. message: "Select 1 card to play.",
  89. maxCount: maxCount,
  90. canEndNotMax: false,
  91. isShowOpponent: true,
  92. mode: SelectCardEffect.Mode.Custom,
  93. root: SelectCardEffect.Root.Custom,
  94. customRootCardList: selectedPermanent.DigivolutionCards,
  95. canLookReverseCard: true,
  96. selectPlayer: card.Owner,
  97. cardEffect: activateClass);
  98. selectCardEffect.SetUpCustomMessage(
  99. "Select 1 digivolution card to play.",
  100. "The opponent is selecting 1 digivolution card to play.");
  101. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  102. yield return StartCoroutine(selectCardEffect.Activate());
  103. IEnumerator SelectCardCoroutine(CardSource cardSource)
  104. {
  105. selectedCards.Add(cardSource);
  106. yield return null;
  107. }
  108. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  109. cardSources: selectedCards,
  110. activateClass: activateClass,
  111. payCost: false,
  112. isTapped: false,
  113. root: SelectCardEffect.Root.DigivolutionCards,
  114. activateETB: true));
  115. }
  116. }
  117. }
  118. }
  119. return cardEffects;
  120. }
  121. }
  122. }