EX10_019.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_019 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasSuperAppTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region App Fusion (Mienumon & Sakusimon)
  23. if (timing == EffectTiming.None)
  24. {
  25. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Mienumon", "Sakusimon" }, card));
  26. }
  27. #endregion
  28. #region Link Condition
  29. if (timing == EffectTiming.None)
  30. {
  31. static bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. return targetPermanent.TopCard.HasAppmonTraits;
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  36. }
  37. #endregion
  38. #region Link
  39. if (timing == EffectTiming.OnDeclaration)
  40. {
  41. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  42. }
  43. #endregion
  44. #region Fortitude
  45. if (timing == EffectTiming.OnDestroyedAnyone)
  46. {
  47. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  48. }
  49. #endregion
  50. #region On Play/When Digivolving shared
  51. bool CanLinkCondition(CardSource cardSource)
  52. {
  53. return cardSource.HasLevel && cardSource.Level <= 4 && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  54. }
  55. bool CanActivateConditionShared(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  58. (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition) ||
  59. card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition));
  60. }
  61. #endregion
  62. #region On Play
  63. if (timing == EffectTiming.OnEnterFieldAnyone)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  67. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  68. cardEffects.Add(activateClass);
  69. string EffectDescription()
  70. {
  71. return "[On Play] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable hashtable)
  78. {
  79. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  80. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition);
  81. if (canSelectSources || canSelectTrash)
  82. {
  83. if (canSelectTrash && canSelectSources)
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  86. {
  87. new(message: "From trash", value: true, spriteIndex: 0),
  88. new(message: "From sources", value: false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "From which area do you select a card?";
  91. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. }
  94. else
  95. {
  96. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  100. List<CardSource> selectedCards = new List<CardSource>();
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. if (fromTrash)
  107. {
  108. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  109. selectCardEffect.SetUp(
  110. canTargetCondition: CanLinkCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. canNoSelect: () => true,
  114. selectCardCoroutine: SelectCardCoroutine,
  115. afterSelectCardCoroutine: null,
  116. message: "Select 1 card to link.",
  117. maxCount: 1,
  118. canEndNotMax: false,
  119. isShowOpponent: true,
  120. mode: SelectCardEffect.Mode.Custom,
  121. root: SelectCardEffect.Root.Trash,
  122. customRootCardList: null,
  123. canLookReverseCard: true,
  124. selectPlayer: card.Owner,
  125. cardEffect: activateClass);
  126. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  127. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  128. yield return StartCoroutine(selectCardEffect.Activate());
  129. }
  130. else
  131. {
  132. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  133. selectCardEffect.SetUp(
  134. canTargetCondition: CanLinkCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. canNoSelect: () => true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. message: "Select 1 digivolution card to link.",
  141. maxCount: 1,
  142. canEndNotMax: false,
  143. isShowOpponent: true,
  144. mode: SelectCardEffect.Mode.Custom,
  145. root: SelectCardEffect.Root.Custom,
  146. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  147. canLookReverseCard: true,
  148. selectPlayer: card.Owner,
  149. cardEffect: activateClass);
  150. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  151. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  152. yield return StartCoroutine(selectCardEffect.Activate());
  153. }
  154. if (selectedCards.Count >= 1)
  155. {
  156. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  157. }
  158. }
  159. }
  160. }
  161. #endregion
  162. #region When Digivolving
  163. if (timing == EffectTiming.OnEnterFieldAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  168. cardEffects.Add(activateClass);
  169. string EffectDescription()
  170. {
  171. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable hashtable)
  178. {
  179. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  180. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition);
  181. if (canSelectSources || canSelectTrash)
  182. {
  183. if (canSelectTrash && canSelectSources)
  184. {
  185. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  186. {
  187. new(message: "From trash", value: true, spriteIndex: 0),
  188. new(message: "From sources", value: false, spriteIndex: 1),
  189. };
  190. string selectPlayerMessage = "From which area do you select a card?";
  191. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  192. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  193. }
  194. else
  195. {
  196. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  197. }
  198. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  199. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  200. List<CardSource> selectedCards = new List<CardSource>();
  201. IEnumerator SelectCardCoroutine(CardSource cardSource)
  202. {
  203. selectedCards.Add(cardSource);
  204. yield return null;
  205. }
  206. if (fromTrash)
  207. {
  208. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  209. selectCardEffect.SetUp(
  210. canTargetCondition: CanLinkCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. canNoSelect: () => true,
  214. selectCardCoroutine: SelectCardCoroutine,
  215. afterSelectCardCoroutine: null,
  216. message: "Select 1 card to link.",
  217. maxCount: 1,
  218. canEndNotMax: false,
  219. isShowOpponent: true,
  220. mode: SelectCardEffect.Mode.Custom,
  221. root: SelectCardEffect.Root.Trash,
  222. customRootCardList: null,
  223. canLookReverseCard: true,
  224. selectPlayer: card.Owner,
  225. cardEffect: activateClass);
  226. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  227. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  228. yield return StartCoroutine(selectCardEffect.Activate());
  229. }
  230. else
  231. {
  232. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  233. selectCardEffect.SetUp(
  234. canTargetCondition: CanLinkCondition,
  235. canTargetCondition_ByPreSelecetedList: null,
  236. canEndSelectCondition: null,
  237. canNoSelect: () => true,
  238. selectCardCoroutine: SelectCardCoroutine,
  239. afterSelectCardCoroutine: null,
  240. message: "Select 1 digivolution card to link.",
  241. maxCount: 1,
  242. canEndNotMax: false,
  243. isShowOpponent: true,
  244. mode: SelectCardEffect.Mode.Custom,
  245. root: SelectCardEffect.Root.Custom,
  246. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  247. canLookReverseCard: true,
  248. selectPlayer: card.Owner,
  249. cardEffect: activateClass);
  250. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  251. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  252. yield return StartCoroutine(selectCardEffect.Activate());
  253. }
  254. if (selectedCards.Count >= 1)
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  257. }
  258. }
  259. }
  260. }
  261. #endregion
  262. #region All Turns - OPT
  263. if (timing == EffectTiming.WhenLinked)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Suspend 1 Digimon/Tamer, Can't Unsuspend", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  268. activateClass.SetHashString("AT_EX10-019");
  269. cardEffects.Add(activateClass);
  270. string EffectDiscription()
  271. {
  272. return "[All Turns] [Once Per Turn] When this Digimon gets linked, you may suspend 1 of your opponent's Digimon or Tamers. It can't unsuspend in their next unsuspend phase.";
  273. }
  274. bool CanUseCondition(Hashtable hashtable)
  275. {
  276. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  277. && CardEffectCommons.CanTriggerWhenLinked(hashtable, perm => perm == card.PermanentOfThisCard(), null);
  278. }
  279. bool CanActivateCondition(Hashtable hashtable)
  280. {
  281. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  282. }
  283. bool CanSelectPermanentCondition(Permanent permanent)
  284. {
  285. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  286. (permanent.IsDigimon || permanent.IsTamer);
  287. }
  288. IEnumerator ActivateCoroutine(Hashtable hashtable)
  289. {
  290. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  291. {
  292. Permanent selectedPermanent = null;
  293. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  294. selectPermanentEffect.SetUp(
  295. selectPlayer: card.Owner,
  296. canTargetCondition: CanSelectPermanentCondition,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. maxCount: 1,
  300. canNoSelect: false,
  301. canEndNotMax: false,
  302. selectPermanentCoroutine: SelectPermanentCoroutine,
  303. afterSelectPermanentCoroutine: null,
  304. mode: SelectPermanentEffect.Mode.Tap,
  305. cardEffect: activateClass);
  306. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  307. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  308. {
  309. selectedPermanent = permanent;
  310. yield return null;
  311. }
  312. if (selectedPermanent != null)
  313. {
  314. bool PermanentCondition(Permanent permanent)
  315. {
  316. return permanent == selectedPermanent;
  317. }
  318. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  319. permanentCondition: PermanentCondition,
  320. effectDuration: EffectDuration.UntilOwnerActivePhase,
  321. activateClass: activateClass,
  322. isOnlyActivePhase: true,
  323. effectName: "Your Digimon can't unsuspend"));
  324. }
  325. }
  326. }
  327. }
  328. #endregion
  329. #region Link Effect
  330. if (timing == EffectTiming.OnTappedAnyone)
  331. {
  332. ActivateClass activateClass = new ActivateClass();
  333. activateClass.SetUpICardEffect("By trashing 1 link card, trash opponents security", CanUseCondition, card);
  334. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  335. activateClass.SetIsLinkedEffect(true);
  336. cardEffects.Add(activateClass);
  337. string EffectDiscription()
  338. {
  339. return "[All Turns] When any of your opponent's Digimon suspend, by trashing 1 of this Digimon's link cards, trash your opponent's top security card.";
  340. }
  341. bool CanUseCondition(Hashtable hashtable)
  342. {
  343. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  344. CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, OpponentsDigimon);
  345. }
  346. bool CanActivateCondition(Hashtable hashtable)
  347. {
  348. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  349. !card.PermanentOfThisCard().HasNoLinkCards;
  350. }
  351. bool OpponentsDigimon(Permanent permanent)
  352. {
  353. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  354. }
  355. IEnumerator ActivateCoroutine(Hashtable hashtable)
  356. {
  357. Permanent thisCardPermament = card.PermanentOfThisCard();
  358. CardSource selectedCard = null;
  359. #region Select Link Card
  360. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  361. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  362. selectCardEffect.SetUp(
  363. canTargetCondition: _ => true,
  364. canTargetCondition_ByPreSelecetedList: null,
  365. canEndSelectCondition: null,
  366. canNoSelect: () => true,
  367. selectCardCoroutine: SelectCardCoroutine,
  368. afterSelectCardCoroutine: null,
  369. message: "Select 1 linked card to trash.",
  370. maxCount: maxCount,
  371. canEndNotMax: false,
  372. isShowOpponent: true,
  373. mode: SelectCardEffect.Mode.Custom,
  374. root: SelectCardEffect.Root.Custom,
  375. customRootCardList: thisCardPermament.LinkedCards,
  376. canLookReverseCard: true,
  377. selectPlayer: card.Owner,
  378. cardEffect: activateClass);
  379. IEnumerator SelectCardCoroutine(CardSource cardSource)
  380. {
  381. selectedCard = cardSource;
  382. yield return null;
  383. }
  384. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  385. yield return StartCoroutine(selectCardEffect.Activate());
  386. #endregion
  387. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  388. targetPermanent: thisCardPermament,
  389. targetLinkCards: new List<CardSource>() { selectedCard },
  390. activateClass: activateClass,
  391. successProcess: SuccessProcess,
  392. failureProcess: null));
  393. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  394. {
  395. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  396. {
  397. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  398. player: card.Owner.Enemy,
  399. destroySecurityCount: 1,
  400. cardEffect: activateClass,
  401. fromTop: true).DestroySecurity());
  402. }
  403. }
  404. }
  405. }
  406. #endregion
  407. return cardEffects;
  408. }
  409. }
  410. }