DarktoLightThundertoGunfire_BT18_097.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class DarktoLightThundertoGunfire_BT18_097 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[Main] You may place up to 5 [Hybrid] trait cards with different names from your hand or trash under 1 of your Tamers. Then, 1 of your Tamers with 5 or more cards under it may digivolve into [MagnaGarurumon] in the hand or trash, ignoring digivolution requirements and without paying the cost.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  27. }
  28. bool CanSelectOwnTamerPermanentCondition(Permanent permanent)
  29. {
  30. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && permanent.IsTamer;
  31. }
  32. bool SelectHybridCardCondition(CardSource cardSource)
  33. {
  34. return cardSource.ContainsTraits("Hybrid");
  35. }
  36. bool DigivolveFromPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  39. permanent.IsTamer && permanent.DigivolutionCards.Count >= 5 &&
  40. (card.Owner.HandCards.Where(DigivolveToCardCondition).Any(cardSource =>
  41. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)) ||
  42. card.Owner.TrashCards.Where(DigivolveToCardCondition).Any(cardSource =>
  43. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass)));
  44. }
  45. bool DigivolveToCardCondition(CardSource cardSource)
  46. {
  47. return cardSource.EqualsCardName("MagnaGarurumon");
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable hashtable)
  50. {
  51. // Place Hybrid cards under Tamer
  52. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnTamerPermanentCondition))
  53. {
  54. Permanent tamerPermanent = null;
  55. SelectPermanentEffect selectPermanentEffect =
  56. GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectOwnTamerPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine1,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage(
  70. "Select 1 of your Tamers that will digivolve.",
  71. "The opponent is selecting 1 of their Tamers that will digivolve.");
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. IEnumerator SelectPermanentCoroutine1(Permanent selectedPermanent)
  74. {
  75. tamerPermanent = selectedPermanent;
  76. yield return null;
  77. }
  78. if (tamerPermanent != null)
  79. {
  80. List<CardSource> digivolutionCards = new List<CardSource>();
  81. if (CardEffectCommons.HasMatchConditionOwnersHand(card, SelectHybridCardCondition))
  82. {
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: SelectHybridCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: Math.Min(5,
  90. CardEffectCommons.MatchConditionOwnersCardCountInHand(card, SelectHybridCardCondition)),
  91. canNoSelect: true,
  92. canEndNotMax: true,
  93. isShowOpponent: true,
  94. selectCardCoroutine: SelectCardCoroutine,
  95. afterSelectCardCoroutine: null,
  96. mode: SelectHandEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. selectHandEffect.SetUpCustomMessage("Select cards in hand to place in digivolution cards.",
  99. "The opponent is selecting cards in hand to place in digivolution cards.");
  100. yield return StartCoroutine(selectHandEffect.Activate());
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. digivolutionCards.Add(cardSource);
  104. yield return null;
  105. }
  106. }
  107. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SelectHybridCardCondition))
  108. {
  109. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  110. selectCardEffect.SetUp(
  111. canTargetCondition: SelectHybridCardCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. canNoSelect: () => true,
  115. selectCardCoroutine: SelectCardCoroutine,
  116. afterSelectCardCoroutine: null,
  117. message: "Select cards in trash to place in digivolution cards.",
  118. maxCount: Math.Min(5 - digivolutionCards.Count,
  119. CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, SelectHybridCardCondition)),
  120. canEndNotMax: true,
  121. isShowOpponent: true,
  122. mode: SelectCardEffect.Mode.Custom,
  123. root: SelectCardEffect.Root.Trash,
  124. customRootCardList: null,
  125. canLookReverseCard: true,
  126. selectPlayer: card.Owner,
  127. cardEffect: activateClass);
  128. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  129. IEnumerator SelectCardCoroutine(CardSource cardSource)
  130. {
  131. digivolutionCards.Add(cardSource);
  132. yield return null;
  133. }
  134. }
  135. if (digivolutionCards.Count >= 1)
  136. {
  137. List<CardSource> digivolutionCardsFixed = new List<CardSource>();
  138. if (digivolutionCards.Count == 1)
  139. {
  140. digivolutionCardsFixed.AddRange(digivolutionCards);
  141. }
  142. else
  143. {
  144. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  145. selectCardEffect.SetUp(
  146. canTargetCondition: _ => true,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. canNoSelect: () => false,
  150. selectCardCoroutine: null,
  151. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  152. message:
  153. "Specify the order to place the cards on the bottom of the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  154. maxCount: digivolutionCards.Count,
  155. canEndNotMax: false,
  156. isShowOpponent: false,
  157. mode: SelectCardEffect.Mode.Custom,
  158. root: SelectCardEffect.Root.Custom,
  159. customRootCardList: digivolutionCards,
  160. canLookReverseCard: true,
  161. selectPlayer: card.Owner,
  162. cardEffect: activateClass);
  163. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  164. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  165. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  166. {
  167. digivolutionCardsFixed.AddRange(cardSources);
  168. yield return null;
  169. }
  170. }
  171. if (CardEffectCommons.IsExistOnBattleArea(card))
  172. {
  173. yield return ContinuousController.instance.StartCoroutine(tamerPermanent
  174. .AddDigivolutionCardsBottom(digivolutionCardsFixed, activateClass));
  175. }
  176. }
  177. }
  178. }
  179. // Digivolve
  180. if (CardEffectCommons.HasMatchConditionPermanent(DigivolveFromPermanentCondition))
  181. {
  182. Permanent selectedPermanent = null;
  183. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  184. selectPermanentEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: DigivolveFromPermanentCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. maxCount: 1,
  190. canNoSelect: false,
  191. canEndNotMax: false,
  192. selectPermanentCoroutine: SelectPermanentCoroutine,
  193. afterSelectPermanentCoroutine: null,
  194. mode: SelectPermanentEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that will digivolve.",
  197. "The opponent is selecting 1 Tamer that will digivolve.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. selectedPermanent = permanent;
  202. yield return null;
  203. }
  204. if (selectedPermanent != null)
  205. {
  206. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, DigivolveToCardCondition);
  207. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, DigivolveToCardCondition);
  208. if (canSelectHand || canSelectTrash)
  209. {
  210. if (canSelectHand && canSelectTrash)
  211. {
  212. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  213. {
  214. new(message: "From hand", value: true, spriteIndex: 0),
  215. new(message: "From trash", value: false, spriteIndex: 1),
  216. };
  217. string selectPlayerMessage = "From which area do you digivolve?";
  218. string notSelectPlayerMessage = "The opponent is choosing from which area to digivolve.";
  219. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  220. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  221. notSelectPlayerMessage: notSelectPlayerMessage);
  222. }
  223. else
  224. {
  225. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  226. }
  227. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  228. .WaitForEndSelect());
  229. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  230. yield return ContinuousController.instance.StartCoroutine(
  231. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  232. targetPermanent: selectedPermanent,
  233. cardCondition: DigivolveToCardCondition,
  234. payCost: true,
  235. reduceCostTuple: null,
  236. fixedCostTuple: null,
  237. ignoreDigivolutionRequirementFixedCost: 0,
  238. isHand: fromHand,
  239. activateClass: activateClass,
  240. successProcess: null));
  241. }
  242. }
  243. }
  244. }
  245. }
  246. #endregion
  247. #region Security Effect
  248. if (timing == EffectTiming.SecuritySkill)
  249. {
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect($"Play 1 Tamer card with an inherited effect from hand or trash and add this card to hand",
  252. CanUseCondition, card);
  253. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  254. activateClass.SetIsSecurityEffect(true);
  255. cardEffects.Add(activateClass);
  256. string EffectDescription()
  257. {
  258. return
  259. "[Security] You may play 1 Tamer card with an inherited effect from your hand or trash without paying the cost. Then, add this card to the hand.";
  260. }
  261. bool CanUseCondition(Hashtable hashtable)
  262. {
  263. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  264. }
  265. bool CanSelectCardCondition(CardSource cardSource)
  266. {
  267. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  268. {
  269. return cardSource.IsTamer && cardSource.HasInheritedEffect;
  270. }
  271. return false;
  272. }
  273. IEnumerator ActivateCoroutine(Hashtable hashtable)
  274. {
  275. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  276. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  277. if (canSelectHand || canSelectTrash)
  278. {
  279. if (canSelectHand && canSelectTrash)
  280. {
  281. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  282. {
  283. new(message: "From hand", value: true, spriteIndex: 0),
  284. new(message: "From trash", value: false, spriteIndex: 1),
  285. };
  286. string selectPlayerMessage = "From which area do you play a card?";
  287. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  288. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  289. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  290. notSelectPlayerMessage: notSelectPlayerMessage);
  291. }
  292. else
  293. {
  294. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  295. }
  296. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  297. .WaitForEndSelect());
  298. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  299. List<CardSource> selectedCards = new List<CardSource>();
  300. IEnumerator SelectCardCoroutine(CardSource cardSource)
  301. {
  302. selectedCards.Add(cardSource);
  303. yield return null;
  304. }
  305. if (fromHand)
  306. {
  307. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  308. selectHandEffect.SetUp(
  309. selectPlayer: card.Owner,
  310. canTargetCondition: CanSelectCardCondition,
  311. canTargetCondition_ByPreSelecetedList: null,
  312. canEndSelectCondition: null,
  313. maxCount: 1,
  314. canNoSelect: true,
  315. canEndNotMax: false,
  316. isShowOpponent: true,
  317. selectCardCoroutine: SelectCardCoroutine,
  318. afterSelectCardCoroutine: null,
  319. mode: SelectHandEffect.Mode.Custom,
  320. cardEffect: activateClass);
  321. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  322. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  323. yield return StartCoroutine(selectHandEffect.Activate());
  324. }
  325. else
  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: SelectCardCoroutine,
  334. afterSelectCardCoroutine: null,
  335. message: "Select 1 card to play.",
  336. maxCount: 1,
  337. canEndNotMax: false,
  338. isShowOpponent: true,
  339. mode: SelectCardEffect.Mode.Custom,
  340. root: SelectCardEffect.Root.Trash,
  341. customRootCardList: null,
  342. canLookReverseCard: true,
  343. selectPlayer: card.Owner,
  344. cardEffect: activateClass);
  345. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  346. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  347. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  348. }
  349. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  350. if (!fromHand)
  351. {
  352. root = SelectCardEffect.Root.Trash;
  353. }
  354. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  355. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root,
  356. activateETB: true));
  357. }
  358. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  359. }
  360. }
  361. #endregion
  362. return cardEffects;
  363. }
  364. }
  365. }