EX10_020.cs 21 KB

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