BT13_019.cs 23 KB

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