EX4_073.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_073 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.ContainsCardName("Omnimon") && targetPermanent.TopCard.HasLevel && targetPermanent.Level == 7;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnEnterFieldAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("De-Digivolve 3 on 1 Digimon and delete Digimon so that their play cost total is up to 6", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[When Digivolving] <De-Digivolve 3> 1 of your opponent's Digimon. Then, choose any number of your opponent's Digimon so that their play cost total is up to 6 and delete them.";
  29. }
  30. bool CanSelectPermanentCondition(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  33. }
  34. bool CanSelectPermanentCondition1(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  37. {
  38. if (permanent.TopCard.GetCostItself <= 6)
  39. {
  40. if (permanent.TopCard.HasPlayCost)
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. return true;
  59. }
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  72. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  73. selectPermanentEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectPermanentCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: CanEndSelectCondition,
  78. maxCount: maxCount,
  79. canNoSelect: false,
  80. canEndNotMax: false,
  81. selectPermanentCoroutine: SelectPermanentCoroutine,
  82. afterSelectPermanentCoroutine: null,
  83. mode: SelectPermanentEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. bool CanEndSelectCondition(List<Permanent> permanents)
  88. {
  89. if (permanents.Count <= 0)
  90. {
  91. return false;
  92. }
  93. return true;
  94. }
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. Permanent selectedPermanent = permanent;
  98. if (selectedPermanent != null)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 3, activateClass).Degeneration());
  101. }
  102. yield return null;
  103. }
  104. }
  105. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  106. {
  107. List<Permanent> selectedPermanents = new List<Permanent>();
  108. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1);
  109. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  110. selectPermanentEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectPermanentCondition1,
  113. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  114. canEndSelectCondition: CanEndSelectCondition,
  115. maxCount: maxCount,
  116. canNoSelect: false,
  117. canEndNotMax: true,
  118. selectPermanentCoroutine: null,
  119. afterSelectPermanentCoroutine: null,
  120. mode: SelectPermanentEffect.Mode.Destroy,
  121. cardEffect: activateClass);
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. bool CanEndSelectCondition(List<Permanent> permanents)
  124. {
  125. if (permanents.Count <= 0)
  126. {
  127. return false;
  128. }
  129. int sumCost = 0;
  130. foreach (Permanent permanent1 in permanents)
  131. {
  132. sumCost += permanent1.TopCard.GetCostItself;
  133. }
  134. if (sumCost > 6)
  135. {
  136. return false;
  137. }
  138. return true;
  139. }
  140. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  141. {
  142. int sumCost = 0;
  143. foreach (Permanent permanent1 in permanents)
  144. {
  145. sumCost += permanent1.TopCard.GetCostItself;
  146. }
  147. sumCost += permanent.TopCard.GetCostItself;
  148. if (sumCost > 6)
  149. {
  150. return false;
  151. }
  152. return true;
  153. }
  154. }
  155. }
  156. }
  157. if (timing == EffectTiming.OnAllyAttack)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("Trash digivolution cards to delete Digimon or Tamer", CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  162. cardEffects.Add(activateClass);
  163. string EffectDiscription()
  164. {
  165. return "[When Attacking] By trashing up to 3 level 6 or higher cards in this Digimon's digivolution cards, among your opponent's Digimon and Tamers, delete 1 with the lowest play cost for each card trashed. If you trashed 3 cards, trash the top 2 cards of your opponent's security stack.";
  166. }
  167. bool CanSelectCardCondition(CardSource cardSource)
  168. {
  169. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  170. {
  171. if (cardSource.Level >= 6)
  172. {
  173. if (cardSource.HasLevel)
  174. {
  175. return true;
  176. }
  177. }
  178. }
  179. return false;
  180. }
  181. bool CanSelectPermanentCondition(Permanent permanent)
  182. {
  183. return CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, false);
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  192. {
  193. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  201. {
  202. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  203. {
  204. Permanent selectedPermanent = card.PermanentOfThisCard();
  205. int trashCount = 0;
  206. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  207. {
  208. List<CardSource> selectedCards = new List<CardSource>();
  209. int maxCount = Math.Min(3, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  210. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  211. selectCardEffect.SetUp(
  212. canTargetCondition: CanSelectCardCondition,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: CanEndSelectCondition,
  215. canNoSelect: () => true,
  216. selectCardCoroutine: SelectCardCoroutine,
  217. afterSelectCardCoroutine: null,
  218. message: "Select digivolution cards to discard.",
  219. maxCount: maxCount,
  220. canEndNotMax: true,
  221. isShowOpponent: true,
  222. mode: SelectCardEffect.Mode.Custom,
  223. root: SelectCardEffect.Root.Custom,
  224. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  225. canLookReverseCard: true,
  226. selectPlayer: card.Owner,
  227. cardEffect: null);
  228. selectCardEffect.SetUpCustomMessage("Select digivolution cards to discard.", "The opponent is selecting digivolution cards to discard.");
  229. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  230. bool CanEndSelectCondition(List<CardSource> cardSources)
  231. {
  232. if (CardEffectCommons.HasNoElement(cardSources))
  233. {
  234. return false;
  235. }
  236. return true;
  237. }
  238. IEnumerator SelectCardCoroutine(CardSource cardSource)
  239. {
  240. selectedCards.Add(cardSource);
  241. yield return null;
  242. }
  243. if (selectedCards.Count >= 1)
  244. {
  245. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  246. trashCount = selectedCards.Count;
  247. }
  248. }
  249. if (trashCount >= 1)
  250. {
  251. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  252. {
  253. for (int i = 0; i < trashCount; i++)
  254. {
  255. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  256. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  257. selectPermanentEffect.SetUp(
  258. selectPlayer: card.Owner,
  259. canTargetCondition: CanSelectPermanentCondition,
  260. canTargetCondition_ByPreSelecetedList: null,
  261. canEndSelectCondition: null,
  262. maxCount: maxCount,
  263. canNoSelect: false,
  264. canEndNotMax: false,
  265. selectPermanentCoroutine: null,
  266. afterSelectPermanentCoroutine: null,
  267. mode: SelectPermanentEffect.Mode.Destroy,
  268. cardEffect: activateClass);
  269. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  270. }
  271. }
  272. if (trashCount == 3)
  273. {
  274. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  275. player: card.Owner.Enemy,
  276. destroySecurityCount: 2,
  277. cardEffect: activateClass,
  278. fromTop: true).DestroySecurity());
  279. }
  280. }
  281. }
  282. }
  283. }
  284. return cardEffects;
  285. }
  286. }
  287. }