EX1_073.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX1
  6. {
  7. public class EX1_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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Place cards in digivolution cards to gain Memory", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] You may place up to 5 level 5 red and black cards with [Cyborg] in their traits and different card numbers from your hand and/or trash in this Digimon's digivolution cards to gain 1 memory for each card placed.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.IsDigimon)
  25. {
  26. if (cardSource.Level == 5 && cardSource.HasLevel)
  27. {
  28. if (cardSource.CardTraits.Contains("Cyborg"))
  29. {
  30. if (cardSource.HasCardColor(CardColor.Red))
  31. {
  32. return true;
  33. }
  34. if (cardSource.HasCardColor(CardColor.Black))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  52. {
  53. return true;
  54. }
  55. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. List<CardSource> digivolutionCards = new List<CardSource>();
  67. bool CanSelectCardCondition1(CardSource cardSource)
  68. {
  69. if (CanSelectCardCondition(cardSource))
  70. {
  71. if (digivolutionCards.Count((cardSource1) => cardSource1.CardID == cardSource.CardID) == 0)
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. if (card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  79. {
  80. List<CardSource> selectedCards = new List<CardSource>();
  81. int maxCount = Math.Min(5, card.Owner.HandCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  82. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  83. selectHandEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectCardCondition1,
  86. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  87. canEndSelectCondition: CanEndSelectCondition,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: true,
  91. isShowOpponent: true,
  92. selectCardCoroutine: SelectCardCoroutine,
  93. afterSelectCardCoroutine: null,
  94. mode: SelectHandEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectHandEffect.SetUpCustomMessage("Select cards to place in Digivolution cards.", "The opponent is selecting cards.");
  97. yield return StartCoroutine(selectHandEffect.Activate());
  98. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  99. {
  100. List<string> cardIDs = new List<string>();
  101. foreach (CardSource cardSource1 in cardSources)
  102. {
  103. if (!cardIDs.Contains(cardSource1.CardID))
  104. {
  105. cardIDs.Add(cardSource1.CardID);
  106. }
  107. }
  108. if (cardIDs.Contains(cardSource.CardID))
  109. {
  110. return false;
  111. }
  112. return true;
  113. }
  114. bool CanEndSelectCondition(List<CardSource> cardSources)
  115. {
  116. List<string> cardIDs = new List<string>();
  117. foreach (CardSource cardSource1 in cardSources)
  118. {
  119. if (!cardIDs.Contains(cardSource1.CardID))
  120. {
  121. cardIDs.Add(cardSource1.CardID);
  122. }
  123. }
  124. if (cardIDs.Count != cardSources.Count)
  125. {
  126. return false;
  127. }
  128. return true;
  129. }
  130. IEnumerator SelectCardCoroutine(CardSource cardSource)
  131. {
  132. selectedCards.Add(cardSource);
  133. digivolutionCards.Add(cardSource);
  134. yield return null;
  135. }
  136. if (selectedCards.Count >= 1)
  137. {
  138. foreach (CardSource selectedCard in selectedCards)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  141. }
  142. }
  143. }
  144. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition1(cardSource)))
  145. {
  146. List<CardSource> selectedCards = new List<CardSource>();
  147. int maxCount = Math.Min(5 - digivolutionCards.Count, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  148. if (maxCount >= 1)
  149. {
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: CanSelectCardCondition1,
  153. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  154. canEndSelectCondition: CanEndSelectCondition,
  155. canNoSelect: () => true,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. message: "Select cards to place in Digivolution cards.",
  159. maxCount: maxCount,
  160. canEndNotMax: true,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Trash,
  164. customRootCardList: null,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  169. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  170. {
  171. List<string> cardIDs = new List<string>();
  172. foreach (CardSource cardSource1 in cardSources)
  173. {
  174. if (!cardIDs.Contains(cardSource1.CardID))
  175. {
  176. cardIDs.Add(cardSource1.CardID);
  177. }
  178. }
  179. foreach (CardSource cardSource1 in digivolutionCards)
  180. {
  181. if (!cardIDs.Contains(cardSource1.CardID))
  182. {
  183. cardIDs.Add(cardSource1.CardID);
  184. }
  185. }
  186. if (cardIDs.Contains(cardSource.CardID))
  187. {
  188. return false;
  189. }
  190. return true;
  191. }
  192. bool CanEndSelectCondition(List<CardSource> cardSources)
  193. {
  194. List<string> cardIDs = new List<string>();
  195. foreach (CardSource cardSource1 in cardSources)
  196. {
  197. if (!cardIDs.Contains(cardSource1.CardID))
  198. {
  199. cardIDs.Add(cardSource1.CardID);
  200. }
  201. }
  202. foreach (CardSource cardSource1 in digivolutionCards)
  203. {
  204. if (!cardIDs.Contains(cardSource1.CardID))
  205. {
  206. cardIDs.Add(cardSource1.CardID);
  207. }
  208. }
  209. if (cardIDs.Count != cardSources.Count + digivolutionCards.Count)
  210. {
  211. return false;
  212. }
  213. return true;
  214. }
  215. IEnumerator SelectCardCoroutine(CardSource cardSource)
  216. {
  217. selectedCards.Add(cardSource);
  218. digivolutionCards.Add(cardSource);
  219. yield return null;
  220. }
  221. if (selectedCards.Count >= 1)
  222. {
  223. foreach (CardSource selectedCard in selectedCards)
  224. {
  225. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(selectedCard));
  226. }
  227. }
  228. }
  229. }
  230. if (digivolutionCards.Count >= 1)
  231. {
  232. List<CardSource> digivolutionCards_fixed = new List<CardSource>();
  233. if (digivolutionCards.Count == 1)
  234. {
  235. foreach (CardSource cardSource in digivolutionCards)
  236. {
  237. digivolutionCards_fixed.Add(cardSource);
  238. }
  239. }
  240. else
  241. {
  242. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  243. selectCardEffect.SetUp(
  244. canTargetCondition: (cardSource) => true,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. canNoSelect: () => false,
  248. selectCardCoroutine: null,
  249. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  250. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  251. maxCount: digivolutionCards.Count,
  252. canEndNotMax: false,
  253. isShowOpponent: false,
  254. mode: SelectCardEffect.Mode.Custom,
  255. root: SelectCardEffect.Root.Custom,
  256. customRootCardList: digivolutionCards,
  257. canLookReverseCard: true,
  258. selectPlayer: card.Owner,
  259. cardEffect: activateClass);
  260. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  261. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  262. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  263. {
  264. foreach (CardSource cardSource in cardSources)
  265. {
  266. digivolutionCards_fixed.Add(cardSource);
  267. }
  268. yield return null;
  269. }
  270. }
  271. if (CardEffectCommons.IsExistOnBattleArea(card))
  272. {
  273. digivolutionCards_fixed.Reverse();
  274. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(digivolutionCards_fixed, activateClass));
  275. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(digivolutionCards_fixed.Count, activateClass));
  276. }
  277. }
  278. }
  279. }
  280. }
  281. if (timing == EffectTiming.None)
  282. {
  283. bool PermanentCondition(Permanent permanent)
  284. {
  285. return permanent == card.PermanentOfThisCard();
  286. }
  287. bool CanUseCondition()
  288. {
  289. return CardEffectCommons.IsExistOnBattleArea(card);
  290. }
  291. string effectName = "Can't have DP reduced";
  292. cardEffects.Add(CardEffectFactory.ImmuneFromDPMinusStaticEffect(
  293. permanentCondition: PermanentCondition,
  294. cardEffectCondition: null,
  295. isInheritedEffect: false,
  296. card: card,
  297. condition: CanUseCondition,
  298. effectName: effectName
  299. ));
  300. }
  301. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  302. {
  303. ActivateClass activateClass = new ActivateClass();
  304. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted", CanUseCondition, card);
  305. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  306. activateClass.SetHashString("Substitute_EX1_073");
  307. cardEffects.Add(activateClass);
  308. string EffectDiscription()
  309. {
  310. return "[All Turns]When this Digimon would be deleted, you may trash 2 level5 Digimon cards in this Digimon's digivolution cards to prevent this Digimon from being deleted.";
  311. }
  312. bool CanSelectCardCondition(CardSource cardSource)
  313. {
  314. if (cardSource.IsDigimon)
  315. {
  316. if (cardSource.Level == 5)
  317. {
  318. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  319. {
  320. if (cardSource.HasLevel)
  321. {
  322. return true;
  323. }
  324. }
  325. }
  326. }
  327. return false;
  328. }
  329. bool CanUseCondition(Hashtable hashtable)
  330. {
  331. if (CardEffectCommons.IsExistOnBattleArea(card))
  332. {
  333. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  334. {
  335. return true;
  336. }
  337. }
  338. return false;
  339. }
  340. bool CanActivateCondition(Hashtable hashtable)
  341. {
  342. if (CardEffectCommons.IsExistOnBattleArea(card))
  343. {
  344. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  345. {
  346. return true;
  347. }
  348. }
  349. return false;
  350. }
  351. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  352. {
  353. if (CardEffectCommons.IsExistOnBattleArea(card))
  354. {
  355. Permanent selectedPermanent = card.PermanentOfThisCard();
  356. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 2)
  357. {
  358. List<CardSource> selectedCards = new List<CardSource>();
  359. int maxCount = Math.Min(2, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  360. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  361. selectCardEffect.SetUp(
  362. canTargetCondition: CanSelectCardCondition,
  363. canTargetCondition_ByPreSelecetedList: null,
  364. canEndSelectCondition: null,
  365. canNoSelect: () => true,
  366. selectCardCoroutine: SelectCardCoroutine,
  367. afterSelectCardCoroutine: null,
  368. message: "Select cards to discard.",
  369. maxCount: maxCount,
  370. canEndNotMax: false,
  371. isShowOpponent: true,
  372. mode: SelectCardEffect.Mode.Custom,
  373. root: SelectCardEffect.Root.Custom,
  374. customRootCardList: selectedPermanent.DigivolutionCards,
  375. canLookReverseCard: true,
  376. selectPlayer: card.Owner,
  377. cardEffect: activateClass);
  378. selectCardEffect.SetNotShowCard();
  379. yield return StartCoroutine(selectCardEffect.Activate());
  380. IEnumerator SelectCardCoroutine(CardSource cardSource)
  381. {
  382. selectedCards.Add(cardSource);
  383. yield return null;
  384. }
  385. if (selectedCards.Count == 2)
  386. {
  387. selectedPermanent.willBeRemoveField = false;
  388. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  389. }
  390. }
  391. }
  392. }
  393. }
  394. return cardEffects;
  395. }
  396. }
  397. }