BT19_077.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main
  13. if (timing == EffectTiming.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Your Digimon digivolves", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] By suspending this Digimon, 1 of your Digimon may digivolve into a Digimon card in the hand with the digivolution cost reduced by 2.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. foreach (CardSource cardSource in card.Owner.HandCards)
  28. {
  29. if (CanSelectCardCondition(cardSource))
  30. {
  31. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. return cardSource.IsDigimon;
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. Permanent selectedPermanent = null;
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: SelectPermanentCoroutine,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  78. {
  79. selectedPermanent = permanent;
  80. yield return null;
  81. }
  82. if (selectedPermanent != null)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  85. targetPermanent: selectedPermanent,
  86. cardCondition: CanSelectCardCondition,
  87. payCost: true,
  88. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  89. fixedCostTuple: null,
  90. ignoreDigivolutionRequirementFixedCost: -1,
  91. isHand: true,
  92. activateClass: activateClass,
  93. successProcess: null));
  94. }
  95. }
  96. }
  97. }
  98. #endregion
  99. #region All Turns
  100. if (timing == EffectTiming.None)
  101. {
  102. cardEffects.Add(CardEffectFactory.CanNotBlockStaticSelfEffect(
  103. attackerCondition: null,
  104. isInheritedEffect: false,
  105. card: card,
  106. condition: () => true,
  107. effectName: "Can't Block"));
  108. cardEffects.Add(CardEffectFactory.CanNotAttackSelfStaticEffect(
  109. defenderCondition: null,
  110. isInheritedEffect: false,
  111. card: card,
  112. condition: () => true,
  113. effectName: "Can't Attack"));
  114. }
  115. #endregion
  116. #region On Deletion
  117. if (timing == EffectTiming.OnDestroyedAnyone)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Place on top of security", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  122. cardEffects.Add(activateClass);
  123. string EffectDiscription()
  124. {
  125. return "[On Deletion] Place this card on top of your security stack.";
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  134. card.Owner.CanAddSecurity(activateClass);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: true));
  139. }
  140. }
  141. #endregion
  142. #region Security
  143. if (timing == EffectTiming.SecuritySkill)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect($"Play a Digimon from hand.", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  148. activateClass.SetIsSecurityEffect(true);
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[Security] You may play 1 Digimon card with 2000 DP or less from your hand without paying the cost.";
  153. }
  154. bool CanSelectCardCondition(CardSource cardSource)
  155. {
  156. if (cardSource != null)
  157. {
  158. if (cardSource.Owner == card.Owner)
  159. {
  160. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  161. {
  162. if (cardSource.IsDigimon)
  163. {
  164. if (cardSource.CardDP <= 2000)
  165. {
  166. return true;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. return false;
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. if (CardEffectCommons.HasMatchConditionOwnersHand(card, (cardSource) => CanSelectCardCondition(cardSource)))
  181. {
  182. int maxCount = Math.Min(1, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  183. List<CardSource> selectedCards = new List<CardSource>();
  184. SelectHandEffect selectCardEffect = GManager.instance.GetComponent<SelectHandEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: CanSelectCardCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: true,
  190. selectCardCoroutine: SelectCardCoroutine,
  191. afterSelectCardCoroutine: null,
  192. maxCount: maxCount,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. mode: SelectHandEffect.Mode.Custom,
  196. selectPlayer: card.Owner,
  197. cardEffect: activateClass);
  198. selectCardEffect.SetUpCustomMessage("Select 1 Digimon with 2000 DP or less to play.", "The opponent is selecting 1 card to play.");
  199. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  200. yield return StartCoroutine(selectCardEffect.Activate());
  201. IEnumerator SelectCardCoroutine(CardSource cardSource)
  202. {
  203. selectedCards.Add(cardSource);
  204. yield return null;
  205. }
  206. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  207. }
  208. }
  209. }
  210. #endregion
  211. return cardEffects;
  212. }
  213. }
  214. }