BT11_087.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT11
  6. {
  7. public class BT11_087 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash 4 cards from deck top and return cards from trash to hand and under Tamer", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Trash the top 4 cards of your deck. Then, add up to 2 cards with [Bagra Army] in one of their traits from your trash to your hand, and place up to 2 Digimon cards with [Bagra Army] in their traits from your trash under 1 of your Tamers.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.CardTraits.Contains("Bagra Army"))
  25. {
  26. return true;
  27. }
  28. if (cardSource.CardTraits.Contains("BagraArmy"))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  37. {
  38. if (permanent.IsTamer)
  39. {
  40. if (!permanent.IsToken)
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanSelectCardCondition1(CardSource cardSource)
  49. {
  50. if (cardSource.IsDigimon)
  51. {
  52. if (cardSource.CardTraits.Contains("Bagra Army"))
  53. {
  54. return true;
  55. }
  56. if (cardSource.CardTraits.Contains("BagraArmy"))
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  66. }
  67. bool CanActivateCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.IsExistOnBattleArea(card);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(4, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  74. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  75. {
  76. int maxCount = Math.Min(2, card.Owner.TrashCards.Count(CanSelectCardCondition));
  77. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  78. selectCardEffect.SetUp(
  79. canTargetCondition: CanSelectCardCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: CanEndSelectCondition,
  82. canNoSelect: () => false,
  83. selectCardCoroutine: null,
  84. afterSelectCardCoroutine: null,
  85. message: "Select up to 2 cards with [Bagra Army] in its traits to add to your hand.",
  86. maxCount: maxCount,
  87. canEndNotMax: true,
  88. isShowOpponent: true,
  89. mode: SelectCardEffect.Mode.AddHand,
  90. root: SelectCardEffect.Root.Trash,
  91. customRootCardList: null,
  92. canLookReverseCard: true,
  93. selectPlayer: card.Owner,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  96. bool CanEndSelectCondition(List<CardSource> cardSources)
  97. {
  98. if (CardEffectCommons.HasNoElement(cardSources))
  99. {
  100. return false;
  101. }
  102. return true;
  103. }
  104. }
  105. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  106. {
  107. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  108. {
  109. List<CardSource> selectedCards = new List<CardSource>();
  110. List<CardSource> digivolutionCards = new List<CardSource>();
  111. int maxCount = Math.Min(2, card.Owner.TrashCards.Count(CanSelectCardCondition1));
  112. if (maxCount == 1)
  113. {
  114. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  115. selectCardEffect.SetUp(
  116. canTargetCondition: CanSelectCardCondition1,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. canNoSelect: () => false,
  120. selectCardCoroutine: SelectCardCoroutine,
  121. afterSelectCardCoroutine: null,
  122. message: "Select 1 Digimon card with [Bagra Army] in its traits from trash.",
  123. maxCount: maxCount,
  124. canEndNotMax: false,
  125. isShowOpponent: true,
  126. mode: SelectCardEffect.Mode.Custom,
  127. root: SelectCardEffect.Root.Trash,
  128. customRootCardList: null,
  129. canLookReverseCard: true,
  130. selectPlayer: card.Owner,
  131. cardEffect: activateClass);
  132. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card with [Bagra Army] in its traits from trash.", "The opponent is selecting 1 Digimon card with [Bagra Army] in its traits from trash.");
  133. yield return StartCoroutine(selectCardEffect.Activate());
  134. IEnumerator SelectCardCoroutine(CardSource cardSource)
  135. {
  136. selectedCards.Add(cardSource);
  137. yield return null;
  138. }
  139. }
  140. else if (maxCount == 2)
  141. {
  142. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  143. selectCardEffect.SetUp(
  144. canTargetCondition: CanSelectCardCondition1,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: CanEndSelectCondition,
  147. canNoSelect: () => false,
  148. selectCardCoroutine: SelectCardCoroutine,
  149. afterSelectCardCoroutine: null,
  150. message: "Select up to 2 Digimon cards with [Bagra Army] in its traits from trash\n(cards will be placed so that cards with lower numbers are on top).",
  151. maxCount: maxCount,
  152. canEndNotMax: true,
  153. isShowOpponent: true,
  154. mode: SelectCardEffect.Mode.Custom,
  155. root: SelectCardEffect.Root.Trash,
  156. customRootCardList: null,
  157. canLookReverseCard: true,
  158. selectPlayer: card.Owner,
  159. cardEffect: activateClass);
  160. selectCardEffect.SetUpCustomMessage("Select up to 2 Digimon cards with [Bagra Army] in its traits from trash.", "The opponent is selecting up to 2 Digimon cards with [Bagra Army] in its traits from trash.");
  161. yield return StartCoroutine(selectCardEffect.Activate());
  162. bool CanEndSelectCondition(List<CardSource> cardSources)
  163. {
  164. if (CardEffectCommons.HasNoElement(cardSources))
  165. {
  166. return false;
  167. }
  168. return true;
  169. }
  170. IEnumerator SelectCardCoroutine(CardSource cardSource)
  171. {
  172. selectedCards.Add(cardSource);
  173. yield return null;
  174. }
  175. }
  176. if (selectedCards.Count >= 1)
  177. {
  178. foreach (CardSource cardSource in selectedCards)
  179. {
  180. digivolutionCards.Add(cardSource);
  181. }
  182. if (digivolutionCards.Count >= 1)
  183. {
  184. maxCount = 1;
  185. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanSelectPermanentCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: maxCount,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: SelectPermanentCoroutine,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Custom,
  197. cardEffect: activateClass);
  198. selectPermanentEffect.SetUpCustomMessage($"Select 1 Tamer that will get digivolution cards from trash.", $"The opponent is selecting 1 Tamer that will get a digivolution cards from trash.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  201. {
  202. Permanent selectedPermanent = permanent;
  203. if (selectedPermanent != null)
  204. {
  205. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. if (timing == EffectTiming.OnMove)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("The moved Digimon gets \"[When Attacking] Lose 3 memory.\"", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  219. cardEffects.Add(activateClass);
  220. string EffectDiscription()
  221. {
  222. return "[Opponent's Turn] When your opponent moves a Digimon from their breeding area, by trashing 1 of this Digimon's digivolution cards, that Digimon gains \"[When Attacking] Lose 3 memory\" for the turn.";
  223. }
  224. bool CanSelectCardCondition(CardSource cardSource)
  225. {
  226. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  227. }
  228. bool PermanentCondition(Permanent permanent)
  229. {
  230. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  231. }
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. if (CardEffectCommons.IsExistOnBattleArea(card))
  235. {
  236. if (CardEffectCommons.IsOpponentTurn(card))
  237. {
  238. if (CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. bool CanActivateCondition(Hashtable hashtable)
  247. {
  248. if (CardEffectCommons.IsExistOnBattleArea(card))
  249. {
  250. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  251. {
  252. return true;
  253. }
  254. }
  255. return false;
  256. }
  257. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  258. {
  259. bool trashed = false;
  260. List<CardSource> selectedCards = new List<CardSource>();
  261. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  262. selectCardEffect.SetUp(
  263. canTargetCondition: CanSelectCardCondition,
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. canNoSelect: () => true,
  267. selectCardCoroutine: SelectCardCoroutine,
  268. afterSelectCardCoroutine: null,
  269. message: "Select 1 digivolution card to discard.",
  270. maxCount: 1,
  271. canEndNotMax: false,
  272. isShowOpponent: true,
  273. mode: SelectCardEffect.Mode.Custom,
  274. root: SelectCardEffect.Root.Custom,
  275. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  276. canLookReverseCard: true,
  277. selectPlayer: card.Owner,
  278. cardEffect: null);
  279. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to discard.", "The opponent is selecting 1 digivolution card to discard.");
  280. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  281. IEnumerator SelectCardCoroutine(CardSource cardSource)
  282. {
  283. selectedCards.Add(cardSource);
  284. yield return null;
  285. }
  286. if (selectedCards.Count >= 1)
  287. {
  288. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  289. trashed = true;
  290. }
  291. if (trashed)
  292. {
  293. Permanent selectedPermanent = CardEffectCommons.GetMovedPermanentFromHashtable(_hashtable);
  294. if (selectedPermanent != null)
  295. {
  296. ActivateClass activateClass1 = new ActivateClass();
  297. activateClass1.SetUpICardEffect("Memory -3", CanUseCondition1, selectedPermanent.TopCard);
  298. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  299. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  300. selectedPermanent.UntilEachTurnEndEffects.Add(GetCardEffect);
  301. selectedPermanent.UntilEachTurnEndEffects.Add(GetDetailEffect);
  302. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  303. string EffectDiscription1()
  304. {
  305. return "[When Attacking] Lose 3 memory.";
  306. }
  307. bool CanUseCondition1(Hashtable hashtable1)
  308. {
  309. if (selectedPermanent.TopCard != null)
  310. {
  311. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  312. {
  313. if (GManager.instance.attackProcess.AttackingPermanent == selectedPermanent)
  314. {
  315. return true;
  316. }
  317. }
  318. }
  319. return false;
  320. }
  321. bool CanActivateCondition1(Hashtable hashtable1)
  322. {
  323. if (selectedPermanent.TopCard != null)
  324. {
  325. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  326. {
  327. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  328. {
  329. return true;
  330. }
  331. }
  332. }
  333. return false;
  334. }
  335. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  336. {
  337. if (selectedPermanent.TopCard != null)
  338. {
  339. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  340. {
  341. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.TopCard.Owner.AddMemory(-3, activateClass1));
  342. }
  343. }
  344. }
  345. ICardEffect GetCardEffect(EffectTiming _timing)
  346. {
  347. if (_timing == EffectTiming.OnAllyAttack)
  348. {
  349. return activateClass1;
  350. }
  351. return null;
  352. }
  353. ICardEffect GetDetailEffect(EffectTiming timing)
  354. {
  355. if (timing == EffectTiming.None)
  356. {
  357. return PermanentEffectFactory.AddDetailClass(selectedPermanent, "[When Attacking] Lose 3 Memory", true, activateClass);
  358. }
  359. return null;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. return cardEffects;
  366. }
  367. }
  368. }