EX5_073.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_073 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  13. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  14. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  15. addJogressConditionClass.SetNotShowUI(true);
  16. cardEffects.Add(addJogressConditionClass);
  17. bool CanUseCondition(Hashtable hashtable)
  18. {
  19. return true;
  20. }
  21. JogressCondition GetJogress(CardSource cardSource)
  22. {
  23. if (cardSource == card)
  24. {
  25. bool PermanentCondition1(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.TopCard.CardNames.Contains("Apollomon"))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool PermanentCondition2(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  39. {
  40. if (permanent.TopCard.CardNames.Contains("Dianamon"))
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. JogressConditionElement[] elements = new JogressConditionElement[]
  48. {
  49. new JogressConditionElement(PermanentCondition1, "Apollomon"),
  50. new JogressConditionElement(PermanentCondition2, "Dianamon"),
  51. };
  52. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  53. return jogressCondition;
  54. }
  55. return null;
  56. }
  57. }
  58. if (timing == EffectTiming.None)
  59. {
  60. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  61. }
  62. if (timing == EffectTiming.None)
  63. {
  64. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  65. }
  66. if (timing == EffectTiming.OnEnterFieldAnyone)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("Trash digivolution cards and delete 1 Digimon", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  71. cardEffects.Add(activateClass);
  72. string EffectDiscription()
  73. {
  74. return "[When Digivolving] [When Attacking] If DNA digivolving, trash any 8 digivolution cards from your opponent's Digimon. Then, delete 1 of their Digimon with as many or fewer digivolution cards as this Digimon.";
  75. }
  76. bool CanSelectPermanentCondition(Permanent permanent)
  77. {
  78. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  79. {
  80. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  81. {
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanSelectCardCondition(CardSource cardSource)
  88. {
  89. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  90. }
  91. bool CanSelectPermanentCondition1(Permanent permanent)
  92. {
  93. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  94. {
  95. if (CardEffectCommons.IsExistOnBattleArea(card))
  96. {
  97. if (permanent.DigivolutionCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Count)
  98. {
  99. return true;
  100. }
  101. }
  102. }
  103. return false;
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  108. {
  109. return true;
  110. }
  111. return false;
  112. }
  113. bool CanActivateCondition(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.IsExistOnBattleArea(card))
  116. {
  117. if (CardEffectCommons.IsJogress(hashtable))
  118. {
  119. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  120. {
  121. return true;
  122. }
  123. }
  124. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  132. {
  133. if (CardEffectCommons.IsJogress(_hashtable))
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  138. permanentCondition: CanSelectPermanentCondition,
  139. cardCondition: CanSelectCardCondition,
  140. maxCount: 8,
  141. canNoTrash: false,
  142. isFromOnly1Permanent: false,
  143. activateClass: activateClass
  144. ));
  145. }
  146. }
  147. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  148. {
  149. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentCondition1,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: null,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.Destroy,
  162. cardEffect: activateClass);
  163. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  164. }
  165. }
  166. }
  167. if (timing == EffectTiming.OnAllyAttack)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Delete 1 Digimon with as many or fewer digivolution cards as this Digimon", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  172. cardEffects.Add(activateClass);
  173. string EffectDiscription()
  174. {
  175. return "[When Attacking] If DNA digivolving, trash any 8 digivolution cards from your opponent's Digimon. Then, delete 1 of their Digimon with as many or fewer digivolution cards as this Digimon.";
  176. }
  177. bool CanSelectPermanentCondition1(Permanent permanent)
  178. {
  179. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  180. {
  181. if (CardEffectCommons.IsExistOnBattleArea(card))
  182. {
  183. if (permanent.DigivolutionCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Count)
  184. {
  185. return true;
  186. }
  187. }
  188. }
  189. return false;
  190. }
  191. bool CanUseCondition(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  194. {
  195. return true;
  196. }
  197. return false;
  198. }
  199. bool CanActivateCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.IsExistOnBattleArea(card))
  202. {
  203. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  211. {
  212. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  213. {
  214. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  215. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  216. selectPermanentEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: CanSelectPermanentCondition1,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: maxCount,
  222. canNoSelect: false,
  223. canEndNotMax: false,
  224. selectPermanentCoroutine: null,
  225. afterSelectPermanentCoroutine: null,
  226. mode: SelectPermanentEffect.Mode.Destroy,
  227. cardEffect: activateClass);
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. }
  230. }
  231. }
  232. if (timing == EffectTiming.WhenRemoveField)
  233. {
  234. ActivateClass activateClass = new ActivateClass();
  235. activateClass.SetUpICardEffect("Prevent this Digimon from being leaving the battle area by opponent's effect", CanUseCondition, card);
  236. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  237. activateClass.SetHashString("Substitute_EX5_073");
  238. cardEffects.Add(activateClass);
  239. string EffectDiscription()
  240. {
  241. return "[All Turns] When this Digimon would leave the battle area by an opponent's effect, by trashing 2 same-level cards in this Digimon's digivolution cards, prevent it from leaving.";
  242. }
  243. bool CanSelectCardCondition(CardSource cardSource)
  244. {
  245. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  246. {
  247. if (CardEffectCommons.IsExistOnBattleArea(card))
  248. {
  249. if (card.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  250. {
  251. foreach (CardSource cardSource1 in card.PermanentOfThisCard().DigivolutionCards)
  252. {
  253. if (cardSource != cardSource1)
  254. {
  255. if (cardSource.Level == cardSource1.Level)
  256. {
  257. if (!cardSource1.CanNotTrashFromDigivolutionCards(activateClass))
  258. {
  259. if (cardSource.HasLevel && cardSource1.HasLevel)
  260. {
  261. return true;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. }
  270. return false;
  271. }
  272. bool CanUseCondition(Hashtable hashtable)
  273. {
  274. if (CardEffectCommons.IsExistOnBattleArea(card))
  275. {
  276. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  277. {
  278. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  279. {
  280. return true;
  281. }
  282. }
  283. }
  284. return false;
  285. }
  286. bool CanActivateCondition(Hashtable hashtable)
  287. {
  288. if (CardEffectCommons.IsExistOnBattleArea(card))
  289. {
  290. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  291. {
  292. List<CardSource> canSelectCards = new List<CardSource>();
  293. foreach (CardSource cardSource in card.PermanentOfThisCard().DigivolutionCards)
  294. {
  295. canSelectCards.Add(cardSource);
  296. }
  297. if (canSelectCards.Count >= 2)
  298. {
  299. List<CardSource[]> cardsList = ParameterComparer.Enumerate(canSelectCards, 2).ToList();
  300. foreach (CardSource[] cardSources in cardsList)
  301. {
  302. if (cardSources.Length == 2)
  303. {
  304. if (cardSources[0].Level == cardSources[1].Level)
  305. {
  306. if (cardSources[0].HasLevel && cardSources[1].HasLevel)
  307. {
  308. return true;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. return false;
  317. }
  318. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  319. {
  320. if (CardEffectCommons.IsExistOnBattleArea(card))
  321. {
  322. Permanent selectedPermanent = card.PermanentOfThisCard();
  323. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  324. {
  325. List<CardSource> selectedCards = new List<CardSource>();
  326. int maxCount = 2;
  327. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  328. selectCardEffect.SetUp(
  329. canTargetCondition: CanSelectCardCondition,
  330. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  331. canEndSelectCondition: CanEndSelectCondition,
  332. canNoSelect: () => true,
  333. selectCardCoroutine: SelectCardCoroutine,
  334. afterSelectCardCoroutine: null,
  335. message: "Select cards to discard.",
  336. maxCount: maxCount,
  337. canEndNotMax: false,
  338. isShowOpponent: true,
  339. mode: SelectCardEffect.Mode.Custom,
  340. root: SelectCardEffect.Root.Custom,
  341. customRootCardList: selectedPermanent.DigivolutionCards,
  342. canLookReverseCard: true,
  343. selectPlayer: card.Owner,
  344. cardEffect: activateClass);
  345. selectCardEffect.SetNotShowCard();
  346. yield return StartCoroutine(selectCardEffect.Activate());
  347. bool CanEndSelectCondition(List<CardSource> cardSources)
  348. {
  349. if (CardEffectCommons.HasNoElement(cardSources))
  350. {
  351. return false;
  352. }
  353. List<int> levels = cardSources
  354. .Map(cardSource1 => cardSource1.Level)
  355. .Distinct()
  356. .ToList();
  357. if (levels.Count > 1)
  358. {
  359. return false;
  360. }
  361. return true;
  362. }
  363. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  364. {
  365. List<int> levels = cardSources
  366. .Map(cardSource1 => cardSource1.Level)
  367. .Concat(new List<int>() { cardSource.Level })
  368. .Distinct()
  369. .ToList();
  370. if (levels.Count > 1)
  371. {
  372. return false;
  373. }
  374. return true;
  375. }
  376. IEnumerator SelectCardCoroutine(CardSource cardSource)
  377. {
  378. selectedCards.Add(cardSource);
  379. yield return null;
  380. }
  381. if (selectedCards.Count >= 1)
  382. {
  383. if (selectedCards.Count == 2)
  384. {
  385. selectedPermanent.willBeRemoveField = false;
  386. selectedPermanent.HideDeleteEffect();
  387. selectedPermanent.HideHandBounceEffect();
  388. selectedPermanent.HideDeckBounceEffect();
  389. }
  390. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
  391. selectedPermanent,
  392. selectedCards,
  393. activateClass).TrashDigivolutionCards());
  394. }
  395. }
  396. }
  397. }
  398. }
  399. return cardEffects;
  400. }
  401. }