EX6_010.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_010 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5)
  18. {
  19. return targetPermanent.TopCard.ContainsTraits("Legend-Arms");
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 4,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null));
  29. }
  30. #endregion
  31. #region Raid
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card,
  35. condition: null));
  36. }
  37. #endregion
  38. #region Piercing
  39. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  40. {
  41. cardEffects.Add(
  42. CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  43. cardEffects.Add(
  44. CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  45. }
  46. #endregion
  47. #region Hand - Main
  48. if (timing == EffectTiming.OnDeclaration)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect(
  52. "Delete 1 of your opponent's Digimon with as much or less DP as that Digimon", CanUseCondition,
  53. card);
  54. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  55. activateClass.SetIsDigimonEffect(true);
  56. cardEffects.Add(activateClass);
  57. string EffectDescription()
  58. {
  59. return
  60. "[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, delete 1 of your opponent's Digimon with as much or less DP as that Digimon.";
  61. }
  62. bool IsLevel6OrHasLegendArmsTrait(Permanent targetPermanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  65. {
  66. if (targetPermanent.TopCard.HasLevel && targetPermanent.Level == 6)
  67. return true;
  68. if (targetPermanent.TopCard.ContainsTraits("Legend-Arms"))
  69. return true;
  70. }
  71. return false;
  72. }
  73. bool IsEnemyPermanentWithAsMuchOrLessDp(Permanent permanent)
  74. {
  75. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  76. {
  77. if (CardEffectCommons.IsExistOnBattleArea(card))
  78. {
  79. if (permanent.DP <= card.PermanentOfThisCard().DP)
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.IsExistOnHand(card))
  90. {
  91. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsLevel6OrHasLegendArmsTrait))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. IEnumerator ActivateCoroutine(Hashtable hashtable)
  99. {
  100. Permanent selectedPermanent = null;
  101. if (CardEffectCommons.HasMatchConditionPermanent(IsLevel6OrHasLegendArmsTrait))
  102. {
  103. int maxCount = Math.Min(1,
  104. CardEffectCommons.MatchConditionPermanentCount(IsLevel6OrHasLegendArmsTrait));
  105. SelectPermanentEffect selectPermanentEffect =
  106. GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: IsLevel6OrHasLegendArmsTrait,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.",
  120. "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  123. {
  124. selectedPermanent = permanent;
  125. yield return null;
  126. }
  127. }
  128. if (selectedPermanent != null)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(
  131. card.Owner.AddMemory(-3, activateClass));
  132. yield return ContinuousController.instance.StartCoroutine(
  133. selectedPermanent.AddDigivolutionCardsBottom(
  134. new List<CardSource>() { card },
  135. activateClass));
  136. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanentWithAsMuchOrLessDp))
  137. {
  138. int enemyCount = Math.Min(1,
  139. CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanentWithAsMuchOrLessDp));
  140. SelectPermanentEffect selectEnemyEffect =
  141. GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectEnemyEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: IsEnemyPermanentWithAsMuchOrLessDp,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: enemyCount,
  148. canNoSelect: false,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: null,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Destroy,
  153. cardEffect: activateClass);
  154. yield return ContinuousController.instance.StartCoroutine(selectEnemyEffect.Activate());
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. #region When Digivolving
  161. if (timing == EffectTiming.OnEnterFieldAnyone)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("May attack", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  166. EffectDescription());
  167. cardEffects.Add(activateClass);
  168. string EffectDescription()
  169. {
  170. return
  171. "[When Digivolving] 1 of your Digimon may attack.";
  172. }
  173. bool IsYourDigimon(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable hashtable)
  186. {
  187. Permanent selectedPermanent = null;
  188. if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon))
  189. {
  190. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsYourDigimon));
  191. SelectPermanentEffect selectPermanentEffect =
  192. GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: IsYourDigimon,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: maxCount,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  206. "The opponent is selecting 1 Digimon that will attack.");
  207. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  208. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  209. {
  210. selectedPermanent = permanent;
  211. yield return null;
  212. }
  213. }
  214. if (selectedPermanent != null)
  215. {
  216. if (selectedPermanent.CanAttack(activateClass))
  217. {
  218. SelectAttackEffect selectAttackEffect =
  219. GManager.instance.GetComponent<SelectAttackEffect>();
  220. selectAttackEffect.SetUp(
  221. attacker: selectedPermanent,
  222. canAttackPlayerCondition: () => true,
  223. defenderCondition: (permanent) => true,
  224. cardEffect: activateClass);
  225. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  226. }
  227. }
  228. }
  229. }
  230. #endregion
  231. #region Your Turn - ESS
  232. if (timing == EffectTiming.None)
  233. {
  234. DisableEffectClass invalidationClass = new DisableEffectClass();
  235. invalidationClass.SetUpICardEffect("Ignore Security Effect", CanUseCondition, card);
  236. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  237. invalidationClass.SetIsInheritedEffect(true);
  238. cardEffects.Add(invalidationClass);
  239. bool CanUseCondition(Hashtable hashtable)
  240. {
  241. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  242. {
  243. if (CardEffectCommons.IsOwnerTurn(card))
  244. {
  245. return true;
  246. }
  247. }
  248. return false;
  249. }
  250. bool InvalidateCondition(ICardEffect cardEffect)
  251. {
  252. if (cardEffect != null)
  253. {
  254. if (cardEffect.EffectSourceCard != null)
  255. {
  256. if (cardEffect.IsSecurityEffect)
  257. {
  258. if (GManager.instance.attackProcess.AttackingPermanent ==
  259. card.PermanentOfThisCard())
  260. {
  261. if (card.PermanentOfThisCard().TopCard.EqualsCardName("RagnaLoardmon"))
  262. {
  263. return true;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. return false;
  270. }
  271. }
  272. #endregion
  273. return cardEffects;
  274. }
  275. }
  276. }