BT17_070.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT17
  4. {
  5. public class BT17_070 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alternate Digivolution
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasText("Dark Masters");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  18. permanentCondition: PermanentCondition,
  19. digivolutionCost: 3,
  20. ignoreDigivolutionRequirement: false,
  21. card: card,
  22. condition: null)
  23. );
  24. }
  25. #endregion
  26. #region On Play/ When Digivolving Shared
  27. bool CanSelectCardSharedCondition(CardSource cardSource)
  28. {
  29. return cardSource.IsDigimon &&
  30. cardSource.HasLevel &&
  31. cardSource.IsLevel5 &&
  32. cardSource.HasText("Dark Masters");
  33. }
  34. bool CanSelectOpponentPermanentSharedCondition(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  37. permanent.TopCard.HasLevel &&
  38. permanent.Level <= 5;
  39. }
  40. #endregion
  41. #region On Play
  42. if (timing == EffectTiming.OnEnterFieldAnyone)
  43. {
  44. ActivateClass activateClass = new ActivateClass();
  45. activateClass.SetUpICardEffect("Place 1 card to digivolution cards to delete opponent's Digimon", CanUseCondition, card);
  46. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  47. cardEffects.Add(activateClass);
  48. string EffectDescription()
  49. {
  50. return
  51. "[On Play] By placing 1 level 5 card with [Dark Masters] in its text from your hand or trash as this Digimon's bottom digivolution card, delete 1 of your opponent's level 5 or lower Digimon.";
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleArea(card) &&
  60. (card.Owner.HandCards.Some(CanSelectCardSharedCondition) ||
  61. card.Owner.TrashCards.Some(CanSelectCardSharedCondition));
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. bool canSelectHand = card.Owner.HandCards.Some(CanSelectCardSharedCondition);
  66. bool canSelectTrash = card.Owner.TrashCards.Some(CanSelectCardSharedCondition);
  67. if (canSelectHand || canSelectTrash)
  68. {
  69. if (canSelectHand && canSelectTrash)
  70. {
  71. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  72. {
  73. new(message: "From hand", value: true, spriteIndex: 0),
  74. new(message: "From trash", value: false, spriteIndex: 1),
  75. };
  76. string selectPlayerMessage = "From which area do you choose a digivolution card?";
  77. string notSelectPlayerMessage = "The opponent is choosing from which area to choose a digivolution card?.";
  78. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  79. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  80. notSelectPlayerMessage: notSelectPlayerMessage);
  81. }
  82. else
  83. {
  84. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  85. }
  86. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  87. .WaitForEndSelect());
  88. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  89. List<CardSource> selectedCards = new List<CardSource>();
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCards.Add(cardSource);
  93. yield return null;
  94. }
  95. if (fromHand)
  96. {
  97. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  98. selectHandEffect.SetUp(
  99. selectPlayer: card.Owner,
  100. canTargetCondition: CanSelectCardSharedCondition,
  101. canTargetCondition_ByPreSelecetedList: null,
  102. canEndSelectCondition: null,
  103. maxCount: 1,
  104. canNoSelect: true,
  105. canEndNotMax: false,
  106. isShowOpponent: true,
  107. selectCardCoroutine: SelectCardCoroutine,
  108. afterSelectCardCoroutine: null,
  109. mode: SelectHandEffect.Mode.Custom,
  110. cardEffect: activateClass);
  111. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  112. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  113. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  114. yield return StartCoroutine(selectHandEffect.Activate());
  115. }
  116. else
  117. {
  118. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  119. selectCardEffect.SetUp(
  120. canTargetCondition: CanSelectCardSharedCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. canNoSelect: () => true,
  124. selectCardCoroutine: SelectCardCoroutine,
  125. afterSelectCardCoroutine: null,
  126. message: "Select 1 card to play.",
  127. maxCount: 1,
  128. canEndNotMax: false,
  129. isShowOpponent: true,
  130. mode: SelectCardEffect.Mode.Custom,
  131. root: SelectCardEffect.Root.Trash,
  132. customRootCardList: null,
  133. canLookReverseCard: true,
  134. selectPlayer: card.Owner,
  135. cardEffect: activateClass);
  136. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  137. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  138. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  139. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  140. }
  141. if (selectedCards.Count == 1)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  144. .AddDigivolutionCardsBottom(
  145. selectedCards,
  146. activateClass));
  147. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentSharedCondition))
  148. {
  149. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  150. selectPermanentEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectOpponentPermanentSharedCondition,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: 1,
  156. canNoSelect: false,
  157. canEndNotMax: false,
  158. selectPermanentCoroutine: null,
  159. afterSelectPermanentCoroutine: null,
  160. mode: SelectPermanentEffect.Mode.Destroy,
  161. cardEffect: activateClass);
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. }
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. #region When Digivolving
  170. if (timing == EffectTiming.OnEnterFieldAnyone)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("Place 1 card to digivolution cards to delete opponent's Digimon", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  175. cardEffects.Add(activateClass);
  176. string EffectDescription()
  177. {
  178. return
  179. "[When Digivolving] By placing 1 level 5 card with [Dark Masters] in its text from your hand or trash as this Digimon's bottom digivolution card, delete 1 of your opponent's level 5 or lower Digimon.";
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleArea(card) &&
  188. (card.Owner.HandCards.Some(CanSelectCardSharedCondition) ||
  189. card.Owner.TrashCards.Some(CanSelectCardSharedCondition));
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. bool canSelectHand = card.Owner.HandCards.Some(CanSelectCardSharedCondition);
  194. bool canSelectTrash = card.Owner.TrashCards.Some(CanSelectCardSharedCondition);
  195. if (canSelectHand || canSelectTrash)
  196. {
  197. if (canSelectHand && canSelectTrash)
  198. {
  199. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  200. {
  201. new(message: "From hand", value: true, spriteIndex: 0),
  202. new(message: "From trash", value: false, spriteIndex: 1),
  203. };
  204. string selectPlayerMessage = "From which area do you choose a digivolution card?";
  205. string notSelectPlayerMessage = "The opponent is choosing from which area to choose a digivolution card?.";
  206. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  207. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  208. notSelectPlayerMessage: notSelectPlayerMessage);
  209. }
  210. else
  211. {
  212. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  215. .WaitForEndSelect());
  216. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  217. List<CardSource> selectedCards = new List<CardSource>();
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCards.Add(cardSource);
  221. yield return null;
  222. }
  223. if (fromHand)
  224. {
  225. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  226. selectHandEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectCardSharedCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. isShowOpponent: true,
  235. selectCardCoroutine: SelectCardCoroutine,
  236. afterSelectCardCoroutine: null,
  237. mode: SelectHandEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  240. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  241. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  242. yield return StartCoroutine(selectHandEffect.Activate());
  243. }
  244. else
  245. {
  246. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  247. selectCardEffect.SetUp(
  248. canTargetCondition: CanSelectCardSharedCondition,
  249. canTargetCondition_ByPreSelecetedList: null,
  250. canEndSelectCondition: null,
  251. canNoSelect: () => true,
  252. selectCardCoroutine: SelectCardCoroutine,
  253. afterSelectCardCoroutine: null,
  254. message: "Select 1 card to play.",
  255. maxCount: 1,
  256. canEndNotMax: false,
  257. isShowOpponent: true,
  258. mode: SelectCardEffect.Mode.Custom,
  259. root: SelectCardEffect.Root.Trash,
  260. customRootCardList: null,
  261. canLookReverseCard: true,
  262. selectPlayer: card.Owner,
  263. cardEffect: activateClass);
  264. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  265. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  266. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  267. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  268. }
  269. if (selectedCards.Count == 1)
  270. {
  271. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  272. .AddDigivolutionCardsBottom(
  273. selectedCards,
  274. activateClass));
  275. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentSharedCondition))
  276. {
  277. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  278. selectPermanentEffect.SetUp(
  279. selectPlayer: card.Owner,
  280. canTargetCondition: CanSelectOpponentPermanentSharedCondition,
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. maxCount: 1,
  284. canNoSelect: false,
  285. canEndNotMax: false,
  286. selectPermanentCoroutine: null,
  287. afterSelectPermanentCoroutine: null,
  288. mode: SelectPermanentEffect.Mode.Destroy,
  289. cardEffect: activateClass);
  290. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  291. }
  292. }
  293. }
  294. }
  295. }
  296. #endregion
  297. #region When Attacking
  298. if (timing == EffectTiming.OnAllyAttack)
  299. {
  300. ActivateClass activateClass = new ActivateClass();
  301. activateClass.SetUpICardEffect("Return 7 cards from opponent's trash to the bottom of deck to unsuspend",
  302. CanUseCondition, card);
  303. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  304. cardEffects.Add(activateClass);
  305. string EffectDescription()
  306. {
  307. return
  308. "[When Attacking] By returning 7 cards from your opponent's trash to the bottom of the deck, unsuspend this Digimon.";
  309. }
  310. bool CanSelectCardCondition(CardSource cardSource)
  311. {
  312. return cardSource && cardSource.Owner == card.Owner.Enemy;
  313. }
  314. bool CanUseCondition(Hashtable hashtable)
  315. {
  316. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  317. }
  318. bool CanActivateCondition(Hashtable hashtable)
  319. {
  320. return CardEffectCommons.IsExistOnBattleArea(card) &&
  321. CardEffectCommons.MatchConditionOpponentsCardCountInTrash(card, CanSelectCardCondition) >= 7;
  322. }
  323. IEnumerator ActivateCoroutine(Hashtable hashtable)
  324. {
  325. if (CardEffectCommons.MatchConditionOpponentsCardCountInTrash(card, CanSelectCardCondition) >= 7)
  326. {
  327. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  328. selectCardEffect.SetUp(
  329. canTargetCondition: CanSelectCardCondition,
  330. canTargetCondition_ByPreSelecetedList: null,
  331. canEndSelectCondition: null,
  332. canNoSelect: () => true,
  333. selectCardCoroutine: null,
  334. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  335. message: "Select 7 cards in opponent's trash to place at the bottom of the deck.",
  336. maxCount: 7,
  337. canEndNotMax: false,
  338. isShowOpponent: true,
  339. mode: SelectCardEffect.Mode.Custom,
  340. root: SelectCardEffect.Root.Custom,
  341. customRootCardList: card.Owner.Enemy.TrashCards,
  342. canLookReverseCard: true,
  343. selectPlayer: card.Owner,
  344. cardEffect: activateClass);
  345. selectCardEffect.SetNotShowCard();
  346. selectCardEffect.SetNotAddLog();
  347. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  348. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  349. {
  350. if (cardSources.Count == 7)
  351. {
  352. yield return ContinuousController.instance.StartCoroutine(
  353. CardObjectController.AddLibraryBottomCards(cardSources));
  354. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  355. .ShowCardEffect(cardSources, "Deck Bottom Card", true, true));
  356. yield return ContinuousController.instance.StartCoroutine(
  357. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() },
  358. activateClass).Unsuspend());
  359. }
  360. }
  361. }
  362. }
  363. }
  364. #endregion
  365. return cardEffects;
  366. }
  367. }
  368. }