EX9_055.cs 24 KB

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