EX10_058.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. //Lilithmon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_058 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digixros
  14. if (timing == EffectTiming.None)
  15. {
  16. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  17. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  18. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  19. addDigiXrosConditionClass.SetNotShowUI(true);
  20. cardEffects.Add(addDigiXrosConditionClass);
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return true;
  24. }
  25. DigiXrosCondition GetDigiXros(CardSource cardSource)
  26. {
  27. if (cardSource == card)
  28. {
  29. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Bagra Army] trait");
  30. bool CanSelectCardCondition(CardSource cardSource)
  31. {
  32. if (cardSource != null)
  33. {
  34. if (cardSource.Owner == card.Owner)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (cardSource.HasBagraArmyTraits)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element };
  48. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  49. return digiXrosCondition;
  50. }
  51. return null;
  52. }
  53. }
  54. #endregion
  55. #region Shared On Play/When Digivolving
  56. string SharedEffectDiscription(string tag)
  57. {
  58. return $"[{tag}] Until your opponent's turn ends, give 1 of their Digimon or Tamers \"[End of Your Turn] Delete 1 of your Digimon.\"";
  59. }
  60. bool SharedCanActivateCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  63. }
  64. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  65. {
  66. bool PermanentCondition(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  69. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card);
  70. }
  71. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  72. {
  73. Permanent selectedPermanent = null;
  74. #region Select Permanent
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: PermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. selectedPermanent = permanent;
  92. yield return null;
  93. }
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon/Tamer to gain effect", "The opponent is selecting 1 Digimon/Tamer to gain effect");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. #endregion
  97. #region Gain Effect
  98. if (selectedPermanent != null)
  99. {
  100. ActivateClass activateClass1 = new ActivateClass();
  101. activateClass1.SetUpICardEffect("Delete 1 of your Digimon", CanUseCondition1, selectedPermanent.TopCard);
  102. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  103. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  104. activateClass1.SetEffectSourceCard(selectedPermanent.TopCard);
  105. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  106. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  109. }
  110. string EffectDiscription1()
  111. {
  112. return "[End of Your Turn] Delete 1 of your Digimon.";
  113. }
  114. bool CanUseCondition1(Hashtable hashtable1)
  115. {
  116. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  117. {
  118. if (selectedPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  119. {
  120. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  121. {
  122. return true;
  123. }
  124. }
  125. }
  126. return false;
  127. }
  128. bool CanActivateCondition1(Hashtable hashtable1)
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  131. {
  132. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  140. {
  141. bool CanSelectPermanentCondition(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, selectedPermanent.TopCard);
  144. }
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  146. {
  147. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  148. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: selectedPermanent.TopCard.Owner,
  151. canTargetCondition: CanSelectPermanentCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: false,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: null,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Destroy,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. }
  163. }
  164. ICardEffect GetCardEffect(EffectTiming _timing)
  165. {
  166. if (_timing == EffectTiming.OnEndTurn)
  167. {
  168. return activateClass1;
  169. }
  170. return null;
  171. }
  172. }
  173. #endregion
  174. }
  175. }
  176. #endregion
  177. #region On Play
  178. if (timing == EffectTiming.OnEnterFieldAnyone)
  179. {
  180. ActivateClass activateClass = new ActivateClass();
  181. activateClass.SetUpICardEffect("1 Digimon gains \"[End of Turn] Delete 1 of your Digimon\"", CanUseCondition, card);
  182. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDiscription("On Play"));
  183. cardEffects.Add(activateClass);
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  187. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  188. }
  189. }
  190. #endregion
  191. #region When Digivolving
  192. if (timing == EffectTiming.OnEnterFieldAnyone)
  193. {
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect("1 Digimon gains \"[End of Turn] Delete 1 of your Digimon\"", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDiscription("On Play"));
  197. cardEffects.Add(activateClass);
  198. bool CanUseCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  201. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  202. }
  203. }
  204. #endregion
  205. #region All Turns - OPT
  206. if (timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnDestroyedAnyone)
  207. {
  208. ActivateClass activateClass = new ActivateClass();
  209. activateClass.SetUpICardEffect("by trashing any 2 sources, Play a level 4 from trash", CanUseCondition, card);
  210. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  211. activateClass.SetHashString("AT_EX10_058");
  212. cardEffects.Add(activateClass);
  213. string EffectDiscription()
  214. {
  215. return "[All Turns] [Once Per Turn] When any of your opponent's Digimon are played or deleted, by trashing any 2 of this Digimon's digivolution cards, you may play 1 level 4 or lower purple Digimon card from your trash without paying the cost.";
  216. }
  217. bool CanUseCondition(Hashtable hashtable)
  218. {
  219. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  220. {
  221. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  222. {
  223. if (timing == EffectTiming.OnEnterFieldAnyone)
  224. {
  225. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, OpponentsDigimon);
  226. }
  227. if (timing == EffectTiming.OnDestroyedAnyone)
  228. return CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, OpponentsDigimon);
  229. }
  230. }
  231. return false;
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  236. }
  237. bool OpponentsDigimon(Permanent permanent)
  238. {
  239. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  240. }
  241. bool CanSelectTrashCard(CardSource source)
  242. {
  243. return source.IsDigimon &&
  244. source.CardColors.Contains(CardColor.Purple) &&
  245. source.HasLevel && source.Level <= 4 &&
  246. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash);
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable hashtable)
  249. {
  250. Permanent thisPermanent = card.PermanentOfThisCard();
  251. List<CardSource> selectedCards = new List<CardSource>();
  252. #region Trash Digivolution Cards
  253. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  254. selectCardEffect.SetUp(
  255. canTargetCondition: _ => true,
  256. canTargetCondition_ByPreSelecetedList: null,
  257. canEndSelectCondition: null,
  258. canNoSelect: () => false,
  259. selectCardCoroutine: SelectCardCoroutine,
  260. afterSelectCardCoroutine: null,
  261. message: "Select 2 digivolution cards to trash.",
  262. maxCount: 2,
  263. canEndNotMax: false,
  264. isShowOpponent: true,
  265. mode: SelectCardEffect.Mode.Custom,
  266. root: SelectCardEffect.Root.Custom,
  267. customRootCardList: thisPermanent.DigivolutionCards,
  268. canLookReverseCard: false,
  269. selectPlayer: card.Owner,
  270. cardEffect: activateClass);
  271. IEnumerator SelectCardCoroutine(CardSource cardSource)
  272. {
  273. selectedCards.Add(cardSource);
  274. yield return null;
  275. }
  276. selectCardEffect.SetUseFaceDown();
  277. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  278. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  279. #endregion
  280. if (selectedCards.Count == 2)
  281. {
  282. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  283. targetPermanent: thisPermanent,
  284. targetDigivolutionCards: selectedCards,
  285. activateClass: activateClass,
  286. successProcess: SuccessProcess,
  287. failureProcess: null));
  288. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  289. {
  290. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectTrashCard(cardSource)))
  291. {
  292. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectTrashCard(cardSource)));
  293. List<CardSource> selectedCards = new List<CardSource>();
  294. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  295. selectCardEffect.SetUp(
  296. canTargetCondition: CanSelectTrashCard,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. canNoSelect: () => true,
  300. selectCardCoroutine: SelectCardCoroutine,
  301. afterSelectCardCoroutine: null,
  302. message: "Select 1 card to play.",
  303. maxCount: maxCount,
  304. canEndNotMax: false,
  305. isShowOpponent: true,
  306. mode: SelectCardEffect.Mode.Custom,
  307. root: SelectCardEffect.Root.Trash,
  308. customRootCardList: null,
  309. canLookReverseCard: true,
  310. selectPlayer: card.Owner,
  311. cardEffect: activateClass);
  312. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  313. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  314. yield return StartCoroutine(selectCardEffect.Activate());
  315. IEnumerator SelectCardCoroutine(CardSource cardSource)
  316. {
  317. selectedCards.Add(cardSource);
  318. yield return null;
  319. }
  320. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  321. }
  322. }
  323. }
  324. }
  325. }
  326. #endregion
  327. return cardEffects;
  328. }
  329. }
  330. }