BT16_069.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_069 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Gesomon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  20. digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Trash sources and give effects.", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return
  33. "[On Play] If [Gesomon] or [X-Antibody] is in this Digimon's digivolution cards, trash the bottom 3 cards under 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers without cards under it can't suspend until the end of their turn.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  38. }
  39. bool SelectSourceCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.EqualsCardName("Gesomon") || cardSource.CardNames.Contains("X Antibody") ||
  42. cardSource.CardNames.Contains("XAntibody");
  43. }
  44. bool CanSelectPermanentCondition(Permanent permanent)
  45. {
  46. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  47. {
  48. if (permanent.IsDigimon || permanent.IsTamer)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanSelectTrashSourceCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  58. {
  59. if (permanent.IsDigimon || permanent.IsTamer)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanSelectCardCondition(CardSource cardSource)
  67. {
  68. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  69. }
  70. bool CanSelectPermanentToNoSuspendCondition(Permanent permanent)
  71. {
  72. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  73. {
  74. if (permanent.IsDigimon || permanent.IsTamer)
  75. {
  76. if (permanent.HasNoDigivolutionCards)
  77. {
  78. return true;
  79. }
  80. }
  81. }
  82. return false;
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  87. {
  88. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTrashSourceCondition))
  89. {
  90. if (card.PermanentOfThisCard().DigivolutionCards.Some(SelectSourceCardCondition))
  91. {
  92. return true;
  93. }
  94. }
  95. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentToNoSuspendCondition))
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) &&
  105. card.PermanentOfThisCard().DigivolutionCards.Some(SelectSourceCardCondition))
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  108. permanentCondition: CanSelectTrashSourceCondition,
  109. cardCondition: CanSelectCardCondition,
  110. maxCount: 3,
  111. canNoTrash: false,
  112. isFromOnly1Permanent: true,
  113. activateClass: activateClass
  114. ));
  115. }
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentToNoSuspendCondition))
  117. {
  118. int maxCount = Math.Min(1,
  119. card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentToNoSuspendCondition));
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectPermanentToNoSuspendCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: maxCount,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: SelectPermanentCoroutine,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.",
  134. "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  137. {
  138. Permanent selectedPermanent = permanent;
  139. if (selectedPermanent != null)
  140. {
  141. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  142. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  143. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  144. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  145. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  148. .CreateDebuffEffect(selectedPermanent));
  149. }
  150. bool CanUseCondition1(Hashtable hashtable)
  151. {
  152. if (selectedPermanent.TopCard != null)
  153. {
  154. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. bool PermanentCondition(Permanent permanent)
  162. {
  163. if (permanent == selectedPermanent)
  164. {
  165. return true;
  166. }
  167. return false;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. #endregion
  175. #region When Digivolving
  176. if (timing == EffectTiming.OnEnterFieldAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect("Trash sources and give effects.", CanUseCondition, card);
  180. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  181. cardEffects.Add(activateClass);
  182. string EffectDiscription()
  183. {
  184. return
  185. "[When Digivolving] If [Gesomon] or [X-Antibody] is in this Digimon's digivolution cards, trash the bottom 3 cards under 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers without cards under it can't suspend until the end of their turn.";
  186. }
  187. bool CanUseCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  190. }
  191. bool SelectSourceCardCondition(CardSource cardSource)
  192. {
  193. return cardSource.EqualsCardName("Gesomon") || cardSource.CardNames.Contains("X Antibody") ||
  194. cardSource.CardNames.Contains("XAntibody");
  195. }
  196. bool CanSelectPermanentCondition(Permanent permanent)
  197. {
  198. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  199. {
  200. if (permanent.IsDigimon || permanent.IsTamer)
  201. {
  202. return true;
  203. }
  204. }
  205. return false;
  206. }
  207. bool CanSelectTrashSourceCondition(Permanent permanent)
  208. {
  209. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  210. {
  211. if (permanent.IsDigimon || permanent.IsTamer)
  212. {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanSelectCardCondition(CardSource cardSource)
  219. {
  220. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  221. }
  222. bool CanSelectPermanentToNoSuspendCondition(Permanent permanent)
  223. {
  224. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  225. {
  226. if (permanent.IsDigimon || permanent.IsTamer)
  227. {
  228. if (permanent.HasNoDigivolutionCards)
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. return false;
  235. }
  236. bool CanActivateCondition(Hashtable hashtable)
  237. {
  238. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  239. {
  240. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTrashSourceCondition))
  241. {
  242. if (card.PermanentOfThisCard().DigivolutionCards.Some(SelectSourceCardCondition))
  243. {
  244. return true;
  245. }
  246. }
  247. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentToNoSuspendCondition))
  248. {
  249. return true;
  250. }
  251. }
  252. return false;
  253. }
  254. IEnumerator ActivateCoroutine(Hashtable hashtable)
  255. {
  256. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) &&
  257. card.PermanentOfThisCard().DigivolutionCards.Some(SelectSourceCardCondition))
  258. {
  259. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  260. permanentCondition: CanSelectTrashSourceCondition,
  261. cardCondition: CanSelectCardCondition,
  262. maxCount: 3,
  263. canNoTrash: false,
  264. isFromOnly1Permanent: true,
  265. activateClass: activateClass
  266. ));
  267. }
  268. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentToNoSuspendCondition))
  269. {
  270. int maxCount = Math.Min(1,
  271. card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentToNoSuspendCondition));
  272. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  273. selectPermanentEffect.SetUp(
  274. selectPlayer: card.Owner,
  275. canTargetCondition: CanSelectPermanentToNoSuspendCondition,
  276. canTargetCondition_ByPreSelecetedList: null,
  277. canEndSelectCondition: null,
  278. maxCount: maxCount,
  279. canNoSelect: false,
  280. canEndNotMax: false,
  281. selectPermanentCoroutine: SelectPermanentCoroutine,
  282. afterSelectPermanentCoroutine: null,
  283. mode: SelectPermanentEffect.Mode.Custom,
  284. cardEffect: activateClass);
  285. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer that will get unable to suspend.",
  286. "The opponent is selecting 1 Digimon or Tamer that will get unable to suspend.");
  287. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  288. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  289. {
  290. Permanent selectedPermanent = permanent;
  291. if (selectedPermanent != null)
  292. {
  293. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  294. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  295. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  296. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  297. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  298. {
  299. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  300. .CreateDebuffEffect(selectedPermanent));
  301. }
  302. bool CanUseCondition1(Hashtable hashtable)
  303. {
  304. if (selectedPermanent.TopCard != null)
  305. {
  306. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  307. {
  308. return true;
  309. }
  310. }
  311. return false;
  312. }
  313. bool PermanentCondition(Permanent permanent)
  314. {
  315. if (permanent == selectedPermanent)
  316. {
  317. return true;
  318. }
  319. return false;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. #endregion
  327. #region Inherit
  328. if (timing == EffectTiming.OnAllyAttack)
  329. {
  330. ActivateClass activateClass = new ActivateClass();
  331. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  332. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  333. activateClass.SetIsInheritedEffect(true);
  334. activateClass.SetHashString("DrawTrashBT16_066");
  335. cardEffects.Add(activateClass);
  336. string EffectDiscription()
  337. {
  338. return
  339. "[When Attacking] [Once Per Turn] Trigger <Draw 1>. (Draw 1 cards from your deck.) Then trash 1 card from your hand.";
  340. }
  341. bool CanUseCondition(Hashtable hashtable)
  342. {
  343. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  344. }
  345. bool CanActivateCondition(Hashtable hashtable)
  346. {
  347. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  348. }
  349. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  350. {
  351. if (card.Owner.LibraryCards.Count >= 1)
  352. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  353. if (card.Owner.HandCards.Count >= 1)
  354. {
  355. int discardCount = 1;
  356. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  357. selectHandEffect.SetUp(
  358. selectPlayer: card.Owner,
  359. canTargetCondition: (cardSource) => true,
  360. canTargetCondition_ByPreSelecetedList: null,
  361. canEndSelectCondition: null,
  362. maxCount: discardCount,
  363. canNoSelect: false,
  364. canEndNotMax: false,
  365. isShowOpponent: true,
  366. selectCardCoroutine: null,
  367. afterSelectCardCoroutine: null,
  368. mode: SelectHandEffect.Mode.Discard,
  369. cardEffect: activateClass);
  370. yield return StartCoroutine(selectHandEffect.Activate());
  371. }
  372. }
  373. }
  374. #endregion
  375. return cardEffects;
  376. }
  377. }
  378. }