EX6_030.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Digivolving
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(
  17. "Play 1 level 5 or lower Digimon from security, then 1 of your opponent's Digimon gets -7000 DP until the end of the turn",
  18. CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  20. EffectDescription());
  21. cardEffects.Add(activateClass);
  22. string EffectDescription()
  23. {
  24. return
  25. "[When Digivolving] Search your security stack. You may play 1 level 5 or lower Digimon card with the [Angel]/[Archangel] trait among them without paying the cost. Then, shuffle your security stack, and 1 of your opponent's Digimon gets -7000 DP until the end of the turn.";
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. if (cardSource.IsDigimon)
  30. {
  31. if (cardSource.Level <= 5)
  32. {
  33. if (cardSource.CardTraits.Contains("Angel") || cardSource.CardTraits.Contains("Archangel"))
  34. {
  35. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  36. cardEffect: activateClass))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. return true;
  58. }
  59. return false;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (card.Owner.SecurityCards.Count >= 1)
  64. {
  65. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count(CanSelectCardCondition));
  66. List<CardSource> selectedCards = new List<CardSource>();
  67. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  68. selectCardEffect.SetUp(
  69. canTargetCondition: CanSelectCardCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. canNoSelect: () => true,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  75. message: "Select 1 Digimon to play.",
  76. maxCount: maxCount,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. mode: SelectCardEffect.Mode.Custom,
  80. root: SelectCardEffect.Root.Security,
  81. customRootCardList: null,
  82. canLookReverseCard: true,
  83. selectPlayer: card.Owner,
  84. cardEffect: activateClass);
  85. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  86. IEnumerator SelectCardCoroutine(CardSource cardSource)
  87. {
  88. selectedCards.Add(cardSource);
  89. yield return null;
  90. }
  91. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  92. {
  93. if (cardSources.Count >= 1)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  96. player: card.Owner,
  97. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  98. activateClass).ReduceSecurity());
  99. }
  100. yield return null;
  101. }
  102. yield return ContinuousController.instance.StartCoroutine(
  103. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards,
  104. activateClass: activateClass, payCost: false, isTapped: false,
  105. root: SelectCardEffect.Root.Security, activateETB: true));
  106. }
  107. if (card.Owner.SecurityCards.Count >= 1)
  108. {
  109. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  110. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  111. }
  112. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  113. {
  114. int maxCount = Math.Min(1,
  115. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  116. SelectPermanentEffect selectPermanentEffect =
  117. GManager.instance.GetComponent<SelectPermanentEffect>();
  118. selectPermanentEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectPermanentCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. maxCount: maxCount,
  124. canNoSelect: false,
  125. canEndNotMax: false,
  126. selectPermanentCoroutine: SelectPermanentCoroutine,
  127. afterSelectPermanentCoroutine: null,
  128. mode: SelectPermanentEffect.Mode.Custom,
  129. cardEffect: activateClass);
  130. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -7000.",
  131. "The opponent is selecting 1 Digimon that will get DP -7000.");
  132. yield return ContinuousController.instance.StartCoroutine(
  133. selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(
  137. CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent,
  138. changeValue: -7000, effectDuration: EffectDuration.UntilEachTurnEnd,
  139. activateClass: activateClass));
  140. }
  141. }
  142. }
  143. }
  144. #endregion
  145. #region All Turns
  146. if (timing == EffectTiming.WhenRemoveField)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect(
  150. "By trashing the top card of your security stack, prevent one Digimon from leaving the battle area",
  151. CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  153. EffectDescription());
  154. cardEffects.Add(activateClass);
  155. string EffectDescription()
  156. {
  157. return
  158. "[All Turns] When one of your Digimon with the [Angel]/[Archangel]/[Three Great Angels] trait would leave the battle area other than in battle, by trashing the top card of your security stack, prevent it from leaving.";
  159. }
  160. bool PermanentCondition(Permanent permanent)
  161. {
  162. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  163. {
  164. if (permanent.TopCard.HasAngelTraitRestrictive)
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  174. {
  175. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition))
  176. {
  177. if (!CardEffectCommons.IsByBattle(hashtable) &&
  178. !CardEffectCommons.IsByEffect(hashtable,
  179. cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.IsExistOnBattleArea(card))
  190. {
  191. if (card.Owner.SecurityCards.Count >= 1)
  192. {
  193. return true;
  194. }
  195. }
  196. return false;
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. if (CardEffectCommons.IsExistOnBattleArea(card))
  201. {
  202. List<Permanent> removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
  203. removedPermanents = removedPermanents.Filter(PermanentCondition);
  204. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  205. {
  206. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  207. player: card.Owner,
  208. destroySecurityCount: 1,
  209. cardEffect: activateClass,
  210. fromTop: true).DestroySecurity());
  211. foreach(Permanent permanent in removedPermanents)
  212. {
  213. permanent.willBeRemoveField = false;
  214. permanent.HideDeleteEffect();
  215. permanent.HideHandBounceEffect();
  216. permanent.HideDeckBounceEffect();
  217. permanent.HideWillRemoveFieldEffect();
  218. }
  219. }
  220. }
  221. }
  222. }
  223. #endregion
  224. return cardEffects;
  225. }
  226. }
  227. }