EX2_012.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_012 : 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.None)
  13. {
  14. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  15. changeCardNamesClass.SetUpICardEffect("Also treated as [ChaosGallantmon]", CanUseCondition, card);
  16. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  17. cardEffects.Add(changeCardNamesClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. return true;
  21. }
  22. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  23. {
  24. if (cardSource == card)
  25. {
  26. CardNames.Add("ChaosGallantmon");
  27. }
  28. return CardNames;
  29. }
  30. }
  31. if (timing == EffectTiming.OnEnterFieldAnyone)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Delete 1 Digimon with 10000 DP or less, or trash top 5 cards from deck", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] Delete 1 of your opponent's Digimon with 10000 DP or less. If no Digimon was deleted by this effect, trash the top 5 cards of both players' decks.";
  40. }
  41. bool CanSelectPermanentCondition(Permanent permanent)
  42. {
  43. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  44. {
  45. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(10000, activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. return true;
  63. }
  64. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.LibraryCards.Count >= 1) >= 1)
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectPermanentCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: maxCount,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: null,
  87. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  88. mode: SelectPermanentEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  93. {
  94. foreach (Permanent permanent in permanents)
  95. {
  96. deleteTargetPermanents.Add(permanent);
  97. }
  98. yield return null;
  99. }
  100. }
  101. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  102. IEnumerator FailureProcess()
  103. {
  104. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  105. {
  106. if (player.LibraryCards.Count >= 1)
  107. {
  108. IAddTrashCardsFromLibraryTop addTrashCard = new IAddTrashCardsFromLibraryTop(5, player, activateClass);
  109. addTrashCard.SetNotShowCards();
  110. yield return ContinuousController.instance.StartCoroutine(addTrashCard.AddTrashCardsFromLibraryTop());
  111. if (player.isYou)
  112. {
  113. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(addTrashCard.discardedCards, "Your Discarded Cards", true, true));
  114. }
  115. else
  116. {
  117. ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(addTrashCard.discardedCards, "Opponent's Discarded Cards", true, true));
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. if (timing == EffectTiming.OnDestroyedAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect("Play [Guilmon] and [Takato Matsuki] from hand or trash", CanUseCondition, card);
  128. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  129. cardEffects.Add(activateClass);
  130. string EffectDiscription()
  131. {
  132. return "[On Deletion] You may play 1 [Guilmon] and 1 [Takato Matsuki] from your hand and/or trash without paying their memory costs.";
  133. }
  134. bool CanSelectCardCondition(CardSource cardSource)
  135. {
  136. if (cardSource.CardNames.Contains("Guilmon"))
  137. {
  138. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanSelectCardCondition1(CardSource cardSource)
  146. {
  147. if (cardSource.CardNames.Contains("Takato Matsuki") || cardSource.CardNames.Contains("TakatoMatsuki"))
  148. {
  149. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  150. {
  151. return true;
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  159. }
  160. bool CanActivateCondition(Hashtable hashtable)
  161. {
  162. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  163. {
  164. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  165. {
  166. return true;
  167. }
  168. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  169. {
  170. return true;
  171. }
  172. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  173. {
  174. return true;
  175. }
  176. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  177. {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. {
  187. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  188. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  189. if (canSelectHand || canSelectTrash)
  190. {
  191. if (canSelectHand && canSelectTrash)
  192. {
  193. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  194. {
  195. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  196. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  197. };
  198. string selectPlayerMessage = "From which area do you play 1 [Guilmon]?";
  199. string notSelectPlayerMessage = "The opponent is choosing from which area to play 1 [Guilmon].";
  200. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  201. }
  202. else
  203. {
  204. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  205. }
  206. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  207. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  208. IEnumerator SelectCardCoroutine(CardSource cardSource)
  209. {
  210. selectedCards.Add(cardSource);
  211. yield return null;
  212. }
  213. if (fromHand)
  214. {
  215. int maxCount = 1;
  216. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  217. selectHandEffect.SetUp(
  218. selectPlayer: card.Owner,
  219. canTargetCondition: CanSelectCardCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. maxCount: maxCount,
  223. canNoSelect: true,
  224. canEndNotMax: false,
  225. isShowOpponent: true,
  226. selectCardCoroutine: SelectCardCoroutine,
  227. afterSelectCardCoroutine: null,
  228. mode: SelectHandEffect.Mode.Custom,
  229. cardEffect: activateClass);
  230. selectHandEffect.SetUpCustomMessage("Select 1 [Guilmon] to play.", "The opponent is selecting 1 [Guilmon] to play.");
  231. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  232. yield return StartCoroutine(selectHandEffect.Activate());
  233. }
  234. else
  235. {
  236. int maxCount = 1;
  237. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  238. selectCardEffect.SetUp(
  239. canTargetCondition: CanSelectCardCondition,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. canNoSelect: () => true,
  243. selectCardCoroutine: SelectCardCoroutine,
  244. afterSelectCardCoroutine: null,
  245. message: "Select 1 [Guilmon] to play.",
  246. maxCount: maxCount,
  247. canEndNotMax: false,
  248. isShowOpponent: true,
  249. mode: SelectCardEffect.Mode.Custom,
  250. root: SelectCardEffect.Root.Trash,
  251. customRootCardList: null,
  252. canLookReverseCard: true,
  253. selectPlayer: card.Owner,
  254. cardEffect: activateClass);
  255. selectCardEffect.SetUpCustomMessage("Select 1 [Guilmon] to play.", "The opponent is selecting 1 [Guilmon] to play.");
  256. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  257. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  258. }
  259. }
  260. }
  261. {
  262. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1;
  263. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1);
  264. if (canSelectHand || canSelectTrash)
  265. {
  266. if (canSelectHand && canSelectTrash)
  267. {
  268. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  269. {
  270. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  271. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  272. };
  273. string selectPlayerMessage = "From which area do you play 1 [Takato Matsuki]?";
  274. string notSelectPlayerMessage = "The opponent is choosing from which area to play 1 [Takato Matsuki].";
  275. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  276. }
  277. else
  278. {
  279. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  280. }
  281. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  282. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  283. IEnumerator SelectCardCoroutine(CardSource cardSource)
  284. {
  285. selectedCards.Add(cardSource);
  286. yield return null;
  287. }
  288. if (fromHand)
  289. {
  290. int maxCount = 1;
  291. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  292. selectHandEffect.SetUp(
  293. selectPlayer: card.Owner,
  294. canTargetCondition: CanSelectCardCondition1,
  295. canTargetCondition_ByPreSelecetedList: null,
  296. canEndSelectCondition: null,
  297. maxCount: maxCount,
  298. canNoSelect: true,
  299. canEndNotMax: false,
  300. isShowOpponent: true,
  301. selectCardCoroutine: SelectCardCoroutine,
  302. afterSelectCardCoroutine: null,
  303. mode: SelectHandEffect.Mode.Custom,
  304. cardEffect: activateClass);
  305. selectHandEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
  306. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  307. yield return StartCoroutine(selectHandEffect.Activate());
  308. }
  309. else
  310. {
  311. int maxCount = 1;
  312. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  313. selectCardEffect.SetUp(
  314. canTargetCondition: CanSelectCardCondition1,
  315. canTargetCondition_ByPreSelecetedList: null,
  316. canEndSelectCondition: null,
  317. canNoSelect: () => true,
  318. selectCardCoroutine: SelectCardCoroutine,
  319. afterSelectCardCoroutine: null,
  320. message: "Select 1 [Takato Matsuki] to play.",
  321. maxCount: maxCount,
  322. canEndNotMax: false,
  323. isShowOpponent: true,
  324. mode: SelectCardEffect.Mode.Custom,
  325. root: SelectCardEffect.Root.Trash,
  326. customRootCardList: null,
  327. canLookReverseCard: true,
  328. selectPlayer: card.Owner,
  329. cardEffect: activateClass);
  330. selectCardEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
  331. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  332. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  333. }
  334. }
  335. }
  336. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  337. if (selectedCards.Some(CardSource => CardEffectCommons.IsExistOnTrash(CardSource)))
  338. {
  339. root = SelectCardEffect.Root.Trash;
  340. }
  341. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  342. cardSources: selectedCards,
  343. activateClass: activateClass,
  344. payCost: false,
  345. isTapped: false,
  346. root: root,
  347. activateETB: true));
  348. }
  349. }
  350. return cardEffects;
  351. }
  352. }
  353. }