BT14_020.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_020 : 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.OnStartMainPhase)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Trash digivolution cards and this Digimon gains unblockable", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Start of Your Main Phase] Trash any 1 digivolution card of 1 of your opponent's Digimon. This Digimon can't be blocked for the turn.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (CardEffectCommons.IsOwnerTurn(card))
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. return true;
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  58. permanentCondition: CanSelectPermanentCondition,
  59. cardCondition: CanSelectCardCondition,
  60. maxCount: 1,
  61. canNoTrash: false,
  62. isFromOnly1Permanent: true,
  63. activateClass: activateClass
  64. ));
  65. Permanent selectedPermanent = card.PermanentOfThisCard();
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeBlocked(
  67. targetPermanent: selectedPermanent,
  68. defenderCondition: null,
  69. effectDuration: EffectDuration.UntilEachTurnEnd,
  70. activateClass: activateClass,
  71. effectName: "Unblockable"));
  72. }
  73. }
  74. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  75. {
  76. ActivateClass activateClass = new ActivateClass();
  77. activateClass.SetUpICardEffect("Play [Gomamon] from digivolution cards", CanUseCondition, card);
  78. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  79. activateClass.SetIsInheritedEffect(true);
  80. activateClass.SetHashString("PlayDigivolutionCards_BT14_020");
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[Opponent's Turn] When this Digimon would be deleted, you may play 1 [Gomamon] from its digivolution cards without paying the cost.";
  85. }
  86. bool CanSelectCardCondition(CardSource cardSource)
  87. {
  88. if (cardSource.IsDigimon)
  89. {
  90. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  91. {
  92. if (cardSource.CardNames.Contains("Gomamon"))
  93. {
  94. return true;
  95. }
  96. }
  97. }
  98. return false;
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. if (CardEffectCommons.IsExistOnBattleArea(card))
  103. {
  104. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  105. {
  106. if (CardEffectCommons.IsOpponentTurn(card))
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnBattleArea(card))
  117. {
  118. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. Permanent selectedPermanent = card.PermanentOfThisCard();
  130. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  131. {
  132. List<CardSource> selectedCards = new List<CardSource>();
  133. int maxCount = 1;
  134. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  135. selectCardEffect.SetUp(
  136. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. canNoSelect: () => true,
  140. selectCardCoroutine: SelectCardCoroutine,
  141. afterSelectCardCoroutine: null,
  142. message: "Select 1 card to play.",
  143. maxCount: maxCount,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. mode: SelectCardEffect.Mode.Custom,
  147. root: SelectCardEffect.Root.Custom,
  148. customRootCardList: selectedPermanent.DigivolutionCards,
  149. canLookReverseCard: true,
  150. selectPlayer: card.Owner,
  151. cardEffect: activateClass);
  152. selectCardEffect.SetUpCustomMessage("Select digivolution cards to play.", "The opponent is selecting digivolution cards to play.");
  153. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  154. yield return StartCoroutine(selectCardEffect.Activate());
  155. IEnumerator SelectCardCoroutine(CardSource cardSource)
  156. {
  157. selectedCards.Add(cardSource);
  158. yield return null;
  159. }
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  161. cardSources: selectedCards,
  162. activateClass: activateClass,
  163. payCost: false,
  164. isTapped: false,
  165. root: SelectCardEffect.Root.DigivolutionCards,
  166. activateETB: true));
  167. }
  168. }
  169. }
  170. }
  171. return cardEffects;
  172. }
  173. }
  174. }