BT18_074.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_074 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region DigiXros
  12. if (timing == EffectTiming.None)
  13. {
  14. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  15. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  16. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  17. addDigiXrosConditionClass.SetNotShowUI(true);
  18. cardEffects.Add(addDigiXrosConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. DigiXrosCondition GetDigiXros(CardSource cardSource)
  24. {
  25. if (cardSource == card)
  26. {
  27. DigiXrosConditionElement elementMercurymon =
  28. new DigiXrosConditionElement(CanSelectCardCondition, "Mercurymon");
  29. bool CanSelectCardCondition(CardSource conditionCardSource)
  30. {
  31. if (conditionCardSource != null)
  32. {
  33. if (conditionCardSource.Owner == card.Owner)
  34. {
  35. if (conditionCardSource.IsDigimon)
  36. {
  37. if (conditionCardSource.CardNames_DigiXros.Contains("Mercurymon"))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. DigiXrosConditionElement elementSephirothmon =
  47. new DigiXrosConditionElement(CanSelectCardCondition1, "Sephirothmon");
  48. bool CanSelectCardCondition1(CardSource conditionCardSource)
  49. {
  50. if (conditionCardSource != null)
  51. {
  52. if (conditionCardSource.Owner == card.Owner)
  53. {
  54. if (conditionCardSource.IsDigimon)
  55. {
  56. if (conditionCardSource.CardNames_DigiXros.Contains("Sephirothmon"))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  66. { elementMercurymon, elementSephirothmon };
  67. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  68. return digiXrosCondition;
  69. }
  70. return null;
  71. }
  72. }
  73. #endregion
  74. #region On Play
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  80. cardEffects.Add(activateClass);
  81. string EffectDiscription()
  82. {
  83. return "[On Play] You may reveal the top 3 cards of your deck. Play 1 black card with a play cost of 7 or less among them without paying the cost. Trash the rest.";
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  88. {
  89. if (cardSource.GetCostItself <= 7)
  90. {
  91. if (cardSource.HasPlayCost)
  92. {
  93. if (cardSource.HasCardColor(CardColor.Black))
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  105. }
  106. bool CanActivateCondition(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  109. {
  110. if (card.Owner.LibraryCards.Count >= 1)
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. List<CardSource> selectedCards = new List<CardSource>();
  120. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  121. revealCount: 3,
  122. simplifiedSelectCardConditions:
  123. new SimplifiedSelectCardConditionClass[]
  124. {
  125. new SimplifiedSelectCardConditionClass(
  126. canTargetCondition:CanSelectCardCondition,
  127. message: "Select 1 black card with a play cost of 7 or less.",
  128. mode: SelectCardEffect.Mode.Custom,
  129. maxCount: 1,
  130. selectCardCoroutine: SelectCardCoroutine),
  131. },
  132. remainingCardsPlace: RemainingCardsPlace.Trash,
  133. activateClass: activateClass
  134. ));
  135. IEnumerator SelectCardCoroutine(CardSource cardSource)
  136. {
  137. selectedCards.Add(cardSource);
  138. yield return null;
  139. }
  140. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  141. cardSources: selectedCards,
  142. activateClass: activateClass,
  143. payCost: false,
  144. isTapped: false,
  145. root: SelectCardEffect.Root.Library,
  146. activateETB: true));
  147. }
  148. }
  149. #endregion
  150. #region When Digivolving
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[When Digivolving] You may reveal the top 3 cards of your deck. Play 1 black card with a play cost of 7 or less among them without paying the cost. Trash the rest.";
  160. }
  161. bool CanSelectCardCondition(CardSource cardSource)
  162. {
  163. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  164. {
  165. if (cardSource.GetCostItself <= 7)
  166. {
  167. if (cardSource.HasPlayCost)
  168. {
  169. if (cardSource.HasCardColor(CardColor.Black))
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. }
  176. return false;
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  181. {
  182. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  183. }
  184. return false;
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  189. {
  190. if (card.Owner.LibraryCards.Count >= 1)
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  198. {
  199. List<CardSource> selectedCards = new List<CardSource>();
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  201. revealCount: 3,
  202. simplifiedSelectCardConditions:
  203. new SimplifiedSelectCardConditionClass[]
  204. {
  205. new SimplifiedSelectCardConditionClass(
  206. canTargetCondition:CanSelectCardCondition,
  207. message: "Select 1 black card with a play cost of 7 or less.",
  208. mode: SelectCardEffect.Mode.Custom,
  209. maxCount: 1,
  210. selectCardCoroutine: SelectCardCoroutine),
  211. },
  212. remainingCardsPlace: RemainingCardsPlace.Trash,
  213. activateClass: activateClass
  214. ));
  215. IEnumerator SelectCardCoroutine(CardSource cardSource)
  216. {
  217. selectedCards.Add(cardSource);
  218. yield return null;
  219. }
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  221. cardSources: selectedCards,
  222. activateClass: activateClass,
  223. payCost: false,
  224. isTapped: false,
  225. root: SelectCardEffect.Root.Library,
  226. activateETB: true));
  227. }
  228. }
  229. #endregion
  230. #region All Turns
  231. if (timing == EffectTiming.WhenRemoveField)
  232. {
  233. ActivateClass activateClass = new ActivateClass();
  234. activateClass.SetUpICardEffect("Return a Digimon or play a Digimon from this Digimon digivolution sources to hand.", CanUseCondition, card);
  235. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  236. cardEffects.Add(activateClass);
  237. string EffectDiscription()
  238. {
  239. return "[All Turns] When this Digimon would leave the battle area, you may return to the hand or play 1 level 4 or lower black Digimon card from this Digimon's digivolution cards without paying the cost.";
  240. }
  241. bool CanSelectCardCondition(CardSource cardSource)
  242. {
  243. if (cardSource != null)
  244. {
  245. if (cardSource.Owner == card.Owner)
  246. {
  247. if (cardSource.IsDigimon)
  248. {
  249. if (cardSource.Level <= 4)
  250. {
  251. if (cardSource.HasCardColor(CardColor.Black))
  252. {
  253. if (cardSource.HasLevel)
  254. {
  255. return true;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  267. {
  268. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  269. {
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. bool CanActivateCondition(Hashtable hashtable)
  276. {
  277. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  278. {
  279. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  280. {
  281. return true;
  282. }
  283. }
  284. return false;
  285. }
  286. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  287. {
  288. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  289. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  290. if (canSelectDigivolutionCards)
  291. {
  292. if (canSelectDigivolutionCards)
  293. {
  294. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  295. {
  296. new SelectionElement<bool>(message: $"Return to hand", value : true, spriteIndex: 0),
  297. new SelectionElement<bool>(message: $"Play a Digimon", value : false, spriteIndex: 1),
  298. };
  299. string selectPlayerMessage = "Do you want to return to hand or play 1 level 4 or lower Digimon from its digivolution sources";
  300. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  301. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  302. }
  303. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  304. bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  305. List<CardSource> selectedCards = new List<CardSource>();
  306. IEnumerator SelectCardCoroutine(CardSource cardSource)
  307. {
  308. selectedCards.Add(cardSource);
  309. yield return null;
  310. }
  311. if (toHand)
  312. {
  313. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  314. selectCardEffect.SetUp(
  315. canTargetCondition: CanSelectCardCondition,
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. canNoSelect: () => true,
  319. selectCardCoroutine: SelectCardCoroutine,
  320. afterSelectCardCoroutine: null,
  321. message: "Select 1 card to return to hand.",
  322. maxCount: 1,
  323. canEndNotMax: false,
  324. isShowOpponent: true,
  325. mode: SelectCardEffect.Mode.AddHand,
  326. root: SelectCardEffect.Root.Custom,
  327. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  328. canLookReverseCard: true,
  329. selectPlayer: card.Owner,
  330. cardEffect: activateClass);
  331. yield return StartCoroutine(selectCardEffect.Activate());
  332. }
  333. else
  334. {
  335. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  336. selectCardEffect.SetUp(
  337. canTargetCondition: CanSelectCardCondition,
  338. canTargetCondition_ByPreSelecetedList: null,
  339. canEndSelectCondition: null,
  340. canNoSelect: () => true,
  341. selectCardCoroutine: SelectCardCoroutine,
  342. afterSelectCardCoroutine: null,
  343. message: "Select 1 card to play.",
  344. maxCount: 1,
  345. canEndNotMax: false,
  346. isShowOpponent: true,
  347. mode: SelectCardEffect.Mode.Custom,
  348. root: SelectCardEffect.Root.Custom,
  349. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  350. canLookReverseCard: true,
  351. selectPlayer: card.Owner,
  352. cardEffect: activateClass);
  353. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  354. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  355. yield return StartCoroutine(selectCardEffect.Activate());
  356. }
  357. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  358. if (!toHand)
  359. {
  360. root = SelectCardEffect.Root.DigivolutionCards;
  361. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedCards[0], payCost: false, cardEffect: activateClass))
  362. {
  363. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  364. cardSources: selectedCards,
  365. activateClass: activateClass,
  366. payCost: false,
  367. isTapped: false,
  368. root: root,
  369. activateETB: true));
  370. }
  371. }
  372. }
  373. }
  374. }
  375. #endregion
  376. return cardEffects;
  377. }
  378. }
  379. }