EX10_058.cs 18 KB

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