EX10_056.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. selectedPermamentToSource = permanent;
  116. yield return null;
  117. }
  118. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to move under a digimon/tamer", "The opponent is selecting 1 Digimon move under a digimon/tamer");
  119. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  120. #endregion
  121. if (selectedPermamentToSource != null)
  122. {
  123. bool IsEnemyPermanent(Permanent permanent)
  124. {
  125. return (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  126. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card))
  127. && permanent != selectedPermamentToSource;
  128. }
  129. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  130. {
  131. Permanent selectedPermanent = null;
  132. #region Select Enemy Permament to add source
  133. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  134. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  135. selectPermanentEffect1.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: IsEnemyPermanent,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: maxCount1,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectPermanentCoroutine1,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  148. {
  149. selectedPermanent = permanent;
  150. yield return null;
  151. }
  152. 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");
  153. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  154. #endregion
  155. if (selectedPermanent != null)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  158. permanentArrays: new List<Permanent[]>() { new Permanent[] { selectedPermamentToSource, selectedPermanent } },
  159. toTop: false,
  160. cardEffect: activateClass).PlacePermanentToDigivolutionCards());
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. #endregion
  168. #region When Digivolving
  169. if (timing == EffectTiming.OnEnterFieldAnyone)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Place 1 opponent digimon under a digimon or tamer", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  174. cardEffects.Add(activateClass);
  175. string EffectDiscription()
  176. {
  177. 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.";
  178. }
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  182. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  183. }
  184. bool CanActivateCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  187. && HasValidEnemyPermanents();
  188. }
  189. bool HasValidEnemyPermanents()
  190. {
  191. int digimon = card.Owner.Enemy.GetBattleAreaDigimons().Count;
  192. int notOptions = card.Owner.Enemy.GetBattleAreaPermanents().Filter(x => !x.IsOption).Count;
  193. return digimon >= 1 &&
  194. notOptions >= 2;
  195. }
  196. bool IsEnemyDigimon(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyDigimon))
  203. {
  204. Permanent selectedPermamentToSource = null;
  205. #region Select Enemy Digimon to add as Source
  206. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  207. selectPermanentEffect.SetUp(
  208. selectPlayer: card.Owner,
  209. canTargetCondition: IsEnemyDigimon,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: null,
  212. maxCount: 1,
  213. canNoSelect: true,
  214. canEndNotMax: false,
  215. selectPermanentCoroutine: SelectPermanentCoroutine,
  216. afterSelectPermanentCoroutine: null,
  217. mode: SelectPermanentEffect.Mode.Custom,
  218. cardEffect: activateClass);
  219. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  220. {
  221. selectedPermamentToSource = permanent;
  222. yield return null;
  223. }
  224. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to move under a digimon/tamer", "The opponent is selecting 1 Digimon move under a digimon/tamer");
  225. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  226. #endregion
  227. if (selectedPermamentToSource != null)
  228. {
  229. bool IsEnemyPermanent(Permanent permanent)
  230. {
  231. return (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  232. || CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaTamer(permanent, card))
  233. && permanent != selectedPermamentToSource;
  234. }
  235. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  236. {
  237. Permanent selectedPermanent = null;
  238. #region Select Enemy Permament to add source
  239. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  241. selectPermanentEffect1.SetUp(
  242. selectPlayer: card.Owner,
  243. canTargetCondition: IsEnemyPermanent,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. maxCount: maxCount1,
  247. canNoSelect: true,
  248. canEndNotMax: false,
  249. selectPermanentCoroutine: SelectPermanentCoroutine1,
  250. afterSelectPermanentCoroutine: null,
  251. mode: SelectPermanentEffect.Mode.Custom,
  252. cardEffect: activateClass);
  253. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  254. {
  255. selectedPermanent = permanent;
  256. yield return null;
  257. }
  258. 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");
  259. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  260. #endregion
  261. if (selectedPermanent != null)
  262. {
  263. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  264. permanentArrays: new List<Permanent[]>() { new Permanent[] { selectedPermamentToSource, selectedPermanent } },
  265. toTop: false,
  266. cardEffect: activateClass).PlacePermanentToDigivolutionCards());
  267. }
  268. }
  269. }
  270. }
  271. }
  272. }
  273. #endregion
  274. #region All Turns - Once Per Turn
  275. #region Digivolving
  276. if (timing == EffectTiming.OnEnterFieldAnyone)
  277. {
  278. ActivateClass activateClass = new ActivateClass();
  279. activateClass.SetUpICardEffect("By trashing 2 source cards, trash opponent top security", CanUseCondition, card);
  280. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  281. activateClass.SetHashString("EX10_056_AllTurns");
  282. cardEffects.Add(activateClass);
  283. string EffectDiscription()
  284. {
  285. 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.";
  286. }
  287. bool CanUseCondition(Hashtable hashtable)
  288. {
  289. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  290. && CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermamentCondition);
  291. }
  292. bool PermamentCondition(Permanent permanent)
  293. {
  294. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card);
  295. }
  296. bool CanActivateCondition(Hashtable hashtable)
  297. {
  298. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  299. && card.PermanentOfThisCard().DigivolutionCards.Count >= 2;
  300. }
  301. IEnumerator ActivateCoroutine(Hashtable hashtable)
  302. {
  303. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  304. {
  305. Permanent thisPermanent = card.PermanentOfThisCard();
  306. List<CardSource> selectedCards = new List<CardSource>();
  307. #region Trash Digivolution Cards
  308. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  309. selectCardEffect.SetUp(
  310. canTargetCondition: _ => true,
  311. canTargetCondition_ByPreSelecetedList: null,
  312. canEndSelectCondition: null,
  313. canNoSelect: () => true,
  314. selectCardCoroutine: SelectCardCoroutine,
  315. afterSelectCardCoroutine: null,
  316. message: "Select 2 digivolution cards to trash.",
  317. maxCount: 2,
  318. canEndNotMax: false,
  319. isShowOpponent: true,
  320. mode: SelectCardEffect.Mode.Custom,
  321. root: SelectCardEffect.Root.Custom,
  322. customRootCardList: thisPermanent.DigivolutionCards,
  323. canLookReverseCard: true,
  324. selectPlayer: card.Owner,
  325. cardEffect: activateClass);
  326. IEnumerator SelectCardCoroutine(CardSource cardSource)
  327. {
  328. selectedCards.Add(cardSource);
  329. yield return null;
  330. }
  331. selectCardEffect.SetUseFaceDown();
  332. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  333. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  334. #endregion
  335. if (selectedCards.Count == 2)
  336. {
  337. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  338. targetPermanent: thisPermanent,
  339. targetDigivolutionCards: selectedCards,
  340. activateClass: activateClass,
  341. successProcess: SuccessProcess,
  342. failureProcess: null));
  343. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  344. {
  345. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  346. player: card.Owner.Enemy,
  347. destroySecurityCount: 1,
  348. cardEffect: activateClass,
  349. fromTop: true).DestroySecurity());
  350. }
  351. }
  352. }
  353. yield return null;
  354. }
  355. }
  356. #endregion
  357. #region Add Digivolution Cards
  358. if (timing == EffectTiming.OnAddDigivolutionCards)
  359. {
  360. ActivateClass activateClass = new ActivateClass();
  361. activateClass.SetUpICardEffect("By trashing 2 source cards, trash opponent top security", CanUseCondition, card);
  362. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  363. activateClass.SetHashString("EX10_056_AllTurns");
  364. cardEffects.Add(activateClass);
  365. string EffectDiscription()
  366. {
  367. 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.";
  368. }
  369. bool CanUseCondition(Hashtable hashtable)
  370. {
  371. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  372. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(hashtable, PermamentCondition, cardEffect => cardEffect.EffectSourceCard != null, null);
  373. }
  374. bool PermamentCondition(Permanent permanent)
  375. {
  376. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card);
  377. }
  378. bool CanActivateCondition(Hashtable hashtable)
  379. {
  380. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  381. && card.PermanentOfThisCard().DigivolutionCards.Count >= 2;
  382. }
  383. IEnumerator ActivateCoroutine(Hashtable hashtable)
  384. {
  385. if (card.PermanentOfThisCard().DigivolutionCards.Count >= 2)
  386. {
  387. Permanent thisPermanent = card.PermanentOfThisCard();
  388. List<CardSource> selectedCards = new List<CardSource>();
  389. #region Trash Digivolution Cards
  390. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  391. selectCardEffect.SetUp(
  392. canTargetCondition: _ => true,
  393. canTargetCondition_ByPreSelecetedList: null,
  394. canEndSelectCondition: null,
  395. canNoSelect: () => true,
  396. selectCardCoroutine: SelectCardCoroutine,
  397. afterSelectCardCoroutine: null,
  398. message: "Select 2 digivolution cards to trash.",
  399. maxCount: 2,
  400. canEndNotMax: false,
  401. isShowOpponent: true,
  402. mode: SelectCardEffect.Mode.Custom,
  403. root: SelectCardEffect.Root.Custom,
  404. customRootCardList: thisPermanent.DigivolutionCards,
  405. canLookReverseCard: true,
  406. selectPlayer: card.Owner,
  407. cardEffect: activateClass);
  408. IEnumerator SelectCardCoroutine(CardSource cardSource)
  409. {
  410. selectedCards.Add(cardSource);
  411. yield return null;
  412. }
  413. selectCardEffect.SetUpCustomMessage("Select 2 digivolution cards to trash.", "The opponent is selecting 2 digivolution cards to trash.");
  414. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  415. #endregion
  416. if (selectedCards.Count == 2)
  417. {
  418. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  419. targetPermanent: thisPermanent,
  420. targetDigivolutionCards: selectedCards,
  421. activateClass: activateClass,
  422. successProcess: SuccessProcess,
  423. failureProcess: null));
  424. IEnumerator SuccessProcess(List<CardSource> trashedSources)
  425. {
  426. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  427. player: card.Owner.Enemy,
  428. destroySecurityCount: 1,
  429. cardEffect: activateClass,
  430. fromTop: true).DestroySecurity());
  431. }
  432. }
  433. }
  434. yield return null;
  435. }
  436. }
  437. #endregion
  438. #endregion
  439. return cardEffects;
  440. }
  441. }
  442. }