EX6_069.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_069 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place 1 Digimon with [Seven Great Demon Lords] trait as bottom digivolution source in breeding area.", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] You may place 1 Digimon card with the [Seven Great Demon Lords] trait from your hand or trash as the bottom digivolution card of the [Gate of Deadly Sins] in your breeding area. Then, place this card in the battle area.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  26. {
  27. if (!permanent.IsToken)
  28. {
  29. if (permanent.TopCard.CardNames.Contains("Gate of Deadly Sins"))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool HasSevenGreatDemonLordTrait(CardSource cardSource)
  38. {
  39. if (cardSource.IsDigimon)
  40. return cardSource.ContainsTraits("Seven Great Demon Lords");
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. if (card.Owner.GetBreedingAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  50. {
  51. bool validCardInTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasSevenGreatDemonLordTrait);
  52. bool validCardInHand = card.Owner.HandCards.Count(HasSevenGreatDemonLordTrait) > 0;
  53. bool useTrash = false;
  54. if (validCardInTrash || validCardInHand)
  55. {
  56. #region Selecting Hand or Trash
  57. if (validCardInTrash && validCardInHand)
  58. {
  59. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  60. {
  61. new SelectionElement<int>(message: $"Trash", value : 0, spriteIndex: 0),
  62. new SelectionElement<int>(message: $"Hand", value : 1, spriteIndex: 0),
  63. new SelectionElement<int>(message: $"No Selection", value : 2, spriteIndex: 1),
  64. };
  65. string selectPlayerMessage = "Will you use a card from hand or trash?";
  66. string notSelectPlayerMessage = "The opponent is choosing whether use a card from hand or trash.";
  67. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  68. }
  69. else if(validCardInTrash && !validCardInHand)
  70. {
  71. GManager.instance.userSelectionManager.SetInt(0);
  72. }
  73. else if (!validCardInTrash && validCardInHand)
  74. {
  75. GManager.instance.userSelectionManager.SetInt(1);
  76. }
  77. else
  78. {
  79. GManager.instance.userSelectionManager.SetInt(2);
  80. }
  81. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  82. useTrash = (GManager.instance.userSelectionManager.SelectedIntValue == 0);
  83. #endregion
  84. if(GManager.instance.userSelectionManager.SelectedIntValue != 2)
  85. {
  86. #region Card Selection
  87. CardSource selectedCard = null;
  88. IEnumerator SelectCardCoroutine(CardSource cardSource)
  89. {
  90. selectedCard = cardSource;
  91. yield return null;
  92. }
  93. if (!useTrash)
  94. {
  95. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  96. selectHandEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: HasSevenGreatDemonLordTrait,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: 1,
  102. canNoSelect: true,
  103. canEndNotMax: false,
  104. isShowOpponent: true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. mode: SelectHandEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. selectHandEffect.SetUpCustomMessage(
  110. "Select 1 card to place at the bottom of digivolution cards.",
  111. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  112. selectHandEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  113. yield return StartCoroutine(selectHandEffect.Activate());
  114. }
  115. else
  116. {
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: HasSevenGreatDemonLordTrait,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. message: "Select 1 card to play.",
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Trash,
  131. customRootCardList: null,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. selectCardEffect.SetUpCustomMessage(
  136. "Select 1 card to place at the bottom of digivolution cards.",
  137. "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  138. selectCardEffect.SetUpCustomMessage_ShowCard("Place bottom digivolution card");
  139. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  140. }
  141. #endregion
  142. #region Place As Source
  143. if (selectedCard != null)
  144. {
  145. if (card.Owner.GetBreedingAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  146. {
  147. Permanent selectedPermanent = card.Owner.GetBreedingAreaPermanents()[0];
  148. if (CanSelectPermanentCondition(selectedPermanent))
  149. {
  150. if (selectedPermanent != null)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  153. new List<CardSource>() { selectedCard },
  154. activateClass));
  155. }
  156. }
  157. }
  158. }
  159. #endregion
  160. }
  161. }
  162. }
  163. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  164. }
  165. }
  166. #endregion
  167. #region All Turns - Delay
  168. if (timing == EffectTiming.OnDestroyedAnyone)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Play 1 Digimon from breeding area", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[All Turns] When one of your [Seven Great Demon Lords] trait Digimon is deleted, <Delay>. \r\n • You may play 1 [Seven Great Demon Lords] trait Digimon from the digivolution cards of your [Gate of Deadly Sins] in the breeding area without paying the cost.";
  177. }
  178. bool CanSelectPermanentCondition(Permanent permanent)
  179. {
  180. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  181. {
  182. if (permanent.IsDigimon)
  183. {
  184. if(permanent.TopCard.ContainsCardName("Gate of Deadly Sins"))
  185. {
  186. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  187. {
  188. return true;
  189. }
  190. }
  191. }
  192. }
  193. return false;
  194. }
  195. bool PermanentCondition(Permanent permanent)
  196. {
  197. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  198. {
  199. return HasSevenGreatDemonLordTrait(permanent.TopCard);
  200. }
  201. return false;
  202. }
  203. bool HasSevenGreatDemonLordTrait(CardSource cardSource)
  204. {
  205. if (cardSource.IsDigimon)
  206. return cardSource.ContainsTraits("Seven Great Demon Lords");
  207. return false;
  208. }
  209. bool CanSelectCardCondition(CardSource cardSource)
  210. {
  211. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  212. {
  213. return HasSevenGreatDemonLordTrait(cardSource);
  214. }
  215. return false;
  216. }
  217. bool CanUseCondition(Hashtable hashtable)
  218. {
  219. if (CardEffectCommons.IsExistOnBattleArea(card))
  220. {
  221. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  222. {
  223. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  224. {
  225. return true;
  226. }
  227. }
  228. }
  229. return false;
  230. }
  231. bool CanActivateCondition(Hashtable hashtable)
  232. {
  233. if (CardEffectCommons.IsExistOnBattleArea(card))
  234. {
  235. if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
  236. {
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  243. {
  244. bool deleted = false;
  245. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  246. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  247. activateClass: activateClass,
  248. successProcess: permanents => SuccessProcess(),
  249. failureProcess: null));
  250. IEnumerator SuccessProcess()
  251. {
  252. deleted = true;
  253. yield return null;
  254. }
  255. if (deleted)
  256. {
  257. if (card.Owner.GetBreedingAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  258. {
  259. Permanent selectedPermanent = card.Owner.GetBreedingAreaPermanents()[0];
  260. if (CanSelectPermanentCondition(selectedPermanent))
  261. {
  262. if (selectedPermanent != null)
  263. {
  264. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  265. {
  266. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  267. List<CardSource> selectedCards = new List<CardSource>();
  268. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  269. selectCardEffect.SetUp(
  270. canTargetCondition: CanSelectCardCondition,
  271. canTargetCondition_ByPreSelecetedList: null,
  272. canEndSelectCondition: null,
  273. canNoSelect: () => false,
  274. selectCardCoroutine: SelectCardCoroutine,
  275. afterSelectCardCoroutine: null,
  276. message: "Select 1 digivolution card to play.",
  277. maxCount: maxCount,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. mode: SelectCardEffect.Mode.Custom,
  281. root: SelectCardEffect.Root.Custom,
  282. customRootCardList: selectedPermanent.DigivolutionCards,
  283. canLookReverseCard: true,
  284. selectPlayer: card.Owner,
  285. cardEffect: activateClass);
  286. selectCardEffect.SetUpCustomMessage(
  287. "Select 1 digivolution card to play.",
  288. "The opponent is selecting 1 digivolution card to play.");
  289. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  290. yield return StartCoroutine(selectCardEffect.Activate());
  291. IEnumerator SelectCardCoroutine(CardSource cardSource)
  292. {
  293. selectedCards.Add(cardSource);
  294. yield return null;
  295. }
  296. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  297. cardSources: selectedCards,
  298. activateClass: activateClass,
  299. payCost: false,
  300. isTapped: false,
  301. root: SelectCardEffect.Root.DigivolutionCards,
  302. activateETB: true));
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. #endregion
  311. #region Security
  312. if (timing == EffectTiming.SecuritySkill)
  313. {
  314. cardEffects.Add(CardEffectFactory.PlaceSelfDelayOptionSecurityEffect(card));
  315. }
  316. #endregion
  317. return cardEffects;
  318. }
  319. }
  320. }