BT17_075.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT17
  7. {
  8. public class BT17_075 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return (targetPermanent.TopCard.EqualsCardName("Eosmon") && targetPermanent.TopCard.Level == 4);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Play Tamer then De-Digivolve 1 on play", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  35. EffectDiscription());
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return
  40. "[On Play] Your opponent may play 1 Tamer card from their hand without paying the cost. If they don't, you may play 1 white Tamer card with a play cost of 4 or less from your hand without paying the cost. Then, <De-Digivolve1> 1 of your opponent's Digimon for every 2 Tamers.";
  41. }
  42. bool CanSelectTamerOpponentCondition(CardSource cardSource)
  43. {
  44. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  45. cardEffect: activateClass,
  46. root: SelectCardEffect.Root.Hand, isBreedingArea: false, isPlayOption: false))
  47. if (cardSource.IsTamer)
  48. return true;
  49. return false;
  50. }
  51. bool CanSelectWhiteTamerCondition(CardSource cardSource)
  52. {
  53. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  54. cardEffect: activateClass,
  55. root: SelectCardEffect.Root.Hand, isBreedingArea: false, isPlayOption: false))
  56. {
  57. if (cardSource.IsTamer)
  58. if (cardSource.HasCardColor(CardColor.White) && cardSource.GetCostItself <= 4)
  59. return true;
  60. }
  61. return false;
  62. }
  63. bool CheckForTamersOnFieldCondition(Permanent permanent)
  64. {
  65. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  66. {
  67. if (permanent.IsTamer)
  68. {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. bool CanSelectPermanentDigimonCondition(Permanent permanent)
  75. {
  76. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  77. }
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. return (CardEffectCommons.CanTriggerOnPlay(hashtable, card));
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. return (CardEffectCommons.IsExistOnBattleAreaDigimon(card));
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable hashtable)
  87. {
  88. bool hasSelectedTamerOpponent = false;
  89. #region Opponent has tamer to play
  90. if (card.Owner.Enemy.HandCards.Count(CanSelectTamerOpponentCondition) > 0)
  91. {
  92. List<CardSource> selectedCardsOpponent = new List<CardSource>();
  93. int maxCount = Math.Min(1, card.Owner.Enemy.HandCards.Count(CanSelectTamerOpponentCondition));
  94. SelectHandEffect selectHandEffectOpponent = GManager.instance.GetComponent<SelectHandEffect>();
  95. selectHandEffectOpponent.SetUp(
  96. selectPlayer: card.Owner.Enemy,
  97. canTargetCondition: CanSelectTamerOpponentCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. maxCount: maxCount,
  101. canNoSelect: true,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. selectCardCoroutine: SelectCardCoroutineOpponent,
  105. afterSelectCardCoroutine: null,
  106. mode: SelectHandEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectHandEffectOpponent.SetUpCustomMessage("Select 1 Tamer to play.",
  109. "The opponent is selecting 1 Tamer to play.");
  110. selectHandEffectOpponent.SetUpCustomMessage_ShowCard("Played Card");
  111. yield return ContinuousController.instance.StartCoroutine(selectHandEffectOpponent.Activate());
  112. IEnumerator SelectCardCoroutineOpponent(CardSource cardSource)
  113. {
  114. if (cardSource != null)
  115. {
  116. selectedCardsOpponent.Add(cardSource);
  117. hasSelectedTamerOpponent = true;
  118. }
  119. yield return null;
  120. }
  121. if (hasSelectedTamerOpponent)
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(
  124. CardEffectCommons.PlayPermanentCards(
  125. cardSources: selectedCardsOpponent,
  126. activateClass: activateClass,
  127. payCost: false,
  128. isTapped: false,
  129. root: SelectCardEffect.Root.Hand,
  130. activateETB: true));
  131. }
  132. }
  133. #endregion
  134. #region I play tamer
  135. if(!hasSelectedTamerOpponent)
  136. {
  137. if (card.Owner.HandCards.Count > 0)
  138. {
  139. List<CardSource> selectedCards = new List<CardSource>();
  140. bool hasSelectedWhiteTamer = false;
  141. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectWhiteTamerCondition));
  142. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  143. selectHandEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: CanSelectWhiteTamerCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: true,
  150. canEndNotMax: false,
  151. isShowOpponent: true,
  152. selectCardCoroutine: SelectCardCoroutine,
  153. afterSelectCardCoroutine: null,
  154. mode: SelectHandEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  157. "The opponent is selecting 1 card to play.");
  158. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  159. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  160. IEnumerator SelectCardCoroutine(CardSource cardSource)
  161. {
  162. selectedCards.Add(cardSource);
  163. hasSelectedWhiteTamer = true;
  164. yield return null;
  165. }
  166. if (hasSelectedWhiteTamer)
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(
  169. CardEffectCommons.PlayPermanentCards(
  170. cardSources: selectedCards,
  171. activateClass: activateClass,
  172. payCost: false,
  173. isTapped: false,
  174. root: SelectCardEffect.Root.Hand,
  175. activateETB: true));
  176. }
  177. }
  178. }
  179. #endregion
  180. #region De Digivolve
  181. //then De-Digivolve statement
  182. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentDigimonCondition))
  183. {
  184. int totalTamers = CardEffectCommons.MatchConditionPermanentCount(CheckForTamersOnFieldCondition);
  185. int maxCountDeDigivolve = Math.Max(0, Mathf.FloorToInt(totalTamers / 2));
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanentDigimonCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: 1,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: SelectPermanentCoroutine,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Custom,
  198. cardEffect: activateClass);
  199. selectPermanentEffect.SetUpCustomMessage("Select Digimon to De-Digivolve.", "The opponent is selecting Digimon to De-Digivolve.");
  200. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  201. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  202. {
  203. Permanent selectedPermanent = permanent;
  204. if (selectedPermanent != null)
  205. {
  206. for(int i = 0; i < maxCountDeDigivolve; i++)
  207. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  208. }
  209. }
  210. }
  211. #endregion
  212. }
  213. }
  214. #endregion
  215. #region When Digivolving
  216. if (timing == EffectTiming.OnEnterFieldAnyone)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("Play Tamer then De-Digivolve 1 on play", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  221. EffectDiscription());
  222. cardEffects.Add(activateClass);
  223. string EffectDiscription()
  224. {
  225. return
  226. "[When Digivolving] Your opponent may play 1 Tamer card from their hand without paying the cost. If they don't, you may play 1 white Tamer card with a play cost of 4 or less from your hand without paying the cost. Then, <De-Digivolve1> 1 of your opponent's Digimon for every 2 Tamers.";
  227. }
  228. bool CanSelectTamerOpponentCondition(CardSource cardSource)
  229. {
  230. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  231. cardEffect: activateClass,
  232. root: SelectCardEffect.Root.Hand, isBreedingArea: false, isPlayOption: false))
  233. if (cardSource.IsTamer)
  234. return true;
  235. return false;
  236. }
  237. bool CanSelectWhiteTamerCondition(CardSource cardSource)
  238. {
  239. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  240. cardEffect: activateClass,
  241. root: SelectCardEffect.Root.Hand, isBreedingArea: false, isPlayOption: false))
  242. {
  243. if (cardSource.IsTamer)
  244. if (cardSource.HasCardColor(CardColor.White) && cardSource.GetCostItself <= 4)
  245. return true;
  246. }
  247. return false;
  248. }
  249. bool CheckForTamersOnFieldCondition(Permanent permanent)
  250. {
  251. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  252. {
  253. if (permanent.IsTamer)
  254. {
  255. return true;
  256. }
  257. }
  258. return false;
  259. }
  260. bool CanSelectPermanentDigimonCondition(Permanent permanent)
  261. {
  262. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  263. }
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. return (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card));
  267. }
  268. bool CanActivateCondition(Hashtable hashtable)
  269. {
  270. return (CardEffectCommons.IsExistOnBattleAreaDigimon(card));
  271. }
  272. IEnumerator ActivateCoroutine(Hashtable hashtable)
  273. {
  274. bool hasSelectedTamerOpponent = false;
  275. #region Opponent has tamer to play
  276. if (card.Owner.Enemy.HandCards.Count(CanSelectTamerOpponentCondition) > 0)
  277. {
  278. List<CardSource> selectedCardsOpponent = new List<CardSource>();
  279. int maxCount = Math.Min(1, card.Owner.Enemy.HandCards.Count(CanSelectTamerOpponentCondition));
  280. SelectHandEffect selectHandEffectOpponent = GManager.instance.GetComponent<SelectHandEffect>();
  281. selectHandEffectOpponent.SetUp(
  282. selectPlayer: card.Owner.Enemy,
  283. canTargetCondition: CanSelectTamerOpponentCondition,
  284. canTargetCondition_ByPreSelecetedList: null,
  285. canEndSelectCondition: null,
  286. maxCount: maxCount,
  287. canNoSelect: true,
  288. canEndNotMax: false,
  289. isShowOpponent: true,
  290. selectCardCoroutine: SelectCardCoroutineOpponent,
  291. afterSelectCardCoroutine: null,
  292. mode: SelectHandEffect.Mode.Custom,
  293. cardEffect: activateClass);
  294. selectHandEffectOpponent.SetUpCustomMessage("Select 1 Tamer to play.",
  295. "The opponent is selecting 1 Tamer to play.");
  296. selectHandEffectOpponent.SetUpCustomMessage_ShowCard("Played Card");
  297. yield return ContinuousController.instance.StartCoroutine(selectHandEffectOpponent.Activate());
  298. IEnumerator SelectCardCoroutineOpponent(CardSource cardSource)
  299. {
  300. if (cardSource != null)
  301. {
  302. selectedCardsOpponent.Add(cardSource);
  303. hasSelectedTamerOpponent = true;
  304. }
  305. yield return null;
  306. }
  307. if (hasSelectedTamerOpponent)
  308. {
  309. yield return ContinuousController.instance.StartCoroutine(
  310. CardEffectCommons.PlayPermanentCards(
  311. cardSources: selectedCardsOpponent,
  312. activateClass: activateClass,
  313. payCost: false,
  314. isTapped: false,
  315. root: SelectCardEffect.Root.Hand,
  316. activateETB: true));
  317. }
  318. }
  319. #endregion
  320. #region I play tamer
  321. if (!hasSelectedTamerOpponent)
  322. {
  323. if (card.Owner.HandCards.Count > 0)
  324. {
  325. List<CardSource> selectedCards = new List<CardSource>();
  326. bool hasSelectedWhiteTamer = false;
  327. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectWhiteTamerCondition));
  328. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  329. selectHandEffect.SetUp(
  330. selectPlayer: card.Owner,
  331. canTargetCondition: CanSelectWhiteTamerCondition,
  332. canTargetCondition_ByPreSelecetedList: null,
  333. canEndSelectCondition: null,
  334. maxCount: maxCount,
  335. canNoSelect: true,
  336. canEndNotMax: false,
  337. isShowOpponent: true,
  338. selectCardCoroutine: SelectCardCoroutine,
  339. afterSelectCardCoroutine: null,
  340. mode: SelectHandEffect.Mode.Custom,
  341. cardEffect: activateClass);
  342. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  343. "The opponent is selecting 1 card to play.");
  344. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  345. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  346. IEnumerator SelectCardCoroutine(CardSource cardSource)
  347. {
  348. selectedCards.Add(cardSource);
  349. hasSelectedWhiteTamer = true;
  350. yield return null;
  351. }
  352. if (hasSelectedWhiteTamer)
  353. {
  354. yield return ContinuousController.instance.StartCoroutine(
  355. CardEffectCommons.PlayPermanentCards(
  356. cardSources: selectedCards,
  357. activateClass: activateClass,
  358. payCost: false,
  359. isTapped: false,
  360. root: SelectCardEffect.Root.Hand,
  361. activateETB: true));
  362. }
  363. }
  364. }
  365. #endregion
  366. #region De Digivolve
  367. //then De-Digivolve statement
  368. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentDigimonCondition))
  369. {
  370. int totalTamers = CardEffectCommons.MatchConditionPermanentCount(CheckForTamersOnFieldCondition);
  371. int maxCountDeDigivolve = Math.Max(0, Mathf.FloorToInt(totalTamers / 2));
  372. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  373. selectPermanentEffect.SetUp(
  374. selectPlayer: card.Owner,
  375. canTargetCondition: CanSelectPermanentDigimonCondition,
  376. canTargetCondition_ByPreSelecetedList: null,
  377. canEndSelectCondition: null,
  378. maxCount: 1,
  379. canNoSelect: false,
  380. canEndNotMax: false,
  381. selectPermanentCoroutine: SelectPermanentCoroutine,
  382. afterSelectPermanentCoroutine: null,
  383. mode: SelectPermanentEffect.Mode.Custom,
  384. cardEffect: activateClass);
  385. selectPermanentEffect.SetUpCustomMessage("Select Digimon to De-Digivolve.", "The opponent is selecting Digimon to De-Digivolve.");
  386. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  387. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  388. {
  389. Permanent selectedPermanent = permanent;
  390. if (selectedPermanent != null)
  391. {
  392. for (int i = 0; i < maxCountDeDigivolve; i++)
  393. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  394. }
  395. }
  396. }
  397. #endregion
  398. }
  399. }
  400. #endregion
  401. #region Inherited Effect - Opponent's Turn
  402. if (timing == EffectTiming.OnAllyAttack)
  403. {
  404. ActivateClass activateClass = new ActivateClass();
  405. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  406. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  407. EffectDiscription());
  408. activateClass.SetIsInheritedEffect(true);
  409. activateClass.SetHashString("Eosmon_SwitchTarget_BT17_075");
  410. cardEffects.Add(activateClass);
  411. string EffectDiscription()
  412. {
  413. return (
  414. "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, you may switch the attack target to 1 of your [Eosmon].");
  415. }
  416. bool IsOpponentAttacking(Permanent permanent)
  417. {
  418. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  419. }
  420. bool CanSelectPermanentCondition(Permanent permanent)
  421. {
  422. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  423. if (permanent.TopCard.EqualsCardName("Eosmon"))
  424. return true;
  425. return false;
  426. }
  427. bool CanUseCondition(Hashtable hashtable)
  428. {
  429. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentAttacking);
  430. }
  431. bool CanActivateCondition(Hashtable hashtable)
  432. {
  433. if (CardEffectCommons.IsExistOnBattleArea(card))
  434. return CardEffectCommons.IsOpponentTurn(card);
  435. return false;
  436. }
  437. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  438. {
  439. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  440. {
  441. int maxCount = Math.Min(1,
  442. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  443. SelectPermanentEffect selectPermanentEffect =
  444. GManager.instance.GetComponent<SelectPermanentEffect>();
  445. selectPermanentEffect.SetUp(
  446. selectPlayer: card.Owner,
  447. canTargetCondition: CanSelectPermanentCondition,
  448. canTargetCondition_ByPreSelecetedList: null,
  449. canEndSelectCondition: null,
  450. maxCount: maxCount,
  451. canNoSelect: false,
  452. canEndNotMax: false,
  453. selectPermanentCoroutine: SelectPermanentCoroutine,
  454. afterSelectPermanentCoroutine: null,
  455. mode: SelectPermanentEffect.Mode.Custom,
  456. cardEffect: activateClass);
  457. selectPermanentEffect.SetUpCustomMessage("Select 1 card to be targeted by opponent's attack.", "Opponent is selecting a card to be targeted.");
  458. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  459. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  460. {
  461. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  462. activateClass,
  463. false,
  464. permanent));
  465. }
  466. }
  467. }
  468. }
  469. #endregion
  470. return cardEffects;
  471. }
  472. }
  473. }