EX10_020.cs 23 KB

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