EX10_012.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using UnityEngine;
  6. //Metalseadramon
  7. namespace DCGO.CardEffects.EX10
  8. {
  9. public class EX10_012 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Hand - Main
  15. if (timing == EffectTiming.OnDeclaration)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Play for reduced cost of 5, delete at end of turn", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  20. activateClass.SetIsDigimonEffect(true);
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[Hand] [Main] If you don't have any Digimon other than Digimon with [Dark Masters] in their texts, you may play this card with the play cost reduced by 5. At turn end, delete the Digimon this effect played.";
  25. }
  26. bool IsDarkMaster(Permanent targetPermanent)
  27. {
  28. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card) &&
  29. !targetPermanent.TopCard.HasText("Dark Masters");
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnHand(card) &&
  34. CardEffectCommons.MatchConditionPermanentCount(IsDarkMaster) == 0 &&
  35. CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass);
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. #region reduce play cost
  40. if (card.Owner.CanReduceCost(null, card))
  41. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  42. ChangeCostClass changeCostClass = new ChangeCostClass();
  43. changeCostClass.SetUpICardEffect($"Play Cost -5", CanUseCondition1, card);
  44. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  45. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  46. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  47. ICardEffect GetReduceCostCardEffect(EffectTiming _timing)
  48. {
  49. if (_timing == EffectTiming.None)
  50. {
  51. return changeCostClass;
  52. }
  53. return null;
  54. }
  55. bool CanUseCondition1(Hashtable hashtable)
  56. {
  57. return true;
  58. }
  59. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  60. {
  61. if (CardSourceCondition(cardSource))
  62. {
  63. if (RootCondition(root))
  64. {
  65. if (PermanentsCondition(targetPermanents))
  66. {
  67. Cost -= 5;
  68. }
  69. }
  70. }
  71. return Cost;
  72. }
  73. bool PermanentsCondition(List<Permanent> targetPermanents)
  74. {
  75. if (targetPermanents == null)
  76. {
  77. return true;
  78. }
  79. else
  80. {
  81. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  82. {
  83. return true;
  84. }
  85. }
  86. return false;
  87. }
  88. bool CardSourceCondition(CardSource cardSource)
  89. {
  90. return true;
  91. }
  92. bool RootCondition(SelectCardEffect.Root root)
  93. {
  94. return true;
  95. }
  96. bool isUpDown()
  97. {
  98. return true;
  99. }
  100. #endregion
  101. if(CardEffectCommons.CanPlayAsNewPermanent(card, true, activateClass))
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  104. cardSources: new List<CardSource> { card },
  105. activateClass: activateClass,
  106. payCost: true,
  107. isTapped: false,
  108. root: SelectCardEffect.Root.Hand,
  109. activateETB: true));
  110. yield return new WaitForSeconds(0.2f);
  111. #region Delete Digimon Played
  112. Permanent playedPermanent = card.PermanentOfThisCard();
  113. ActivateClass activateClass1 = new ActivateClass();
  114. activateClass1.SetUpICardEffect("Delete the Digimon", CanUseCondition2, playedPermanent.TopCard);
  115. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  116. activateClass1.SetEffectSourcePermanent(playedPermanent);
  117. playedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  118. if (!playedPermanent.TopCard.CanNotBeAffected(activateClass))
  119. {
  120. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(playedPermanent));
  121. }
  122. string EffectDiscription1()
  123. {
  124. return "[End of Your Turn] Delete this Digimon.";
  125. }
  126. bool CanUseCondition2(Hashtable hashtable1)
  127. {
  128. if (CardEffectCommons.IsOwnerTurn(card))
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(playedPermanent, playedPermanent.TopCard))
  131. {
  132. return true;
  133. }
  134. }
  135. return false;
  136. }
  137. bool CanActivateCondition1(Hashtable hashtable1)
  138. {
  139. if (CardEffectCommons.IsPermanentExistsOnBattleArea(playedPermanent))
  140. {
  141. if (!playedPermanent.TopCard.CanNotBeAffected(activateClass))
  142. {
  143. return true;
  144. }
  145. }
  146. return false;
  147. }
  148. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  149. {
  150. if (CardEffectCommons.IsPermanentExistsOnBattleArea(playedPermanent))
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  153. new List<Permanent>() { playedPermanent },
  154. CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  155. }
  156. }
  157. ICardEffect GetCardEffect(EffectTiming _timing)
  158. {
  159. if (_timing == EffectTiming.OnEndTurn)
  160. {
  161. return activateClass1;
  162. }
  163. return null;
  164. }
  165. #endregion
  166. }
  167. #region release reducing play cost
  168. card.Owner.UntilCalculateFixedCostEffect.Remove(GetReduceCostCardEffect);
  169. #endregion
  170. }
  171. }
  172. #endregion
  173. #region On Play/When Attacking Shared
  174. string SharedEffectName = "1 Digimon and 1 Tamer cant suspend";
  175. string SharedEffectDescription(string tag)
  176. => $"[{tag}] 1 of your opponent's Digimon and 1 of their Tamers can't suspend until their turn ends.";
  177. bool CanSelectDigimonCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  180. }
  181. bool CanSelectTamerCondition(Permanent permanent)
  182. {
  183. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  184. {
  185. if (permanent.IsTamer)
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. CardEffectFactory.ActivateClassesForSharedEffects
  193. (ref cardEffects, timing, card,
  194. SharedEffectName,
  195. SharedActivateCoroutine,
  196. SharedEffectDescription,
  197. optional: false,
  198. onPlay: true,
  199. whenAttacking: true);
  200. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  201. {
  202. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  203. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectDigimonCondition))
  204. {
  205. selectPermanentEffect.SetUp(
  206. selectPlayer: card.Owner,
  207. canTargetCondition: CanSelectDigimonCondition,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. maxCount: 1,
  211. canNoSelect: false,
  212. canEndNotMax: false,
  213. selectPermanentCoroutine: SelectPermanentCoroutine,
  214. afterSelectPermanentCoroutine: null,
  215. mode: SelectPermanentEffect.Mode.Custom,
  216. cardEffect: activateClass);
  217. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get unable to suspend.", "The opponent is selecting 1 Digimon that will get unable to suspend.");
  218. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  219. }
  220. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition))
  221. {
  222. selectPermanentEffect.SetUp(
  223. selectPlayer: card.Owner,
  224. canTargetCondition: CanSelectTamerCondition,
  225. canTargetCondition_ByPreSelecetedList: null,
  226. canEndSelectCondition: null,
  227. maxCount: 1,
  228. canNoSelect: false,
  229. canEndNotMax: false,
  230. selectPermanentCoroutine: SelectPermanentCoroutine,
  231. afterSelectPermanentCoroutine: null,
  232. mode: SelectPermanentEffect.Mode.Custom,
  233. cardEffect: activateClass);
  234. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get unable to suspend.", "The opponent is selecting 1 Digimon that will get unable to suspend.");
  235. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  236. }
  237. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  238. {
  239. Permanent selectedPermanent = permanent;
  240. if (selectedPermanent != null)
  241. {
  242. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  243. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  244. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  245. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  246. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  249. }
  250. bool CanUseCondition1(Hashtable hashtable)
  251. {
  252. if (selectedPermanent.TopCard != null)
  253. {
  254. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  255. {
  256. return true;
  257. }
  258. }
  259. return false;
  260. }
  261. bool PermanentCondition(Permanent permanent)
  262. {
  263. if (permanent == selectedPermanent)
  264. {
  265. return true;
  266. }
  267. return false;
  268. }
  269. }
  270. }
  271. }
  272. #endregion
  273. #region All Turns
  274. if (timing == EffectTiming.None)
  275. {
  276. bool Condition()
  277. {
  278. return CardEffectCommons.IsExistOnBattleArea(card);
  279. }
  280. bool CardCondition(CardSource cardSource)
  281. {
  282. return !cardSource.EqualsCardName("Apocalymon");
  283. }
  284. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  285. cardCondition: CardCondition,
  286. isInheritedEffect: false,
  287. card: card,
  288. condition: Condition,
  289. effectName: "[All Turns] This Digimon can only digivolve into [Apocalymon].")
  290. );
  291. }
  292. #endregion
  293. #region On Deletion
  294. if (timing == EffectTiming.OnDestroyedAnyone)
  295. {
  296. ActivateClass activateClass = new ActivateClass();
  297. activateClass.SetUpICardEffect("Place this Digimon face up as bottom security", CanUseCondition, card);
  298. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  299. cardEffects.Add(activateClass);
  300. string EffectDiscription()
  301. {
  302. return "[On Deletion] If you have no blue face-up security cards, place this Digimon face up as the bottom security card.";
  303. }
  304. bool FaceUpBlue(CardSource card)
  305. {
  306. return !card.IsFlipped &&
  307. card.HasCardColor(CardColor.Blue);
  308. }
  309. bool CanUseCondition(Hashtable hashtable)
  310. {
  311. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  312. }
  313. bool CanActivateCondition(Hashtable hashtable)
  314. {
  315. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  316. && card.Owner.CanAddSecurity(activateClass);
  317. }
  318. IEnumerator ActivateCoroutine(Hashtable hashtable)
  319. {
  320. if(!CardEffectCommons.HasMatchConditionOwnersSecurity(card, FaceUpBlue, false))
  321. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, false, true));
  322. }
  323. }
  324. #endregion
  325. #region Security
  326. if (timing == EffectTiming.SecuritySkill)
  327. {
  328. ActivateClass activateClass = new ActivateClass();
  329. activateClass.SetUpICardEffect($"Play 1 Level 5 or lower digimon with [Dark Masters] in text from hand or trash", CanUseCondition, card);
  330. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  331. activateClass.SetIsSecurityEffect(true);
  332. cardEffects.Add(activateClass);
  333. string EffectDiscription()
  334. {
  335. return "[Security] If this card was face-up, you may play 1 level 5 or lower card with [Dark Masters] in its text from your hand or trash without paying the cost.";
  336. }
  337. bool CanUseCondition(Hashtable hashtable)
  338. {
  339. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card)
  340. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  341. && !CardEffectCommons.GetFaceDownFromHashtable(hashtable);
  342. }
  343. bool CanSelectCardCondition(CardSource cardSource)
  344. {
  345. return cardSource.IsDigimon
  346. && cardSource.HasLevel && cardSource.Level <= 5
  347. && cardSource.HasText("Dark Masters");
  348. }
  349. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  350. {
  351. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  352. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  353. if (canSelectHand || canSelectTrash)
  354. {
  355. if (canSelectHand && canSelectTrash)
  356. {
  357. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  358. {
  359. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  360. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  361. };
  362. string selectPlayerMessage = "From which area do you select a card?";
  363. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  364. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  365. }
  366. else
  367. {
  368. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  369. }
  370. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  371. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  372. List<CardSource> selectedCards = new List<CardSource>();
  373. IEnumerator SelectCardCoroutine(CardSource cardSource)
  374. {
  375. selectedCards.Add(cardSource);
  376. yield return null;
  377. }
  378. if (fromHand)
  379. {
  380. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  381. selectHandEffect.SetUp(
  382. selectPlayer: card.Owner,
  383. canTargetCondition: CanSelectCardCondition,
  384. canTargetCondition_ByPreSelecetedList: null,
  385. canEndSelectCondition: null,
  386. maxCount: 1,
  387. canNoSelect: true,
  388. canEndNotMax: false,
  389. isShowOpponent: true,
  390. selectCardCoroutine: SelectCardCoroutine,
  391. afterSelectCardCoroutine: null,
  392. mode: SelectHandEffect.Mode.Custom,
  393. cardEffect: activateClass);
  394. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon to play.");
  395. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  396. }
  397. else
  398. {
  399. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  400. selectCardEffect.SetUp(
  401. canTargetCondition: CanSelectCardCondition,
  402. canTargetCondition_ByPreSelecetedList: null,
  403. canEndSelectCondition: null,
  404. canNoSelect: () => true,
  405. selectCardCoroutine: SelectCardCoroutine,
  406. afterSelectCardCoroutine: null,
  407. message: "Select 1 card to add as source.",
  408. maxCount: 1,
  409. canEndNotMax: false,
  410. isShowOpponent: true,
  411. mode: SelectCardEffect.Mode.Custom,
  412. root: SelectCardEffect.Root.Trash,
  413. customRootCardList: null,
  414. canLookReverseCard: true,
  415. selectPlayer: card.Owner,
  416. cardEffect: activateClass);
  417. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  418. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  419. }
  420. if (selectedCards.Any()) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  421. cardSources: selectedCards,
  422. activateClass: activateClass,
  423. payCost: false,
  424. isTapped: false,
  425. root: fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  426. activateETB: true
  427. ));
  428. }
  429. }
  430. }
  431. #endregion
  432. return cardEffects;
  433. }
  434. }
  435. }