BT12_015.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_015 : 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.OnDeclaration)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Your [Takuya Kanbara] digivolves to this card", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Hand][Main] Place 1 [Agunimon] and 1 [BurningGreymon] from your trash under 1 of your [Takuya Kanbara] cards in any order and digivolve into this card as if the Tamer is a level 4 red Digimon for the digivolution cost.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource != null)
  25. {
  26. if (cardSource.Owner == card.Owner)
  27. {
  28. if (cardSource.CardNames.Contains("Agunimon"))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition1(CardSource cardSource)
  37. {
  38. if (cardSource != null)
  39. {
  40. if (cardSource.Owner == card.Owner)
  41. {
  42. if (cardSource.CardNames.Contains("BurningGreymon"))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanSelectPermanentCondition(Permanent permanent)
  51. {
  52. if (permanent != null)
  53. {
  54. if (permanent.TopCard != null)
  55. {
  56. if (permanent.TopCard.Owner == card.Owner)
  57. {
  58. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  59. {
  60. if (!permanent.IsToken)
  61. {
  62. if (permanent.TopCard.CardNames.Contains("Takuya Kanbara"))
  63. {
  64. return true;
  65. }
  66. if (permanent.TopCard.CardNames.Contains("TakuyaKanbara"))
  67. {
  68. return true;
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. if (card.Owner.HandCards.Contains(card))
  80. {
  81. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  82. {
  83. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  84. {
  85. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  95. {
  96. if (card.Owner.HandCards.Contains(card))
  97. {
  98. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  99. {
  100. Permanent selectedPermanent = null;
  101. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectPermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: maxCount,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: SelectPermanentCoroutine,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Select 1 [Takuya Kanbara].", "The opponent is selecting 1 [Takuya Kanbara].");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  118. {
  119. selectedPermanent = permanent;
  120. yield return null;
  121. }
  122. if (selectedPermanent != null)
  123. {
  124. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)))
  125. {
  126. bool digivolve = false;
  127. maxCount = 2;
  128. if (card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) < maxCount)
  129. {
  130. maxCount = card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource));
  131. }
  132. List<CardSource> selectedCards = new List<CardSource>();
  133. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  134. selectCardEffect.SetUp(
  135. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource),
  136. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  137. canEndSelectCondition: CanEndSelectCondition,
  138. canNoSelect: () => false,
  139. selectCardCoroutine: SelectCardCoroutine,
  140. afterSelectCardCoroutine: null,
  141. message: "Select cards to place on the bottom of Digivolution cards\n(cards will be placed in the digivolution cards so that cards with lower numbers are on top).",
  142. maxCount: maxCount,
  143. canEndNotMax: false,
  144. isShowOpponent: true,
  145. mode: SelectCardEffect.Mode.Custom,
  146. root: SelectCardEffect.Root.Trash,
  147. customRootCardList: null,
  148. canLookReverseCard: true,
  149. selectPlayer: card.Owner,
  150. cardEffect: activateClass);
  151. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  152. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  153. {
  154. if (cardSources.Count(CanSelectCardCondition) >= 1)
  155. {
  156. if (CanSelectCardCondition(cardSource))
  157. {
  158. return false;
  159. }
  160. }
  161. if (cardSources.Count(CanSelectCardCondition1) >= 1)
  162. {
  163. if (CanSelectCardCondition1(cardSource))
  164. {
  165. return false;
  166. }
  167. }
  168. return true;
  169. }
  170. bool CanEndSelectCondition(List<CardSource> cardSources)
  171. {
  172. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  173. {
  174. if (cardSources.Count(CanSelectCardCondition) == 0)
  175. {
  176. return false;
  177. }
  178. }
  179. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  180. {
  181. if (cardSources.Count(CanSelectCardCondition1) == 0)
  182. {
  183. return false;
  184. }
  185. }
  186. if (cardSources.Count(CanSelectCardCondition) >= 2)
  187. {
  188. return false;
  189. }
  190. if (cardSources.Count(CanSelectCardCondition1) >= 2)
  191. {
  192. return false;
  193. }
  194. return true;
  195. }
  196. IEnumerator SelectCardCoroutine(CardSource cardSource)
  197. {
  198. selectedCards.Add(cardSource);
  199. yield return null;
  200. }
  201. if (selectedCards.Count >= 1)
  202. {
  203. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  204. if (selectedCards.Count == 2)
  205. {
  206. digivolve = true;
  207. }
  208. }
  209. if (digivolve)
  210. {
  211. #region 1
  212. CardSource topCard = selectedPermanent.TopCard;
  213. #region 2
  214. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  215. changeCardColorClass.SetUpICardEffect($"Treated as red", CanUseCondition1, card);
  216. changeCardColorClass.SetUpChangeCardColorClass(ChangeCardColors: ChangeCardColors);
  217. changeCardColorClass.SetNotShowUI(true);
  218. bool CanUseCondition1(Hashtable hashtable)
  219. {
  220. if (selectedPermanent.TopCard != null)
  221. {
  222. if (card.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  223. {
  224. if (topCard == selectedPermanent.TopCard)
  225. {
  226. return true;
  227. }
  228. }
  229. }
  230. return false;
  231. }
  232. List<CardColor> ChangeCardColors(CardSource cardSource, List<CardColor> CardColors)
  233. {
  234. if (cardSource == selectedPermanent.TopCard)
  235. {
  236. CardColors.Add(CardColor.Red);
  237. }
  238. return CardColors;
  239. }
  240. #endregion
  241. #region 3
  242. ChangePermanentLevelClass changePermanentLevelClass = new ChangePermanentLevelClass();
  243. changePermanentLevelClass.SetUpICardEffect($"Treated as level 4", CanUseCondition1, card);
  244. changePermanentLevelClass.SetUpChangePermanentLevelClass(GetLevel: GetLevel);
  245. changePermanentLevelClass.SetNotShowUI(true);
  246. int GetLevel(Permanent permanent, int level)
  247. {
  248. if (selectedPermanent.TopCard != null)
  249. {
  250. if (permanent == selectedPermanent)
  251. {
  252. level = 4;
  253. }
  254. }
  255. return level;
  256. }
  257. #endregion
  258. #region 4
  259. TreatAsDigimonClass treatAsDigimonClass = new TreatAsDigimonClass();
  260. treatAsDigimonClass.SetUpICardEffect($"Treated as Digimon", CanUseCondition1, card);
  261. treatAsDigimonClass.SetUpTreatAsDigimonClass(permanentCondition: PermanentCondition);
  262. treatAsDigimonClass.SetNotShowUI(true);
  263. bool PermanentCondition(Permanent permanent)
  264. {
  265. if (selectedPermanent.TopCard != null)
  266. {
  267. if (permanent == selectedPermanent)
  268. {
  269. return true;
  270. }
  271. }
  272. return false;
  273. }
  274. #endregion
  275. #region 5
  276. DontHaveDPClass dontHaveDPClass = new DontHaveDPClass();
  277. dontHaveDPClass.SetUpICardEffect("Don't have DP", CanUseCondition1, card);
  278. dontHaveDPClass.SetUpDontHaveDPClass(PermanentCondition: PermanentCondition);
  279. dontHaveDPClass.SetNotShowUI(true);
  280. #endregion
  281. List<Func<EffectTiming, ICardEffect>> GetCardEffects = new List<Func<EffectTiming, ICardEffect>>()
  282. {
  283. (_timing) => changeCardColorClass,
  284. (_timing) => changePermanentLevelClass,
  285. (_timing) => treatAsDigimonClass,
  286. (_timing) => dontHaveDPClass,
  287. };
  288. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in GetCardEffects)
  289. {
  290. card.Owner.PermanentEffects.Add(GetCardEffect);
  291. }
  292. #endregion
  293. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true, activateClass))
  294. {
  295. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  296. cardSources: new List<CardSource>() { card },
  297. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  298. payCost: true,
  299. targetPermanent: selectedPermanent,
  300. isTapped: false,
  301. root: SelectCardEffect.Root.Hand,
  302. activateETB: true).PlayCard());
  303. }
  304. #region 6
  305. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in GetCardEffects)
  306. {
  307. card.Owner.PermanentEffects.Remove(GetCardEffect);
  308. }
  309. #endregion
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. if (timing == EffectTiming.OnDestroyedAnyone)
  318. {
  319. ActivateClass activateClass = new ActivateClass();
  320. activateClass.SetUpICardEffect("Return 1 [Takuya Kanbara] from trash to hand", CanUseCondition, card);
  321. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  322. cardEffects.Add(activateClass);
  323. string EffectDiscription()
  324. {
  325. return "[On Deletion] Return 1[Takuya Kanbara] card from your trash to your hand.";
  326. }
  327. bool CanSelectCardCondition(CardSource cardSource)
  328. {
  329. if (cardSource != null)
  330. {
  331. if (cardSource.Owner == card.Owner)
  332. {
  333. if (cardSource.CardNames.Contains("Takuya Kanbara"))
  334. {
  335. return true;
  336. }
  337. if (cardSource.CardNames.Contains("TakuyaKanbara"))
  338. {
  339. return true;
  340. }
  341. }
  342. }
  343. return false;
  344. }
  345. bool CanUseCondition(Hashtable hashtable)
  346. {
  347. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  348. }
  349. bool CanActivateCondition(Hashtable hashtable)
  350. {
  351. if (CardEffectCommons.IsExistOnTrash(card))
  352. {
  353. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  354. {
  355. return true;
  356. }
  357. }
  358. return false;
  359. }
  360. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  361. {
  362. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  363. {
  364. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  365. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  366. selectCardEffect.SetUp(
  367. canTargetCondition: CanSelectCardCondition,
  368. canTargetCondition_ByPreSelecetedList: null,
  369. canEndSelectCondition: null,
  370. canNoSelect: () => false,
  371. selectCardCoroutine: null,
  372. afterSelectCardCoroutine: null,
  373. message: "Select 1 [Takuya Kanbara] to add to your hand.",
  374. maxCount: maxCount,
  375. canEndNotMax: false,
  376. isShowOpponent: true,
  377. mode: SelectCardEffect.Mode.AddHand,
  378. root: SelectCardEffect.Root.Trash,
  379. customRootCardList: null,
  380. canLookReverseCard: true,
  381. selectPlayer: card.Owner,
  382. cardEffect: activateClass);
  383. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  384. }
  385. }
  386. }
  387. return cardEffects;
  388. }
  389. }
  390. }