BT20_054.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_054 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Blocker
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  15. isInheritedEffect: false,
  16. card: card,
  17. condition: null));
  18. }
  19. #endregion
  20. #region Opponent's Turn
  21. if (timing == EffectTiming.WhenRemoveField)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Play 1 play cost 4 or lower Digimon", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[Opponent's Turn] When this Digimon would leave the battle area, you may play 1 play cost 4 or lower Digimon card from this Digimon's digivolution cards without paying the cost.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. return cardSource.IsDigimon &&
  34. cardSource.HasPlayCost && cardSource.GetCostItself <= 4 &&
  35. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false,activateClass,SelectCardEffect.Root.DigivolutionCards);
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (CardEffectCommons.IsOpponentTurn(card))
  42. {
  43. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 0)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable hashtable)
  63. {
  64. List<CardSource> selectedCards = new List<CardSource>();
  65. int maxCount = 1;
  66. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  67. selectCardEffect.SetUp(
  68. canTargetCondition: CanSelectCardCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. canNoSelect: () => true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. message: "Select 1 card to play.",
  75. maxCount: maxCount,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. mode: SelectCardEffect.Mode.Custom,
  79. root: SelectCardEffect.Root.Custom,
  80. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  81. canLookReverseCard: true,
  82. selectPlayer: card.Owner,
  83. cardEffect: activateClass);
  84. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  85. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  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. #region Redirect - ESS
  103. if (timing == EffectTiming.OnAllyAttack)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("You may change the attack target to this Digimon.", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  108. activateClass.SetHashString("Redirect_BT20-054");
  109. activateClass.SetIsInheritedEffect(true);
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[Opponent's Turn] [Once Per Turn] When any of your opponent's Digimon attack, you may change the attack target to this Digimon.";
  114. }
  115. bool IsOpponentDigimon(Permanent permanent)
  116. {
  117. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  118. }
  119. bool IsThisDigimon(Permanent permanent)
  120. {
  121. return permanent == card.PermanentOfThisCard();
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsOpponentTurn(card) &&
  126. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: IsThisDigimon,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: 1,
  141. canNoSelect: false,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectPermanentCoroutine,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.",
  148. "The opponent is selecting 1 Digimon to attack.");
  149. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  150. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  153. activateClass,
  154. false,
  155. permanent));
  156. }
  157. }
  158. }
  159. #endregion
  160. return cardEffects;
  161. }
  162. }
  163. }