BT17_036.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_036 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasText("Pulsemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region All Turns
  22. if (timing == EffectTiming.WhenRemoveField)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Trash a security to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  27. activateClass.SetHashString("TrashSecurityToStay_BT17_036");
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area by an opponent's effect, by trashing the top card of your security stack, prevent it.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  36. {
  37. if(card.Owner.SecurityCards.Count > 0)
  38. {
  39. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  40. {
  41. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.IsExistOnBattleArea(card))
  53. {
  54. return true;
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  63. card.Owner,
  64. 1,
  65. activateClass,
  66. true).DestroySecurity());
  67. Permanent thisCardPermanent = card.PermanentOfThisCard();
  68. thisCardPermanent.willBeRemoveField = false;
  69. thisCardPermanent.HideDeleteEffect();
  70. thisCardPermanent.HideHandBounceEffect();
  71. thisCardPermanent.HideDeckBounceEffect();
  72. thisCardPermanent.HideWillRemoveFieldEffect();
  73. yield return null;
  74. }
  75. }
  76. }
  77. if (timing == EffectTiming.OnDiscardSecurity)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("If a card is trashed from security and there's a Tamer in the digivolution cards, this Digimon digivolves for free.", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  82. activateClass.SetHashString("Digivolve_BT17_036");
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[All Turns] [Once per turn] When a card is trashed from your security stack by an effect, this Digimon with [Leon Alexander] in its digivolution cards may digivolve into a Digimon card with [Pulsemon] in its text in the hand without paying the cost.";
  87. }
  88. bool CanSelectCardCondition(CardSource cardSource)
  89. {
  90. if (cardSource.HasText("Pulsemon") && cardSource.IsDigimon)
  91. {
  92. return true;
  93. }
  94. return false;
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. if (CardEffectCommons.IsExistOnBattleArea(card))
  99. {
  100. if (CardEffectCommons.CanTriggerOnTrashSecurity(hashtable, cardEffect => cardEffect != null, cardSource => cardSource.Owner == card.Owner))
  101. {
  102. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => (cardSource.EqualsCardName("Leon Alexander") && cardSource.IsTamer)) >= 1)
  103. {
  104. return true;
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. if (CardEffectCommons.IsExistOnBattleArea(card))
  113. {
  114. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  124. targetPermanent: card.PermanentOfThisCard(),
  125. cardCondition: CanSelectCardCondition,
  126. payCost: false,
  127. reduceCostTuple: null,
  128. fixedCostTuple: null,
  129. ignoreDigivolutionRequirementFixedCost: -1,
  130. isHand: true,
  131. activateClass: activateClass,
  132. successProcess: null));
  133. }
  134. }
  135. #endregion
  136. #region Inherit
  137. if (timing == EffectTiming.OnEndAttack)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("Unsuspend this Digimon by trashing the top card of your security.", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  142. activateClass.SetIsInheritedEffect(true);
  143. activateClass.SetHashString("Inherit_BT17_036");
  144. cardEffects.Add(activateClass);
  145. string EffectDiscription()
  146. {
  147. return "[End of Attack] [Once per turn] If this Digimon has [Pulsemon] in its text, by trashing the top card of your security stack, unsuspend this Digimon.";
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  152. }
  153. bool CanActivateCondition(Hashtable hashtable)
  154. {
  155. if (CardEffectCommons.IsExistOnBattleArea(card))
  156. {
  157. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  158. {
  159. if (card.Owner.SecurityCards.Count >= 1)
  160. {
  161. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  162. {
  163. return true;
  164. }
  165. }
  166. }
  167. }
  168. return false;
  169. }
  170. bool PermanentCondition(Permanent permanent)
  171. {
  172. if (permanent == card.PermanentOfThisCard())
  173. {
  174. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  175. {
  176. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  187. player: card.Owner,
  188. destroySecurityCount: 1,
  189. cardEffect: activateClass,
  190. fromTop: true).DestroySecurity());
  191. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  192. {
  193. Permanent selectedPermanent = card.PermanentOfThisCard();
  194. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  195. }
  196. }
  197. }
  198. #endregion
  199. return cardEffects;
  200. }
  201. }
  202. }