EX9_055.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Abbadomon
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_055 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Assembly
  13. if (timing == EffectTiming.None)
  14. {
  15. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  16. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  17. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  18. addAssemblyConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addAssemblyConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. AssemblyCondition GetAssembly(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition, "4 [Negamon]");
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. if (cardSource != null)
  32. {
  33. if (cardSource.Owner == card.Owner)
  34. {
  35. if (cardSource.IsDigimon)
  36. {
  37. if (cardSource.ContainsCardName("Negamon"))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. List<AssemblyConditionElement> elements = new List<AssemblyConditionElement>();
  47. for (int i = 0; i < 4; i++)
  48. {
  49. elements.Add(element);
  50. }
  51. AssemblyCondition assemblyCondition = new AssemblyCondition(elements, null, 3);
  52. return assemblyCondition;
  53. }
  54. return null;
  55. }
  56. }
  57. #endregion
  58. #region On Play
  59. if (timing == EffectTiming.OnEnterFieldAnyone)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("Play 1 [Abbadomon Core]", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  64. cardEffects.Add(activateClass);
  65. string EffectDiscription()
  66. {
  67. return "[On Play] If there are 4 or more total [Negamon] in your trash and your Digimon's digivolution cards, you may play 1 [Abbadomon Core] from your hand or trash to your empty breeding area without paying the cost.";
  68. }
  69. int NegamonAmount()
  70. {
  71. int value = 0;
  72. value += CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsNegamon);
  73. foreach (Permanent perm in card.Owner.GetBattleAreaDigimons())
  74. {
  75. value += perm.DigivolutionCards.Count(IsNegamon);
  76. }
  77. return value;
  78. }
  79. bool IsNegamon(CardSource source)
  80. {
  81. return source.EqualsCardName("Negamon");
  82. }
  83. bool CanSelectCardCondition(CardSource cardSource)
  84. {
  85. if (cardSource.EqualsCardName("Abbadomon Core"))
  86. {
  87. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Hand, isBreedingArea: true))
  88. {
  89. return true;
  90. }
  91. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Trash, isBreedingArea: true))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  101. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  102. }
  103. bool CanActivateCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  106. NegamonAmount() >= 4;
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable hashtable)
  109. {
  110. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  111. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  112. if (canSelectHand || canSelectTrash)
  113. {
  114. if (canSelectHand && canSelectTrash)
  115. {
  116. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  117. {
  118. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  119. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  120. };
  121. string selectPlayerMessage = "From which area do you play a card?";
  122. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  123. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  124. }
  125. else
  126. {
  127. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  128. }
  129. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  130. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  131. List<CardSource> selectedCards = new List<CardSource>();
  132. IEnumerator SelectCardCoroutine(CardSource cardSource)
  133. {
  134. selectedCards.Add(cardSource);
  135. yield return null;
  136. }
  137. if (fromHand)
  138. {
  139. int maxCount = 1;
  140. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  141. selectHandEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: CanSelectCardCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: maxCount,
  147. canNoSelect: true,
  148. canEndNotMax: false,
  149. isShowOpponent: true,
  150. selectCardCoroutine: SelectCardCoroutine,
  151. afterSelectCardCoroutine: null,
  152. mode: SelectHandEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  155. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  156. yield return StartCoroutine(selectHandEffect.Activate());
  157. }
  158. else
  159. {
  160. int maxCount = 1;
  161. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  162. selectCardEffect.SetUp(
  163. canTargetCondition: CanSelectCardCondition,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. canNoSelect: () => true,
  167. selectCardCoroutine: SelectCardCoroutine,
  168. afterSelectCardCoroutine: null,
  169. message: "Select 1 card to play.",
  170. maxCount: maxCount,
  171. canEndNotMax: false,
  172. isShowOpponent: true,
  173. mode: SelectCardEffect.Mode.Custom,
  174. root: SelectCardEffect.Root.Trash,
  175. customRootCardList: null,
  176. canLookReverseCard: true,
  177. selectPlayer: card.Owner,
  178. cardEffect: activateClass);
  179. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  180. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  181. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  182. }
  183. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  184. if (!fromHand)
  185. {
  186. root = SelectCardEffect.Root.Trash;
  187. }
  188. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true, isBreedingArea: true));
  189. }
  190. }
  191. }
  192. #endregion
  193. #region When Digivolving
  194. if (timing == EffectTiming.OnEnterFieldAnyone)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("Play 1 [Abbadomon Core]", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return "[When Digivolving] If there are 4 or more total [Negamon] in your trash and your Digimon's digivolution cards, you may play 1 [Abbadomon Core] from your hand or trash to your empty breeding area without paying the cost.";
  203. }
  204. int NegamonAmount()
  205. {
  206. int value = 0;
  207. value += CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsNegamon);
  208. foreach (Permanent perm in card.Owner.GetBattleAreaDigimons())
  209. {
  210. value += perm.DigivolutionCards.Count(IsNegamon);
  211. }
  212. return value;
  213. }
  214. bool IsNegamon(CardSource source)
  215. {
  216. return source.EqualsCardName("Negamon");
  217. }
  218. bool CanSelectCardCondition(CardSource cardSource)
  219. {
  220. if (cardSource.EqualsCardName("Abbadomon Core"))
  221. {
  222. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Hand, isBreedingArea: true))
  223. {
  224. return true;
  225. }
  226. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Trash, isBreedingArea: true))
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  236. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  237. }
  238. bool CanActivateCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  241. NegamonAmount() >= 4;
  242. }
  243. IEnumerator ActivateCoroutine(Hashtable hashtable)
  244. {
  245. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  246. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  247. if (canSelectHand || canSelectTrash)
  248. {
  249. if (canSelectHand && canSelectTrash)
  250. {
  251. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  252. {
  253. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  254. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  255. };
  256. string selectPlayerMessage = "From which area do you play a card?";
  257. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  258. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  259. }
  260. else
  261. {
  262. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  263. }
  264. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  265. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  266. List<CardSource> selectedCards = new List<CardSource>();
  267. IEnumerator SelectCardCoroutine(CardSource cardSource)
  268. {
  269. selectedCards.Add(cardSource);
  270. yield return null;
  271. }
  272. if (fromHand)
  273. {
  274. int maxCount = 1;
  275. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  276. selectHandEffect.SetUp(
  277. selectPlayer: card.Owner,
  278. canTargetCondition: CanSelectCardCondition,
  279. canTargetCondition_ByPreSelecetedList: null,
  280. canEndSelectCondition: null,
  281. maxCount: maxCount,
  282. canNoSelect: true,
  283. canEndNotMax: false,
  284. isShowOpponent: true,
  285. selectCardCoroutine: SelectCardCoroutine,
  286. afterSelectCardCoroutine: null,
  287. mode: SelectHandEffect.Mode.Custom,
  288. cardEffect: activateClass);
  289. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  290. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  291. yield return StartCoroutine(selectHandEffect.Activate());
  292. }
  293. else
  294. {
  295. int maxCount = 1;
  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 card to play.",
  305. maxCount: maxCount,
  306. canEndNotMax: false,
  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 card to play.", "The opponent is selecting 1 card to play.");
  315. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  316. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  317. }
  318. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  319. if (!fromHand)
  320. {
  321. root = SelectCardEffect.Root.Trash;
  322. }
  323. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true, isBreedingArea: true));
  324. }
  325. }
  326. }
  327. #endregion
  328. #region End of All Turns
  329. if (timing == EffectTiming.OnEndTurn)
  330. {
  331. ActivateClass activateClass = new ActivateClass();
  332. activateClass.SetUpICardEffect("By placing 1 digimon as top source, delete opponents digimon of same level", CanUseCondition, card);
  333. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  334. activateClass.SetHashString("EOT_EX9-055");
  335. cardEffects.Add(activateClass);
  336. string EffectDiscription()
  337. {
  338. return "[End of All Turns] [Once Per Turn] By placing 1 level 6 or lower Digimon card with [Negamon] in its text from your trash as this Digimon's top digivolution card, delete 1 of your opponent's Digimon with the same level as the placed card.";
  339. }
  340. bool CanSelectTuckedTarget(CardSource source)
  341. {
  342. return source.IsDigimon &&
  343. source.HasLevel && source.Level <= 6 &&
  344. source.HasText("Negamon");
  345. }
  346. bool CanUseCondition(Hashtable hashtable)
  347. {
  348. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  349. }
  350. bool CanActivateCondition(Hashtable hashtable)
  351. {
  352. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  353. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTuckedTarget);
  354. }
  355. IEnumerator ActivateCoroutine(Hashtable hashtable)
  356. {
  357. bool placed = false;
  358. List<CardSource> selectedCards = new List<CardSource>();
  359. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  360. selectHandEffect.SetUp(
  361. selectPlayer: card.Owner,
  362. canTargetCondition: CanSelectTuckedTarget,
  363. canTargetCondition_ByPreSelecetedList: null,
  364. canEndSelectCondition: null,
  365. maxCount: 1,
  366. canNoSelect: true,
  367. canEndNotMax: false,
  368. isShowOpponent: true,
  369. selectCardCoroutine: SelectCardCoroutine,
  370. afterSelectCardCoroutine: null,
  371. mode: SelectHandEffect.Mode.Custom,
  372. cardEffect: activateClass);
  373. selectHandEffect.SetUpCustomMessage("Select 1 card to place in Digivolution cards.", "The opponent is selecting 1 card to place in Digivolution cards.");
  374. selectHandEffect.SetNotShowCard();
  375. yield return StartCoroutine(selectHandEffect.Activate());
  376. IEnumerator SelectCardCoroutine(CardSource cardSource)
  377. {
  378. selectedCards.Add(cardSource);
  379. yield return null;
  380. }
  381. if (selectedCards.Count >= 1)
  382. {
  383. if (!card.PermanentOfThisCard().IsToken)
  384. {
  385. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(selectedCards, activateClass));
  386. placed = true;
  387. }
  388. }
  389. if (placed)
  390. {
  391. bool CanSelectOpponentsDigimon(Permanent permanent)
  392. {
  393. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  394. permanent.TopCard.HasLevel && permanent.TopCard.Level <= selectedCards[0].Level;
  395. }
  396. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimon))
  397. {
  398. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  399. selectPermanentEffect.SetUp(
  400. selectPlayer: card.Owner,
  401. canTargetCondition: CanSelectOpponentsDigimon,
  402. canTargetCondition_ByPreSelecetedList: null,
  403. canEndSelectCondition: null,
  404. maxCount: 1,
  405. canNoSelect: false,
  406. canEndNotMax: false,
  407. selectPermanentCoroutine: null,
  408. afterSelectPermanentCoroutine: null,
  409. mode: SelectPermanentEffect.Mode.Destroy,
  410. cardEffect: activateClass);
  411. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  412. }
  413. }
  414. }
  415. }
  416. #endregion
  417. return cardEffects;
  418. }
  419. }
  420. }