EX10_035.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using UnityEngine;
  6. //Machinedramon
  7. namespace DCGO.CardEffects.EX10
  8. {
  9. public class EX10_035 : 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 = "De-digivolve 2, 2 digimon";
  175. string SharedEffectDescription(string tag)
  176. => $"[{tag}] <De-Digivolve 2> 2 of your opponent's Digimon. (Trash up to 2 cards from the top. You can't trash past level 3 cards.)";
  177. bool CanSelectPermanentCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  180. }
  181. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  182. {
  183. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  184. {
  185. int degenrationMaxCount = 2;
  186. int degenrationCount = 0;
  187. SelectCountEffect selectCountEffect = GManager.instance.GetComponent<SelectCountEffect>();
  188. if (selectCountEffect != null)
  189. {
  190. selectCountEffect.SetUp(
  191. SelectPlayer: card.Owner,
  192. targetPermanent: null,
  193. MaxCount: degenrationMaxCount,
  194. CanNoSelect: false,
  195. Message: "How much will you De-Digivolve?",
  196. Message_Enemy: "The opponent is choosing how much to De-Digivolve.",
  197. SelectCountCoroutine: SelectCountCoroutine);
  198. yield return ContinuousController.instance.StartCoroutine(selectCountEffect.Activate());
  199. IEnumerator SelectCountCoroutine(int count)
  200. {
  201. degenrationCount = count;
  202. yield return null;
  203. }
  204. }
  205. List<Permanent> selectedPermaments = new List<Permanent>();
  206. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  207. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  208. selectPermanentEffect.SetUp(
  209. selectPlayer: card.Owner,
  210. canTargetCondition: CanSelectPermanentCondition,
  211. canTargetCondition_ByPreSelecetedList: null,
  212. canEndSelectCondition: null,
  213. maxCount: maxCount,
  214. canNoSelect: false,
  215. canEndNotMax: false,
  216. selectPermanentCoroutine: SelectPermanentCoroutine,
  217. afterSelectPermanentCoroutine: null,
  218. mode: SelectPermanentEffect.Mode.Custom,
  219. cardEffect: activateClass);
  220. selectPermanentEffect.SetUpCustomMessage("Select 2 Digimon to De-Digivolve.", "The opponent is selecting 2 Digimon to De-Digivolve.");
  221. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  222. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  223. {
  224. selectedPermaments.Add(permanent);
  225. yield return null;
  226. }
  227. if (selectedPermaments.Any())
  228. {
  229. foreach (var selectedPermanent in selectedPermaments)
  230. {
  231. if (selectedPermanent != null)
  232. {
  233. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, degenrationCount, activateClass, true).Degeneration());
  234. }
  235. }
  236. }
  237. }
  238. }
  239. CardEffectFactory.ActivateClassesForSharedEffects
  240. (ref cardEffects, timing, card,
  241. SharedEffectName,
  242. SharedActivateCoroutine,
  243. SharedEffectDescription,
  244. optional: false,
  245. onPlay: true,
  246. whenAttacking: true);
  247. #endregion
  248. #region All Turns
  249. if (timing == EffectTiming.None)
  250. {
  251. bool Condition()
  252. {
  253. return CardEffectCommons.IsExistOnBattleArea(card);
  254. }
  255. bool CardCondition(CardSource cardSource)
  256. {
  257. return !cardSource.EqualsCardName("Apocalymon");
  258. }
  259. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  260. cardCondition: CardCondition,
  261. isInheritedEffect: false,
  262. card: card,
  263. condition: Condition,
  264. effectName: "[All Turns] This Digimon can only digivolve into [Apocalymon].")
  265. );
  266. }
  267. #endregion
  268. #region On Deletion
  269. if (timing == EffectTiming.OnDestroyedAnyone)
  270. {
  271. ActivateClass activateClass = new ActivateClass();
  272. activateClass.SetUpICardEffect("Place this Digimon face up as bottom security", CanUseCondition, card);
  273. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  274. cardEffects.Add(activateClass);
  275. string EffectDiscription()
  276. {
  277. return "[On Deletion] If you have no black face-up security cards, place this Digimon face up as the bottom security card.";
  278. }
  279. bool FaceUpBlack(CardSource card)
  280. {
  281. return !card.IsFlipped &&
  282. card.HasCardColor(CardColor.Black);
  283. }
  284. bool CanUseCondition(Hashtable hashtable)
  285. {
  286. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  287. }
  288. bool CanActivateCondition(Hashtable hashtable)
  289. {
  290. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  291. && card.Owner.CanAddSecurity(activateClass);
  292. }
  293. IEnumerator ActivateCoroutine(Hashtable hashtable)
  294. {
  295. if(!CardEffectCommons.HasMatchConditionOwnersSecurity(card, FaceUpBlack, false))
  296. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, false, true));
  297. }
  298. }
  299. #endregion
  300. #region Security
  301. if (timing == EffectTiming.SecuritySkill)
  302. {
  303. ActivateClass activateClass = new ActivateClass();
  304. activateClass.SetUpICardEffect($"Play 1 Level 5 or lower digimon with [Dark Masters] in text from hand or trash", CanUseCondition, card);
  305. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  306. activateClass.SetIsSecurityEffect(true);
  307. cardEffects.Add(activateClass);
  308. string EffectDiscription()
  309. {
  310. 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.";
  311. }
  312. bool CanUseCondition(Hashtable hashtable)
  313. {
  314. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card)
  315. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  316. && !CardEffectCommons.GetFaceDownFromHashtable(hashtable);
  317. }
  318. bool CanSelectCardCondition(CardSource cardSource)
  319. {
  320. return cardSource.IsDigimon
  321. && cardSource.HasLevel && cardSource.Level <= 5
  322. && cardSource.HasText("Dark Masters");
  323. }
  324. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  325. {
  326. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  327. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  328. if (canSelectHand || canSelectTrash)
  329. {
  330. if (canSelectHand && canSelectTrash)
  331. {
  332. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  333. {
  334. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  335. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  336. };
  337. string selectPlayerMessage = "From which area do you select a card?";
  338. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  339. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  340. }
  341. else
  342. {
  343. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  344. }
  345. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  346. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  347. List<CardSource> selectedCards = new List<CardSource>();
  348. IEnumerator SelectCardCoroutine(CardSource cardSource)
  349. {
  350. selectedCards.Add(cardSource);
  351. yield return null;
  352. }
  353. if (fromHand)
  354. {
  355. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  356. selectHandEffect.SetUp(
  357. selectPlayer: card.Owner,
  358. canTargetCondition: CanSelectCardCondition,
  359. canTargetCondition_ByPreSelecetedList: null,
  360. canEndSelectCondition: null,
  361. maxCount: 1,
  362. canNoSelect: true,
  363. canEndNotMax: false,
  364. isShowOpponent: true,
  365. selectCardCoroutine: SelectCardCoroutine,
  366. afterSelectCardCoroutine: null,
  367. mode: SelectHandEffect.Mode.Custom,
  368. cardEffect: activateClass);
  369. selectHandEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon to play.");
  370. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  371. }
  372. else
  373. {
  374. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  375. selectCardEffect.SetUp(
  376. canTargetCondition: CanSelectCardCondition,
  377. canTargetCondition_ByPreSelecetedList: null,
  378. canEndSelectCondition: null,
  379. canNoSelect: () => true,
  380. selectCardCoroutine: SelectCardCoroutine,
  381. afterSelectCardCoroutine: null,
  382. message: "Select 1 card to add as source.",
  383. maxCount: 1,
  384. canEndNotMax: false,
  385. isShowOpponent: true,
  386. mode: SelectCardEffect.Mode.Custom,
  387. root: SelectCardEffect.Root.Trash,
  388. customRootCardList: null,
  389. canLookReverseCard: true,
  390. selectPlayer: card.Owner,
  391. cardEffect: activateClass);
  392. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  393. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  394. }
  395. if (selectedCards.Any()) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  396. cardSources: selectedCards,
  397. activateClass: activateClass,
  398. payCost: false,
  399. isTapped: false,
  400. root: fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  401. activateETB: true
  402. ));
  403. }
  404. }
  405. }
  406. #endregion
  407. return cardEffects;
  408. }
  409. }
  410. }