BT12_105.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT12
  5. {
  6. public class BT12_105 : 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.OptionSkill)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  15. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Main] Until the end of your opponent's turn, 1 of your opponent's Digimon gains \"[On Deletion] Trash the top card of your security stack.\" Then, if you have a blue Digimon in play, you may play 1 green level 4 or lower Digimon card with a [Free] trait from your hand without paying its cost.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  24. }
  25. bool CanSelectPermanentCondition1(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource != null)
  39. {
  40. if (cardSource.IsDigimon)
  41. {
  42. if (cardSource.Owner == card.Owner)
  43. {
  44. if (cardSource.CardColors.Contains(CardColor.Green))
  45. {
  46. if (cardSource.Level <= 4)
  47. {
  48. if (cardSource.CardTraits.Contains("Free"))
  49. {
  50. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  51. {
  52. if (cardSource.HasLevel)
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = 1;
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. Permanent selectedPermanent = permanent;
  92. if (selectedPermanent != null)
  93. {
  94. CardSource _topCard = selectedPermanent.TopCard;
  95. ActivateClass activateClass1 = new ActivateClass();
  96. activateClass1.SetUpICardEffect("Trash the top card of your security", CanUseCondition1, selectedPermanent.TopCard);
  97. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  98. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  99. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
  100. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  103. }
  104. string EffectDiscription1()
  105. {
  106. return "[On Deletion] Trash the top card of your security stack.";
  107. }
  108. bool CanUseCondition1(Hashtable hashtable1)
  109. {
  110. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  111. {
  112. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent))
  113. {
  114. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanActivateCondition1(Hashtable hashtable1)
  123. {
  124. if (CardEffectCommons.IsTopCardInTrashOnDeletion(hashtable1))
  125. {
  126. if (_topCard.Owner.SecurityCards.Count >= 1)
  127. {
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  136. player: _topCard.Owner,
  137. destroySecurityCount: 1,
  138. cardEffect: activateClass1,
  139. fromTop: true).DestroySecurity());
  140. }
  141. }
  142. }
  143. }
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  145. {
  146. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  147. {
  148. List<CardSource> selectedCards = new List<CardSource>();
  149. int maxCount = 1;
  150. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  151. selectHandEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectCardCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: true,
  158. canEndNotMax: false,
  159. isShowOpponent: true,
  160. selectCardCoroutine: SelectCardCoroutine,
  161. afterSelectCardCoroutine: null,
  162. mode: SelectHandEffect.Mode.Custom,
  163. cardEffect: activateClass);
  164. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  165. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  166. yield return StartCoroutine(selectHandEffect.Activate());
  167. IEnumerator SelectCardCoroutine(CardSource cardSource)
  168. {
  169. selectedCards.Add(cardSource);
  170. yield return null;
  171. }
  172. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  173. }
  174. }
  175. }
  176. }
  177. if (timing == EffectTiming.SecuritySkill)
  178. {
  179. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Opponent's 1 Digimon gets effect and play 1 Digimon from hand");
  180. }
  181. return cardEffects;
  182. }
  183. }
  184. }