EX8_043.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX8
  4. {
  5. public class EX8_043 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("Dinosaur");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  18. permanentCondition: PermanentCondition,
  19. digivolutionCost: 3,
  20. ignoreDigivolutionRequirement: false,
  21. card: card,
  22. condition: null)
  23. );
  24. }
  25. #endregion
  26. #region On Play/When Digivolving Shared
  27. bool CanSelectPermanentConditionShared(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) &&
  30. permanent.IsDigimon;
  31. }
  32. bool CanSelectOpponentPermanentConditionShared(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  35. permanent.IsDigimon;
  36. }
  37. bool CanActivateConditionShared(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  40. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared);
  41. }
  42. Permanent thisPermanent = card.PermanentOfThisCard();
  43. void ActivateDeDigivolveProtection()
  44. {
  45. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  46. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition,
  47. thisPermanent.TopCard);
  48. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  49. thisPermanent.UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  50. }
  51. bool CanUseImmunityCondition(Hashtable hashtable1)
  52. {
  53. return thisPermanent.TopCard != null;
  54. }
  55. bool PermanentImmunityCondition(Permanent permanent)
  56. {
  57. return permanent == thisPermanent;
  58. }
  59. #endregion
  60. #region On Play
  61. if (timing == EffectTiming.OnEnterFieldAnyone)
  62. {
  63. ActivateClass activateClass = new ActivateClass();
  64. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  65. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  66. cardEffects.Add(activateClass);
  67. string EffectDescription()
  68. {
  69. return
  70. "[On Play] You may suspend 1 Digimon. Then, if this Digimon is suspended, <De-Digivolve 1> 1 of your opponent's Digimon , and this Digimon isn't returned to hand or deck by an opponent's effect, and isn't affected by <De-Digivolve> effects until the end of your opponent's turn.";
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentConditionShared,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: 1,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: null,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Tap,
  90. cardEffect: activateClass);
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. if (card.PermanentOfThisCard().IsSuspended)
  93. {
  94. #region <De-Digivolve 1>
  95. Permanent selectedPermanent = null;
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectOpponentPermanentConditionShared,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: 1,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  109. "The opponent is selecting 1 Digimon to De-Digivolve.");
  110. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. selectedPermanent = permanent;
  114. yield return null;
  115. }
  116. if (selectedPermanent != null)
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(
  119. new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  120. }
  121. #endregion
  122. #region Immunities
  123. bool CardEffectCondition(ICardEffect cardEffect)
  124. {
  125. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  126. }
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  128. targetPermanent: card.PermanentOfThisCard(),
  129. cardEffectCondition: CardEffectCondition,
  130. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  131. activateClass: activateClass,
  132. effectName: "Can't return to hand by opponent's effects"));
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  134. targetPermanent: card.PermanentOfThisCard(),
  135. cardEffectCondition: CardEffectCondition,
  136. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  137. activateClass: activateClass,
  138. effectName: "Can't return to deck by opponent's effects"));
  139. ActivateDeDigivolveProtection();
  140. #endregion
  141. }
  142. }
  143. }
  144. #endregion
  145. #region When Digivolving
  146. if (timing == EffectTiming.OnEnterFieldAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return
  155. "[When Digivolving] You may suspend 1 Digimon. Then, if this Digimon is suspended, <De-Digivolve 1> 1 of your opponent's Digimon , and this Digimon isn't returned to hand or deck by an opponent's effect, and isn't affected by <De-Digivolve> effects until the end of your opponent's turn.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectPermanentConditionShared,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: 1,
  170. canNoSelect: true,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: null,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Tap,
  175. cardEffect: activateClass);
  176. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  177. if (card.PermanentOfThisCard().IsSuspended)
  178. {
  179. #region <De-Digivolve 1>
  180. Permanent selectedPermanent = null;
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectOpponentPermanentConditionShared,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: 1,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: SelectPermanentCoroutine,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Custom,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  194. "The opponent is selecting 1 Digimon to De-Digivolve.");
  195. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  196. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  197. {
  198. selectedPermanent = permanent;
  199. yield return null;
  200. }
  201. if (selectedPermanent != null)
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(
  204. new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  205. }
  206. #endregion
  207. #region Immunities
  208. bool CardEffectCondition(ICardEffect cardEffect)
  209. {
  210. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  211. }
  212. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  213. targetPermanent: card.PermanentOfThisCard(),
  214. cardEffectCondition: CardEffectCondition,
  215. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  216. activateClass: activateClass,
  217. effectName: "Can't return to hand by opponent's effects"));
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  219. targetPermanent: card.PermanentOfThisCard(),
  220. cardEffectCondition: CardEffectCondition,
  221. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  222. activateClass: activateClass,
  223. effectName: "Can't return to deck by opponent's effects"));
  224. ActivateDeDigivolveProtection();
  225. #endregion
  226. }
  227. }
  228. }
  229. #endregion
  230. #region All Turns - ESS
  231. if (timing == EffectTiming.OnEndBattle)
  232. {
  233. ActivateClass activateClass = new ActivateClass();
  234. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  235. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  236. activateClass.SetIsInheritedEffect(true);
  237. activateClass.SetHashString("TrashSecurity_EX8_043");
  238. cardEffects.Add(activateClass);
  239. string EffectDescription()
  240. {
  241. return
  242. "[All Turns] (Once Per Turn) When this Digimon deletes an opponent's Digimon in battle, trash the top card of your opponent's security stack.";
  243. }
  244. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  245. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  246. bool CanUseCondition(Hashtable hashtable)
  247. {
  248. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  249. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  250. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  251. }
  252. bool CanActivateCondition(Hashtable hashtable)
  253. {
  254. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  255. card.Owner.Enemy.SecurityCards.Count >= 1;
  256. }
  257. IEnumerator ActivateCoroutine(Hashtable hashtable)
  258. {
  259. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  260. player: card.Owner.Enemy,
  261. destroySecurityCount: 1,
  262. cardEffect: activateClass,
  263. fromTop: true).DestroySecurity());
  264. }
  265. }
  266. #endregion
  267. return cardEffects;
  268. }
  269. }
  270. }