GesomonXAntibody_BT16_069.cs 20 KB

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