EX9_074.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Kimeramon
  7. namespace DCGO.CardEffects.EX9
  8. {
  9. public class EX9_074 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Assembly
  15. if (timing == EffectTiming.None)
  16. {
  17. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  18. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  19. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  20. addAssemblyConditionClass.SetNotShowUI(true);
  21. cardEffects.Add(addAssemblyConditionClass);
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return true;
  25. }
  26. AssemblyCondition GetAssembly(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (cardSource != null)
  34. {
  35. if (cardSource.Owner == card.Owner)
  36. {
  37. if (cardSource.IsDigimon)
  38. {
  39. if (cardSource.IsLevel4 || cardSource.Level_Assembly.Contains(4))
  40. {
  41. if (cardSource.HasDMTraits)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  52. {
  53. List<string> cardNames = new List<string>();
  54. foreach (CardSource cardSource1 in cardSources)
  55. {
  56. foreach (string cardName in cardSource1.CardNames)
  57. {
  58. if (!cardNames.Contains(cardName))
  59. {
  60. cardNames.Add(cardName);
  61. }
  62. }
  63. }
  64. if (cardSource.CardNames.Count((cardName) => cardNames.Contains(cardName)) >= 1)
  65. {
  66. return false;
  67. }
  68. return true;
  69. }
  70. AssemblyCondition assemblyCondition = new AssemblyCondition(
  71. element:element,
  72. CanTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  73. selectMessage: "7 level 4 [DM] trait Digimon cards w/different names",
  74. elementCount: 7,
  75. reduceCost: 7);
  76. return assemblyCondition;
  77. }
  78. return null;
  79. }
  80. }
  81. #endregion
  82. #region Sec +1
  83. if (timing == EffectTiming.None)
  84. {
  85. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  86. changeValue: 1,
  87. isInheritedEffect: false,
  88. card: card,
  89. condition: null));
  90. }
  91. #endregion
  92. #region Rush
  93. if (timing == EffectTiming.None)
  94. {
  95. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  96. }
  97. #endregion
  98. #region On Play
  99. if (timing == EffectTiming.OnEnterFieldAnyone)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Place digimon from trash as top source card, delete digimon", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  104. activateClass.SetIsDigimonEffect(true);
  105. cardEffects.Add(activateClass);
  106. string EffectDiscription()
  107. {
  108. return "[On Play] You may place 1 level 4 or lower [DM] trait Digimon card from your trash as this Digimon's top digivolution card. Then, delete 1 of your opponent's Digimon with the same color as any of this Digimon's digivolution cards. If this Digimon has 6 or more colors in its digivolution cards, instead delete 1 of each of your opponent's Digimon with different colors.";
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsExistOnBattleArea(card);
  117. }
  118. bool CanSelectCardCondition(CardSource cardSource)
  119. {
  120. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 4 && cardSource.HasDMTraits;
  121. }
  122. bool CanSelectPermanentCondition(Permanent permanent, List<CardColor> cardColors)
  123. {
  124. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.CardColors.Exists(color => cardColors.Contains(color));
  125. }
  126. bool CanEndSelectCondition(List<Permanent> permanents)
  127. {
  128. if (permanents.Count <= 0)
  129. return false;
  130. return true;
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  135. {
  136. CardSource selectedCard = null;
  137. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  138. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  139. selectCardEffect.SetUp(
  140. canTargetCondition: CanSelectCardCondition,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. canNoSelect: () => true,
  144. selectCardCoroutine: SelectCardCoroutine,
  145. afterSelectCardCoroutine: null,
  146. message: "Select 1 [DM] digimon to add as top source",
  147. maxCount: maxCount,
  148. canEndNotMax: true,
  149. isShowOpponent: true,
  150. mode: SelectCardEffect.Mode.Custom,
  151. root: SelectCardEffect.Root.Trash,
  152. customRootCardList: null,
  153. canLookReverseCard: true,
  154. selectPlayer: card.Owner,
  155. cardEffect: activateClass);
  156. selectCardEffect.SetUpCustomMessage("Select 1 [DM] digimon to add as top source", "The opponent is selecting 1 digimon to add as top source");
  157. yield return StartCoroutine(selectCardEffect.Activate());
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCard = cardSource;
  161. yield return null;
  162. }
  163. if (selectedCard != null)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  166. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(new List<CardSource>() { selectedCard }, activateClass));
  167. }
  168. }
  169. List<CardColor> colours = card.PermanentOfThisCard().DigivolutionCards
  170. .Filter(x => !x.IsFlipped)
  171. .SelectMany(e => e.CardColors)
  172. .Distinct()
  173. .ToList();
  174. if (colours.Count <= 5 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CanSelectPermanentCondition(permanent, colours)))
  175. {
  176. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(permanent => CanSelectPermanentCondition(permanent, colours)));
  177. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  178. selectPermanentEffect.SetUp(
  179. selectPlayer: card.Owner,
  180. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, colours),
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. maxCount: maxCount1,
  184. canNoSelect: false,
  185. canEndNotMax: false,
  186. selectPermanentCoroutine: null,
  187. afterSelectPermanentCoroutine: null,
  188. mode: SelectPermanentEffect.Mode.Destroy,
  189. cardEffect: activateClass);
  190. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  191. }
  192. if (colours.Count >= 6 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)))
  193. {
  194. List<Permanent> permanentToDelete = new List<Permanent>();
  195. List<CardColor> selectableColors = new List<CardColor>();
  196. foreach (string cardColor in DataBase.CardColorNameDictionary.Values)
  197. {
  198. CardColor compareColor = DictionaryUtility.GetCardColor(cardColor.Trim(), DataBase.CardColorNameDictionary);
  199. bool CanSelectOpponentDigimon(Permanent permanent)
  200. {
  201. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  202. permanent.TopCard.CardColors.Contains(compareColor);
  203. }
  204. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimon))
  205. {
  206. selectableColors.Add(compareColor);
  207. }
  208. }
  209. foreach(CardColor deletableColor in selectableColors)
  210. {
  211. bool CanSelectOpponentDigimon(Permanent permanent)
  212. {
  213. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  214. permanent.TopCard.CardColors.Contains(deletableColor) &&
  215. CanTargetCondition_ByPreSelecetedList(permanentToDelete, permanent);
  216. }
  217. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimon))
  218. {
  219. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  220. selectPermanentEffect.SetUp(
  221. selectPlayer: card.Owner,
  222. canTargetCondition: CanSelectOpponentDigimon,
  223. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  224. canEndSelectCondition: CanEndSelectCondition,
  225. maxCount: 1,
  226. canNoSelect: false,
  227. canEndNotMax: true,
  228. selectPermanentCoroutine: DigimonToDelete,
  229. afterSelectPermanentCoroutine: null,
  230. mode: SelectPermanentEffect.Mode.Custom,
  231. cardEffect: activateClass);
  232. selectPermanentEffect.SetUpCustomMessage($"Select 1 {deletableColor.ToString()} Digimon to delete", $"Opponent is selecting 1 {deletableColor.ToString()} Digimon to delete");
  233. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  234. }
  235. }
  236. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  237. {
  238. if (permanentToDelete.Contains(permanent))
  239. return false;
  240. return true;
  241. }
  242. IEnumerator DigimonToDelete (Permanent permanent)
  243. {
  244. if(permanent != null)
  245. permanentToDelete.Add(permanent);
  246. yield return null;
  247. }
  248. if(permanentToDelete.Count > 0)
  249. {
  250. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(permanentToDelete, hashtable).Destroy());
  251. }
  252. }
  253. }
  254. }
  255. #endregion
  256. #region When Digivolving
  257. if (timing == EffectTiming.OnEnterFieldAnyone)
  258. {
  259. ActivateClass activateClass = new ActivateClass();
  260. activateClass.SetUpICardEffect("Place digimon from trash as top source card, delete digimon", CanUseCondition, card);
  261. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  262. activateClass.SetIsDigimonEffect(true);
  263. cardEffects.Add(activateClass);
  264. string EffectDiscription()
  265. {
  266. return "[When Digivolving] You may place 1 level 4 or lower [DM] trait Digimon card from your trash as this Digimon's top digivolution card. Then, delete 1 of your opponent's Digimon with the same color as any of this Digimon's digivolution cards. If this Digimon has 6 or more colors in its digivolution cards, instead delete 1 of each of your opponent's Digimon with different colors.";
  267. }
  268. bool CanUseCondition(Hashtable hashtable)
  269. {
  270. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  271. }
  272. bool CanActivateCondition(Hashtable hashtable)
  273. {
  274. return CardEffectCommons.IsExistOnBattleArea(card);
  275. }
  276. bool CanSelectCardCondition(CardSource cardSource)
  277. {
  278. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 4 && cardSource.HasDMTraits;
  279. }
  280. bool CanSelectPermanentCondition(Permanent permanent, List<CardColor> cardColors)
  281. {
  282. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.TopCard.CardColors.Exists(color => cardColors.Contains(color));
  283. }
  284. bool CanEndSelectCondition(List<Permanent> permanents)
  285. {
  286. if (permanents.Count <= 0)
  287. return false;
  288. return true;
  289. }
  290. IEnumerator ActivateCoroutine(Hashtable hashtable)
  291. {
  292. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  293. {
  294. CardSource selectedCard = null;
  295. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  296. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  297. selectCardEffect.SetUp(
  298. canTargetCondition: CanSelectCardCondition,
  299. canTargetCondition_ByPreSelecetedList: null,
  300. canEndSelectCondition: null,
  301. canNoSelect: () => true,
  302. selectCardCoroutine: SelectCardCoroutine,
  303. afterSelectCardCoroutine: null,
  304. message: "Select 1 [DM] digimon to add as top source",
  305. maxCount: maxCount,
  306. canEndNotMax: true,
  307. isShowOpponent: true,
  308. mode: SelectCardEffect.Mode.Custom,
  309. root: SelectCardEffect.Root.Trash,
  310. customRootCardList: null,
  311. canLookReverseCard: true,
  312. selectPlayer: card.Owner,
  313. cardEffect: activateClass);
  314. selectCardEffect.SetUpCustomMessage("Select 1 [DM] digimon to add as top source", "The opponent is selecting 1 digimon to add as top source");
  315. yield return StartCoroutine(selectCardEffect.Activate());
  316. IEnumerator SelectCardCoroutine(CardSource cardSource)
  317. {
  318. selectedCard = cardSource;
  319. yield return null;
  320. }
  321. if (selectedCard != null)
  322. {
  323. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  324. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(new List<CardSource>() { selectedCard }, activateClass));
  325. }
  326. }
  327. List<CardColor> colours = card.PermanentOfThisCard().DigivolutionCards
  328. .Filter(x => !x.IsFlipped)
  329. .SelectMany(e => e.CardColors)
  330. .Distinct()
  331. .ToList();
  332. if (colours.Count <= 5 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CanSelectPermanentCondition(permanent, colours)))
  333. {
  334. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(permanent => CanSelectPermanentCondition(permanent, colours)));
  335. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  336. selectPermanentEffect.SetUp(
  337. selectPlayer: card.Owner,
  338. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, colours),
  339. canTargetCondition_ByPreSelecetedList: null,
  340. canEndSelectCondition: null,
  341. maxCount: maxCount1,
  342. canNoSelect: false,
  343. canEndNotMax: false,
  344. selectPermanentCoroutine: null,
  345. afterSelectPermanentCoroutine: null,
  346. mode: SelectPermanentEffect.Mode.Destroy,
  347. cardEffect: activateClass);
  348. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  349. }
  350. if (colours.Count >= 6 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, permanent => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)))
  351. {
  352. List<Permanent> permanentToDelete = new List<Permanent>();
  353. List<CardColor> selectableColors = new List<CardColor>();
  354. foreach (string cardColor in DataBase.CardColorNameDictionary.Values)
  355. {
  356. CardColor compareColor = DictionaryUtility.GetCardColor(cardColor.Trim(), DataBase.CardColorNameDictionary);
  357. bool CanSelectOpponentDigimon(Permanent permanent)
  358. {
  359. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  360. permanent.TopCard.CardColors.Contains(compareColor);
  361. }
  362. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimon))
  363. {
  364. selectableColors.Add(compareColor);
  365. }
  366. }
  367. foreach (CardColor deletableColor in selectableColors)
  368. {
  369. bool CanSelectOpponentDigimon(Permanent permanent)
  370. {
  371. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  372. permanent.TopCard.CardColors.Contains(deletableColor) &&
  373. CanTargetCondition_ByPreSelecetedList(permanentToDelete, permanent);
  374. }
  375. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimon))
  376. {
  377. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  378. selectPermanentEffect.SetUp(
  379. selectPlayer: card.Owner,
  380. canTargetCondition: CanSelectOpponentDigimon,
  381. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  382. canEndSelectCondition: CanEndSelectCondition,
  383. maxCount: 1,
  384. canNoSelect: false,
  385. canEndNotMax: true,
  386. selectPermanentCoroutine: DigimonToDelete,
  387. afterSelectPermanentCoroutine: null,
  388. mode: SelectPermanentEffect.Mode.Custom,
  389. cardEffect: activateClass);
  390. selectPermanentEffect.SetUpCustomMessage($"Select 1 {deletableColor.ToString()} Digimon to delete", $"Opponent is selecting 1 {deletableColor.ToString()} Digimon to delete");
  391. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  392. }
  393. }
  394. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  395. {
  396. if (permanentToDelete.Contains(permanent))
  397. return false;
  398. return true;
  399. }
  400. IEnumerator DigimonToDelete(Permanent permanent)
  401. {
  402. if (permanent != null)
  403. permanentToDelete.Add(permanent);
  404. yield return null;
  405. }
  406. if (permanentToDelete.Count > 0)
  407. {
  408. Hashtable _hashtable = new Hashtable();
  409. hashtable.Add("CardEffect", activateClass);
  410. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(permanentToDelete, _hashtable).Destroy());
  411. }
  412. }
  413. }
  414. }
  415. #endregion
  416. #region All Turns
  417. if (timing == EffectTiming.None)
  418. {
  419. int count()
  420. {
  421. if (CardEffectCommons.IsExistOnBattleArea(card))
  422. {
  423. return card.PermanentOfThisCard().DigivolutionCardsColors.Count;
  424. }
  425. return 0;
  426. }
  427. bool Condition()
  428. {
  429. if (CardEffectCommons.IsExistOnBattleArea(card))
  430. {
  431. if (count() >= 1)
  432. {
  433. return true;
  434. }
  435. }
  436. return false;
  437. }
  438. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(changeValue: () => 1000 * count(), isInheritedEffect: false, card: card, condition: Condition));
  439. }
  440. #endregion
  441. return cardEffects;
  442. }
  443. }
  444. }