EX10_058.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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 this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  102. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  103. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  104. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  105. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  108. }
  109. string EffectDiscription1()
  110. {
  111. return "[End of Your Turn] Delete this Digimon.";
  112. }
  113. bool CanUseCondition1(Hashtable hashtable1)
  114. {
  115. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  116. {
  117. if (selectedPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  118. {
  119. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  120. {
  121. return true;
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanActivateCondition1(Hashtable hashtable1)
  128. {
  129. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  130. {
  131. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  132. {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  139. {
  140. bool CanSelectPermanentCondition(Permanent permanent)
  141. {
  142. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, selectedPermanent.TopCard);
  143. }
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  145. {
  146. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  147. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: selectedPermanent.TopCard.Owner,
  150. canTargetCondition: CanSelectPermanentCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: maxCount,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: null,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Destroy,
  159. cardEffect: activateClass);
  160. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  161. }
  162. }
  163. ICardEffect GetCardEffect(EffectTiming _timing)
  164. {
  165. if (_timing == EffectTiming.OnEndTurn)
  166. {
  167. return activateClass1;
  168. }
  169. return null;
  170. }
  171. }
  172. #endregion
  173. }
  174. }
  175. #endregion
  176. #region On Play
  177. if (timing == EffectTiming.OnEnterFieldAnyone)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect("1 Digimon gains \"[End of Turn] Delete 1 of your Digimon\"", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDiscription("On Play"));
  182. cardEffects.Add(activateClass);
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  186. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  187. }
  188. }
  189. #endregion
  190. #region When Digivolving
  191. if (timing == EffectTiming.OnEnterFieldAnyone)
  192. {
  193. ActivateClass activateClass = new ActivateClass();
  194. activateClass.SetUpICardEffect("1 Digimon gains \"[End of Turn] Delete 1 of your Digimon\"", CanUseCondition, card);
  195. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDiscription("On Play"));
  196. cardEffects.Add(activateClass);
  197. bool CanUseCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  200. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  201. }
  202. }
  203. #endregion
  204. #region All Turns - OPT
  205. if (timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnDestroyedAnyone)
  206. {
  207. ActivateClass activateClass = new ActivateClass();
  208. activateClass.SetUpICardEffect("by trashing any 2 sources, Play a level 4 from trash", CanUseCondition, card);
  209. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  210. activateClass.SetHashString("AT_EX10_058");
  211. cardEffects.Add(activateClass);
  212. string EffectDiscription()
  213. {
  214. 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.";
  215. }
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  219. {
  220. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  221. {
  222. if (timing == EffectTiming.OnEnterFieldAnyone)
  223. {
  224. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, OpponentsDigimon);
  225. }
  226. if (timing == EffectTiming.OnDestroyedAnyone)
  227. return CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, OpponentsDigimon);
  228. }
  229. }
  230. return false;
  231. }
  232. bool CanActivateCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  235. }
  236. bool OpponentsDigimon(Permanent permanent)
  237. {
  238. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  239. }
  240. bool CanSelectTrashCard(CardSource source)
  241. {
  242. return source.IsDigimon &&
  243. source.CardColors.Contains(CardColor.Purple) &&
  244. source.HasLevel && source.Level <= 4 &&
  245. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash);
  246. }
  247. IEnumerator ActivateCoroutine(Hashtable hashtable)
  248. {
  249. Permanent thisPermanent = card.PermanentOfThisCard();
  250. List<CardSource> selectedCards = new List<CardSource>();
  251. #region Trash Digivolution Cards
  252. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  253. selectCardEffect.SetUp(
  254. canTargetCondition: _ => true,
  255. canTargetCondition_ByPreSelecetedList: null,
  256. canEndSelectCondition: null,
  257. canNoSelect: () => false,
  258. selectCardCoroutine: SelectCardCoroutine,
  259. afterSelectCardCoroutine: null,
  260. message: "Select 2 digivolution cards to trash.",
  261. maxCount: 2,
  262. canEndNotMax: false,
  263. isShowOpponent: true,
  264. mode: SelectCardEffect.Mode.Custom,
  265. root: SelectCardEffect.Root.Custom,
  266. customRootCardList: thisPermanent.DigivolutionCards,
  267. canLookReverseCard: false,
  268. selectPlayer: card.Owner,
  269. cardEffect: activateClass);
  270. IEnumerator SelectCardCoroutine(CardSource cardSource)
  271. {
  272. selectedCards.Add(cardSource);
  273. yield return null;
  274. }
  275. selectCardEffect.SetUseFaceDown();
  276. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  277. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  278. #endregion
  279. if (selectedCards.Count == 2)
  280. {
  281. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  282. targetPermanent: thisPermanent,
  283. targetDigivolutionCards: selectedCards,
  284. activateClass: activateClass,
  285. successProcess: SuccessProcess,
  286. failureProcess: null));
  287. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  288. {
  289. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectTrashCard(cardSource)))
  290. {
  291. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectTrashCard(cardSource)));
  292. List<CardSource> selectedCards = new List<CardSource>();
  293. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  294. selectCardEffect.SetUp(
  295. canTargetCondition: CanSelectTrashCard,
  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 StartCoroutine(selectCardEffect.Activate());
  314. IEnumerator SelectCardCoroutine(CardSource cardSource)
  315. {
  316. selectedCards.Add(cardSource);
  317. yield return null;
  318. }
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  320. }
  321. }
  322. }
  323. }
  324. }
  325. #endregion
  326. return cardEffects;
  327. }
  328. }
  329. }