EX6_044.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.EX6
  7. {
  8. public class EX6_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5)
  19. {
  20. return targetPermanent.TopCard.ContainsTraits("Legend-Arms");
  21. }
  22. return false;
  23. }
  24. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  25. permanentCondition: PermanentCondition,
  26. digivolutionCost: 4,
  27. ignoreDigivolutionRequirement: false,
  28. card: card,
  29. condition: null));
  30. }
  31. #endregion
  32. #region Blocker/Reboot
  33. if (timing == EffectTiming.None)
  34. {
  35. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  36. isInheritedEffect: false,
  37. card: card,
  38. condition: null));
  39. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  40. isInheritedEffect: true,
  41. card: card,
  42. condition: null));
  43. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(
  44. isInheritedEffect: false,
  45. card: card,
  46. condition: null));
  47. }
  48. #endregion
  49. #region Hand - Main
  50. if (timing == EffectTiming.OnDeclaration)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("<De-Digivolve 1> all of your opponent's Digimon", CanUseCondition, card);
  54. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  55. activateClass.SetIsDigimonEffect(true);
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[Hand][Main] By paying 3 cost and placing this card as the bottom digivolution card of 1 of your Digimon that's level 6 or has the [Legend-Arms] trait, <De-Digivolve 1> all of your opponent's Digimon with as much or less DP than that Digimon.";
  60. }
  61. bool IsLevel6OrHasLegendArmsTrait(Permanent targetPermanent)
  62. {
  63. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  64. {
  65. if (targetPermanent.TopCard.HasLevel && targetPermanent.Level == 6)
  66. return true;
  67. if (targetPermanent.TopCard.ContainsTraits("Legend-Arms"))
  68. return true;
  69. }
  70. return false;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. if (CardEffectCommons.IsExistOnHand(card))
  75. {
  76. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsLevel6OrHasLegendArmsTrait))
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable hashtable)
  84. {
  85. Permanent selectedPermanent = null;
  86. if (CardEffectCommons.HasMatchConditionPermanent(IsLevel6OrHasLegendArmsTrait))
  87. {
  88. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLevel6OrHasLegendArmsTrait));
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: IsLevel6OrHasLegendArmsTrait,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: maxCount,
  96. canNoSelect: false,
  97. canEndNotMax: false,
  98. selectPermanentCoroutine: SelectPermanentCoroutine,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.Custom,
  101. cardEffect: activateClass);
  102. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. selectedPermanent = permanent;
  107. yield return null;
  108. }
  109. }
  110. if (selectedPermanent != null)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-3, activateClass));
  113. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  114. new List<CardSource>() { card },
  115. activateClass));
  116. List<Permanent> enemyPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Where(x => x.DP <= selectedPermanent.DP).ToList();
  117. foreach(Permanent permanent in enemyPermanents)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  120. }
  121. }
  122. }
  123. }
  124. #endregion
  125. #region When Digivolving
  126. if (timing == EffectTiming.OnEnterFieldAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Unaffected by opponents Digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[When Digivolving] 1 of your Digimon isn't affected by your opponent's Digimon effects until the end of your opponent's turn.";
  135. }
  136. bool IsYourDigimon(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. Permanent selectedPermanent = null;
  151. if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon))
  152. {
  153. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsYourDigimon));
  154. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  155. selectPermanentEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: IsYourDigimon,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. maxCount: maxCount,
  161. canNoSelect: false,
  162. canEndNotMax: false,
  163. selectPermanentCoroutine: SelectPermanentCoroutine,
  164. afterSelectPermanentCoroutine: null,
  165. mode: SelectPermanentEffect.Mode.Custom,
  166. cardEffect: activateClass);
  167. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will not be affected by the effect's of your opponent's Digimon.", "The opponent is selecting 1 Digimon that will not be affected by the effect's of your Digimon.");
  168. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  169. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  170. {
  171. selectedPermanent = permanent;
  172. yield return null;
  173. }
  174. }
  175. if(selectedPermanent != null)
  176. {
  177. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  178. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseConditionImmunity, card);
  179. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  180. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  181. bool CanUseConditionImmunity(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  184. }
  185. bool CardCondition(CardSource cardSource)
  186. {
  187. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  188. {
  189. if (cardSource == selectedPermanent.TopCard)
  190. {
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. bool SkillCondition(ICardEffect cardEffect)
  197. {
  198. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  199. {
  200. if (cardEffect.IsDigimonEffect)
  201. {
  202. return true;
  203. }
  204. if (cardEffect.IsDigimonEffect && cardEffect.IsSecurityEffect)
  205. {
  206. return true;
  207. }
  208. }
  209. return false;
  210. }
  211. ICardEffect GetCardEffect(EffectTiming _timing)
  212. {
  213. if (_timing == EffectTiming.None)
  214. {
  215. return canNotAffectedClass;
  216. }
  217. return null;
  218. }
  219. }
  220. }
  221. }
  222. #endregion
  223. #region Opponent's Turn - ESS
  224. if (timing == EffectTiming.None)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  227. {
  228. if(card.PermanentOfThisCard().TopCard != card)
  229. {
  230. Permanent selectedPermanent = card.PermanentOfThisCard();
  231. CanNotBeRemovedClass canNotBeRemovedClass = new CanNotBeRemovedClass();
  232. canNotBeRemovedClass.SetUpICardEffect("Can't leave battle area except by deletion effect", CanUseProtectionCondition, card);
  233. canNotBeRemovedClass.SetUpCanNotBeRemovedClass(permanentCondition: PermanentCondition);
  234. canNotBeRemovedClass.SetIsInheritedEffect(true);
  235. if(!cardEffects.Contains(canNotBeRemovedClass))
  236. cardEffects.Add(canNotBeRemovedClass);
  237. bool CanUseProtectionCondition(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.IsOpponentTurn(card))
  240. {
  241. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  242. {
  243. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  244. {
  245. return true;
  246. }
  247. }
  248. }
  249. return false;
  250. }
  251. bool PermanentCondition(Permanent permanent)
  252. {
  253. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  254. {
  255. if (permanent == selectedPermanent)
  256. {
  257. if (selectedPermanent.TopCard != card)
  258. {
  259. if (selectedPermanent.TopCard.CardNames.Contains("RagnaLoardmon"))
  260. {
  261. return true;
  262. }
  263. }
  264. }
  265. }
  266. return false;
  267. }
  268. }
  269. }
  270. }
  271. #endregion
  272. return cardEffects;
  273. }
  274. }
  275. }