BT17_014.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_014 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Hand - Main
  13. if (timing == EffectTiming.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Your [Takuya Kanbara] digivolves into this card", CanUseCondition,
  17. card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return
  23. "[Hand] [Main] By placing 1 [Agunimon] and [BurningGreymon] from your trash under 1 of your [Takuya Kanbara]s, digivolve it into this card as if that card is a level 4 red Digimon for a digivolution cost of 3.";
  24. }
  25. bool CanSelectAgunimonCardCondition(CardSource cardSource)
  26. {
  27. if (cardSource != null)
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (cardSource.EqualsCardName("Agunimon"))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanSelectBurningGreymonCardCondition(CardSource cardSource)
  40. {
  41. if (cardSource != null)
  42. {
  43. if (cardSource.Owner == card.Owner)
  44. {
  45. if (cardSource.EqualsCardName("BurningGreymon"))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. if (permanent != null)
  56. {
  57. if (permanent.TopCard != null)
  58. {
  59. if (permanent.TopCard.Owner == card.Owner)
  60. {
  61. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  62. {
  63. if (!permanent.IsToken)
  64. {
  65. if (permanent.TopCard.EqualsCardName("Takuya Kanbara"))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. if (card.Owner.HandCards.Contains(card))
  79. {
  80. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  81. {
  82. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  83. CanSelectAgunimonCardCondition))
  84. {
  85. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  86. CanSelectBurningGreymonCardCondition))
  87. {
  88. return true;
  89. }
  90. }
  91. }
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. if (card.Owner.HandCards.Contains(card))
  98. {
  99. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  100. {
  101. Permanent selectedPermanent = null;
  102. int maxCount = Math.Min(1,
  103. card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  104. SelectPermanentEffect selectPermanentEffect =
  105. GManager.instance.GetComponent<SelectPermanentEffect>();
  106. selectPermanentEffect.SetUp(
  107. selectPlayer: card.Owner,
  108. canTargetCondition: CanSelectPermanentCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. maxCount: maxCount,
  112. canNoSelect: false,
  113. canEndNotMax: false,
  114. selectPermanentCoroutine: SelectPermanentCoroutine,
  115. afterSelectPermanentCoroutine: null,
  116. mode: SelectPermanentEffect.Mode.Custom,
  117. cardEffect: activateClass);
  118. selectPermanentEffect.SetUpCustomMessage("Select 1 [Takuya Kanbara].",
  119. "The opponent is selecting 1 [Takuya Kanbara].");
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. selectedPermanent = permanent;
  124. yield return null;
  125. }
  126. if (selectedPermanent != null)
  127. {
  128. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  129. (cardSource) =>
  130. CanSelectAgunimonCardCondition(cardSource) ||
  131. CanSelectBurningGreymonCardCondition(cardSource)))
  132. {
  133. bool digivolve = false;
  134. maxCount = 2;
  135. if (card.Owner.TrashCards.Count((cardSource) =>
  136. CanSelectAgunimonCardCondition(cardSource) ||
  137. CanSelectBurningGreymonCardCondition(cardSource)) <
  138. maxCount)
  139. {
  140. maxCount = card.Owner.TrashCards.Count((cardSource) =>
  141. CanSelectAgunimonCardCondition(cardSource) ||
  142. CanSelectBurningGreymonCardCondition(cardSource));
  143. }
  144. List<CardSource> selectedCards = new List<CardSource>();
  145. SelectCardEffect selectCardEffect =
  146. GManager.instance.GetComponent<SelectCardEffect>();
  147. selectCardEffect.SetUp(
  148. canTargetCondition: (cardSource) =>
  149. CanSelectAgunimonCardCondition(cardSource) ||
  150. CanSelectBurningGreymonCardCondition(cardSource),
  151. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  152. canEndSelectCondition: CanEndSelectCondition,
  153. canNoSelect: () => false,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. message:
  157. "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).",
  158. maxCount: maxCount,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Trash,
  163. customRootCardList: null,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. yield return ContinuousController.instance.StartCoroutine(
  168. selectCardEffect.Activate());
  169. bool CanTargetConditionByPreSelectedList(List<CardSource> cardSources,
  170. CardSource cardSource)
  171. {
  172. if (cardSources.Count(CanSelectAgunimonCardCondition) >= 1)
  173. {
  174. if (CanSelectAgunimonCardCondition(cardSource))
  175. {
  176. return false;
  177. }
  178. }
  179. if (cardSources.Count(CanSelectBurningGreymonCardCondition) >= 1)
  180. {
  181. if (CanSelectBurningGreymonCardCondition(cardSource))
  182. {
  183. return false;
  184. }
  185. }
  186. return true;
  187. }
  188. bool CanEndSelectCondition(List<CardSource> cardSources)
  189. {
  190. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  191. CanSelectAgunimonCardCondition))
  192. {
  193. if (cardSources.Count(CanSelectAgunimonCardCondition) == 0)
  194. {
  195. return false;
  196. }
  197. }
  198. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card,
  199. CanSelectBurningGreymonCardCondition))
  200. {
  201. if (cardSources.Count(CanSelectBurningGreymonCardCondition) == 0)
  202. {
  203. return false;
  204. }
  205. }
  206. if (cardSources.Count(CanSelectAgunimonCardCondition) >= 2)
  207. {
  208. return false;
  209. }
  210. if (cardSources.Count(CanSelectBurningGreymonCardCondition) >= 2)
  211. {
  212. return false;
  213. }
  214. return true;
  215. }
  216. IEnumerator SelectCardCoroutine(CardSource cardSource)
  217. {
  218. selectedCards.Add(cardSource);
  219. yield return null;
  220. }
  221. if (selectedCards.Count >= 1)
  222. {
  223. yield return ContinuousController.instance.StartCoroutine(
  224. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  225. if (selectedCards.Count == 2)
  226. {
  227. digivolve = true;
  228. }
  229. }
  230. if (digivolve)
  231. {
  232. CardSource topCard = selectedPermanent.TopCard;
  233. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  234. changeCardColorClass.SetUpICardEffect($"Treated as red",
  235. CanUseChangeColorCondition,
  236. card);
  237. changeCardColorClass.SetUpChangeCardColorClass(
  238. ChangeCardColors: ChangeCardColors);
  239. changeCardColorClass.SetNotShowUI(true);
  240. bool CanUseChangeColorCondition(Hashtable ccHashtable)
  241. {
  242. if (selectedPermanent.TopCard != null)
  243. {
  244. if (card.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  245. {
  246. if (topCard == selectedPermanent.TopCard)
  247. {
  248. return true;
  249. }
  250. }
  251. }
  252. return false;
  253. }
  254. List<CardColor> ChangeCardColors(CardSource cardSource,
  255. List<CardColor> cardColors)
  256. {
  257. if (cardSource == selectedPermanent.TopCard)
  258. {
  259. cardColors.Add(CardColor.Red);
  260. }
  261. return cardColors;
  262. }
  263. ChangePermanentLevelClass changePermanentLevelClass =
  264. new ChangePermanentLevelClass();
  265. changePermanentLevelClass.SetUpICardEffect($"Treated as level 4",
  266. CanUseChangeColorCondition, card);
  267. changePermanentLevelClass.SetUpChangePermanentLevelClass(GetLevel: GetLevel);
  268. changePermanentLevelClass.SetNotShowUI(true);
  269. int GetLevel(Permanent permanent, int level)
  270. {
  271. if (selectedPermanent.TopCard != null)
  272. {
  273. if (permanent == selectedPermanent)
  274. {
  275. level = 4;
  276. }
  277. }
  278. return level;
  279. }
  280. TreatAsDigimonClass treatAsDigimonClass = new TreatAsDigimonClass();
  281. treatAsDigimonClass.SetUpICardEffect($"Treated as Digimon",
  282. CanUseChangeColorCondition,
  283. card);
  284. treatAsDigimonClass.SetUpTreatAsDigimonClass(
  285. permanentCondition: PermanentCondition);
  286. treatAsDigimonClass.SetNotShowUI(true);
  287. bool PermanentCondition(Permanent permanent)
  288. {
  289. if (selectedPermanent.TopCard != null)
  290. {
  291. if (permanent == selectedPermanent)
  292. {
  293. return true;
  294. }
  295. }
  296. return false;
  297. }
  298. DontHaveDPClass dontHaveDPClass = new DontHaveDPClass();
  299. dontHaveDPClass.SetUpICardEffect("Don't have DP", CanUseChangeColorCondition,
  300. card);
  301. dontHaveDPClass.SetUpDontHaveDPClass(PermanentCondition: PermanentCondition);
  302. dontHaveDPClass.SetNotShowUI(true);
  303. List<Func<EffectTiming, ICardEffect>> getCardEffects =
  304. new List<Func<EffectTiming, ICardEffect>>()
  305. {
  306. _ => changeCardColorClass,
  307. _ => changePermanentLevelClass,
  308. _ => treatAsDigimonClass,
  309. _ => dontHaveDPClass,
  310. };
  311. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  312. {
  313. card.Owner.PermanentEffects.Add(getCardEffect);
  314. }
  315. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true,
  316. activateClass))
  317. {
  318. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  319. targetPermanent: selectedPermanent,
  320. cardCondition: source => source == card,
  321. payCost: true,
  322. reduceCostTuple: null,
  323. fixedCostTuple: (fixedCost: 3, fixedCostCardCondition: null),
  324. ignoreDigivolutionRequirementFixedCost: -1,
  325. isHand: true,
  326. activateClass: activateClass,
  327. successProcess:null,
  328. failedProcess: DigivolvedFailed(),
  329. isOptional: false));
  330. }
  331. else
  332. {
  333. yield return ContinuousController.instance.StartCoroutine("DigivolvedFailed");
  334. }
  335. IEnumerator DigivolvedFailed()
  336. {
  337. IDiscardHand discard = new IDiscardHand(card, hashtable);
  338. discard.Discard();
  339. yield return null;
  340. }
  341. foreach (Func<EffectTiming, ICardEffect> getCardEffect in getCardEffects)
  342. {
  343. card.Owner.PermanentEffects.Remove(getCardEffect);
  344. }
  345. }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. #endregion
  353. #region When Digivolving
  354. if (timing == EffectTiming.OnEnterFieldAnyone)
  355. {
  356. ActivateClass activateClass = new ActivateClass();
  357. activateClass.SetUpICardEffect(
  358. "Delete 1 Digimon with 6000 DP or less",
  359. CanUseCondition, card);
  360. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  361. EffectDescription());
  362. cardEffects.Add(activateClass);
  363. string EffectDescription()
  364. {
  365. return
  366. "[When Digivolving] Delete 1 of your opponent's Digimon with 6000 DP or less.";
  367. }
  368. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  369. {
  370. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  371. {
  372. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  373. {
  374. return true;
  375. }
  376. }
  377. return false;
  378. }
  379. bool CanUseCondition(Hashtable hashtable)
  380. {
  381. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  382. }
  383. bool CanActivateCondition(Hashtable hashtable)
  384. {
  385. if (CardEffectCommons.IsExistOnBattleArea(card))
  386. {
  387. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  388. {
  389. return true;
  390. }
  391. }
  392. return false;
  393. }
  394. IEnumerator ActivateCoroutine(Hashtable hashtable)
  395. {
  396. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  397. {
  398. int enemyCount = Math.Min(1,
  399. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  400. SelectPermanentEffect selectEnemyEffect =
  401. GManager.instance.GetComponent<SelectPermanentEffect>();
  402. selectEnemyEffect.SetUp(
  403. selectPlayer: card.Owner,
  404. canTargetCondition: CanSelectOpponentPermanentCondition,
  405. canTargetCondition_ByPreSelecetedList: null,
  406. canEndSelectCondition: null,
  407. maxCount: enemyCount,
  408. canNoSelect: false,
  409. canEndNotMax: false,
  410. selectPermanentCoroutine: null,
  411. afterSelectPermanentCoroutine: null,
  412. mode: SelectPermanentEffect.Mode.Destroy,
  413. cardEffect: activateClass);
  414. yield return ContinuousController.instance.StartCoroutine(selectEnemyEffect.Activate());
  415. }
  416. }
  417. }
  418. #endregion
  419. #region Your Turn - ESS
  420. if (timing == EffectTiming.None)
  421. {
  422. DisableEffectClass invalidationClass = new DisableEffectClass();
  423. invalidationClass.SetUpICardEffect("Ignore Security effects on Option cards", CanUseCondition, card);
  424. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  425. invalidationClass.SetIsInheritedEffect(true);
  426. cardEffects.Add(invalidationClass);
  427. bool CanUseCondition(Hashtable hashtable)
  428. {
  429. return true;
  430. }
  431. bool InvalidateCondition(ICardEffect cardEffect)
  432. {
  433. if (CardEffectCommons.IsExistOnBattleArea(card))
  434. {
  435. if (CardEffectCommons.IsOwnerTurn(card))
  436. {
  437. if (card.PermanentOfThisCard().TopCard.ContainsTraits("Hybrid") ||
  438. card.PermanentOfThisCard().TopCard.ContainsTraits("TenWarriors") ||
  439. card.PermanentOfThisCard().TopCard.ContainsTraits("Ten Warriors"))
  440. {
  441. if (cardEffect != null)
  442. {
  443. if (cardEffect.EffectSourceCard != null)
  444. {
  445. if (cardEffect.EffectSourceCard.IsOption)
  446. {
  447. if (cardEffect.IsSecurityEffect)
  448. {
  449. if (GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard())
  450. {
  451. return true;
  452. }
  453. }
  454. }
  455. }
  456. }
  457. }
  458. }
  459. }
  460. return false;
  461. }
  462. }
  463. #endregion
  464. return cardEffects;
  465. }
  466. }
  467. }