EX10_057.cs 20 KB

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