EX10_056.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Bagramon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_056 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DigiXros
  13. if (timing == EffectTiming.None)
  14. {
  15. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  16. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  17. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  18. addDigiXrosConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addDigiXrosConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. DigiXrosCondition GetDigiXros(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. if (cardSource != null)
  31. {
  32. if (cardSource.Owner == card.Owner)
  33. {
  34. if (cardSource.IsDigimon)
  35. {
  36. if (cardSource.CardTraits.Contains("BagraArmy"))
  37. {
  38. return true;
  39. }
  40. if (cardSource.CardTraits.Contains("Bagra Army"))
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "[Bagra Army] Digimon");
  50. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>();
  51. for (int i = 0; i < 2; i++)
  52. {
  53. elements.Add(element);
  54. }
  55. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  56. return digiXrosCondition;
  57. }
  58. return null;
  59. }
  60. }
  61. #endregion
  62. #region On Play
  63. if (timing == EffectTiming.OnEnterFieldAnyone)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect("Place 1 opponent digimon under a digimon or tamer", CanUseCondition, card);
  67. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  68. cardEffects.Add(activateClass);
  69. string EffectDiscription()
  70. {
  71. return "[On Play] You may place 1 of your opponent's Digimon as any of their other Digimon's bottom digivolution card or under any of their Tamers.";
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  76. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  77. }
  78. bool CanActivateCondition(Hashtable hashtable)
  79. {
  80. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  81. && HasValidEnemyPermanents();
  82. }
  83. bool HasValidEnemyPermanents()
  84. {
  85. int digimon = card.Owner.Enemy.GetBattleAreaDigimons().Count;
  86. int notOptions = card.Owner.Enemy.GetBattleAreaPermanents().Filter(x => !x.IsOption).Count;
  87. return digimon >= 1 &&
  88. notOptions >= 2;
  89. }
  90. bool IsEnemyDigimon(Permanent permanent)
  91. {
  92. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyDigimon))
  97. {
  98. Permanent selectedPermamentToSource = null;
  99. #region Select Enemy Digimon to add as Source
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: IsEnemyDigimon,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: 1,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: SelectPermanentCoroutine,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  114. {
  115. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  116. {
  117. selectedPermamentToSource = permanent;
  118. }
  119. yield return null;
  120. }
  121. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to move under a digimon/tamer", "The opponent is selecting 1 Digimon move under a digimon/tamer");
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. #endregion
  124. if (selectedPermamentToSource != null)
  125. {
  126. bool IsEnemyPermanent(Permanent permanent)
  127. {
  128. return (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  129. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card))
  130. && permanent != selectedPermamentToSource;
  131. }
  132. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  133. {
  134. Permanent selectedPermanent = null;
  135. #region Select Enemy Permanent to add source
  136. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  138. selectPermanentEffect1.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: IsEnemyPermanent,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: maxCount1,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: SelectPermanentCoroutine1,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  151. {
  152. selectedPermanent = permanent;
  153. yield return null;
  154. }
  155. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon or tamer to add the source card underneath", "The opponent is selecting 1 Digimon or tamer to add the source card underneath");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  157. #endregion
  158. if (selectedPermanent != null)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  161. permanentArrays: new List<Permanent[]>() { new Permanent[] { selectedPermamentToSource, selectedPermanent } },
  162. toTop: false,
  163. cardEffect: activateClass).PlacePermanentToDigivolutionCards());
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. #endregion
  171. #region When Digivolving
  172. if (timing == EffectTiming.OnEnterFieldAnyone)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Place 1 opponent digimon under a digimon or tamer", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[When Digivolving] You may place 1 of your opponent's Digimon as any of their other Digimon's bottom digivolution card or under any of their Tamers.";
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  185. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  190. && HasValidEnemyPermanents();
  191. }
  192. bool HasValidEnemyPermanents()
  193. {
  194. int digimon = card.Owner.Enemy.GetBattleAreaDigimons().Count;
  195. int notOptions = card.Owner.Enemy.GetBattleAreaPermanents().Filter(x => !x.IsOption).Count;
  196. return digimon >= 1 &&
  197. notOptions >= 2;
  198. }
  199. bool IsEnemyDigimon(Permanent permanent)
  200. {
  201. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable hashtable)
  204. {
  205. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyDigimon))
  206. {
  207. Permanent selectedPermamentToSource = null;
  208. #region Select Enemy Digimon to add as Source
  209. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  210. selectPermanentEffect.SetUp(
  211. selectPlayer: card.Owner,
  212. canTargetCondition: IsEnemyDigimon,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. maxCount: 1,
  216. canNoSelect: true,
  217. canEndNotMax: false,
  218. selectPermanentCoroutine: SelectPermanentCoroutine,
  219. afterSelectPermanentCoroutine: null,
  220. mode: SelectPermanentEffect.Mode.Custom,
  221. cardEffect: activateClass);
  222. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  223. {
  224. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  225. {
  226. selectedPermamentToSource = permanent;
  227. }
  228. yield return null;
  229. }
  230. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to move under a digimon/tamer", "The opponent is selecting 1 Digimon move under a digimon/tamer");
  231. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  232. #endregion
  233. if (selectedPermamentToSource != null)
  234. {
  235. bool IsEnemyPermanent(Permanent permanent)
  236. {
  237. return (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  238. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card))
  239. && permanent != selectedPermamentToSource;
  240. }
  241. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  242. {
  243. Permanent selectedPermanent = null;
  244. #region Select Enemy Permanent to add source
  245. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  246. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  247. selectPermanentEffect1.SetUp(
  248. selectPlayer: card.Owner,
  249. canTargetCondition: IsEnemyPermanent,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. maxCount: maxCount1,
  253. canNoSelect: true,
  254. canEndNotMax: false,
  255. selectPermanentCoroutine: SelectPermanentCoroutine1,
  256. afterSelectPermanentCoroutine: null,
  257. mode: SelectPermanentEffect.Mode.Custom,
  258. cardEffect: activateClass);
  259. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  260. {
  261. selectedPermanent = permanent;
  262. yield return null;
  263. }
  264. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon or tamer to add the source card underneath", "The opponent is selecting 1 Digimon or tamer to add the source card underneath");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  266. #endregion
  267. if (selectedPermanent != null)
  268. {
  269. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  270. permanentArrays: new List<Permanent[]>() { new Permanent[] { selectedPermamentToSource, selectedPermanent } },
  271. toTop: false,
  272. cardEffect: activateClass).PlacePermanentToDigivolutionCards());
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }
  279. #endregion
  280. #region All Turns - Once Per Turn
  281. #region Digivolving
  282. if (timing == EffectTiming.OnEnterFieldAnyone)
  283. {
  284. ActivateClass activateClass = new ActivateClass();
  285. activateClass.SetUpICardEffect("By trashing 2 source cards, trash opponent top security", CanUseCondition, card);
  286. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  287. activateClass.SetHashString("EX10_056_AllTurns");
  288. cardEffects.Add(activateClass);
  289. string EffectDiscription()
  290. {
  291. return "[All Turns] [Once Per Turn] When any of your opponent's Digimon or Tamers digivolve or effects place cards under them, by trashing any 2 of this Digimon's digivolution cards, trash your opponent's top security card.";
  292. }
  293. bool CanUseCondition(Hashtable hashtable)
  294. {
  295. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  296. && CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermamentCondition);
  297. }
  298. bool PermamentCondition(Permanent permanent)
  299. {
  300. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card);
  301. }
  302. bool CanActivateCondition(Hashtable hashtable)
  303. {
  304. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  305. && card.PermanentOfThisCard().DigivolutionCards.Count >= 2;
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable hashtable)
  308. {
  309. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  310. {
  311. Permanent thisPermanent = card.PermanentOfThisCard();
  312. List<CardSource> selectedCards = new List<CardSource>();
  313. #region Trash Digivolution Cards
  314. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  315. selectCardEffect.SetUp(
  316. canTargetCondition: _ => true,
  317. canTargetCondition_ByPreSelecetedList: null,
  318. canEndSelectCondition: null,
  319. canNoSelect: () => true,
  320. selectCardCoroutine: SelectCardCoroutine,
  321. afterSelectCardCoroutine: null,
  322. message: "Select 2 digivolution cards to trash.",
  323. maxCount: 2,
  324. canEndNotMax: false,
  325. isShowOpponent: true,
  326. mode: SelectCardEffect.Mode.Custom,
  327. root: SelectCardEffect.Root.Custom,
  328. customRootCardList: thisPermanent.DigivolutionCards,
  329. canLookReverseCard: true,
  330. selectPlayer: card.Owner,
  331. cardEffect: activateClass);
  332. IEnumerator SelectCardCoroutine(CardSource cardSource)
  333. {
  334. selectedCards.Add(cardSource);
  335. yield return null;
  336. }
  337. selectCardEffect.SetUseFaceDown();
  338. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  339. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  340. #endregion
  341. if (selectedCards.Count == 2)
  342. {
  343. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  344. targetPermanent: thisPermanent,
  345. targetDigivolutionCards: selectedCards,
  346. activateClass: activateClass,
  347. successProcess: SuccessProcess,
  348. failureProcess: null));
  349. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  350. {
  351. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  352. player: card.Owner.Enemy,
  353. destroySecurityCount: 1,
  354. cardEffect: activateClass,
  355. fromTop: true).DestroySecurity());
  356. }
  357. }
  358. }
  359. yield return null;
  360. }
  361. }
  362. #endregion
  363. #region Add Digivolution Cards
  364. if (timing == EffectTiming.OnAddDigivolutionCards)
  365. {
  366. ActivateClass activateClass = new ActivateClass();
  367. activateClass.SetUpICardEffect("By trashing 2 source cards, trash opponent top security", CanUseCondition, card);
  368. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  369. activateClass.SetHashString("EX10_056_AllTurns");
  370. cardEffects.Add(activateClass);
  371. string EffectDiscription()
  372. {
  373. return "[All Turns] [Once Per Turn] When any of your opponent's Digimon or Tamers digivolve or effects place cards under them, by trashing any 2 of this Digimon's digivolution cards, trash your opponent's top security card.";
  374. }
  375. bool CanUseCondition(Hashtable hashtable)
  376. {
  377. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  378. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(hashtable, PermamentCondition, cardEffect => cardEffect.EffectSourceCard != null, null);
  379. }
  380. bool PermamentCondition(Permanent permanent)
  381. {
  382. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card);
  383. }
  384. bool CanActivateCondition(Hashtable hashtable)
  385. {
  386. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  387. && card.PermanentOfThisCard().DigivolutionCards.Count >= 2;
  388. }
  389. IEnumerator ActivateCoroutine(Hashtable hashtable)
  390. {
  391. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  392. {
  393. Permanent thisPermanent = card.PermanentOfThisCard();
  394. List<CardSource> selectedCards = new List<CardSource>();
  395. #region Trash Digivolution Cards
  396. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  397. selectCardEffect.SetUp(
  398. canTargetCondition: _ => true,
  399. canTargetCondition_ByPreSelecetedList: null,
  400. canEndSelectCondition: null,
  401. canNoSelect: () => true,
  402. selectCardCoroutine: SelectCardCoroutine,
  403. afterSelectCardCoroutine: null,
  404. message: "Select 2 digivolution cards to trash.",
  405. maxCount: 2,
  406. canEndNotMax: false,
  407. isShowOpponent: true,
  408. mode: SelectCardEffect.Mode.Custom,
  409. root: SelectCardEffect.Root.Custom,
  410. customRootCardList: thisPermanent.DigivolutionCards,
  411. canLookReverseCard: true,
  412. selectPlayer: card.Owner,
  413. cardEffect: activateClass);
  414. IEnumerator SelectCardCoroutine(CardSource cardSource)
  415. {
  416. selectedCards.Add(cardSource);
  417. yield return null;
  418. }
  419. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  420. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  421. #endregion
  422. if (selectedCards.Count == 2)
  423. {
  424. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  425. targetPermanent: thisPermanent,
  426. targetDigivolutionCards: selectedCards,
  427. activateClass: activateClass,
  428. successProcess: SuccessProcess,
  429. failureProcess: null));
  430. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  431. {
  432. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  433. player: card.Owner.Enemy,
  434. destroySecurityCount: 1,
  435. cardEffect: activateClass,
  436. fromTop: true).DestroySecurity());
  437. }
  438. }
  439. }
  440. yield return null;
  441. }
  442. }
  443. #endregion
  444. #endregion
  445. return cardEffects;
  446. }
  447. }
  448. }