Regulusmon_LM_017.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class Regulusmon_LM_017 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. //Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Gammamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. //Blast Digivolve
  22. if (timing == EffectTiming.OnCounterTiming)
  23. {
  24. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  25. }
  26. #region On Play/When Digivolving Shared
  27. string EffectSharedDiscription()
  28. {
  29. return "[On Play] [When Digivolving] Trash 1 card in your hand. Then, you may place 1 card with [Gammamon] in its text from your trash as this Digimon's bottom digivolution card.";
  30. }
  31. bool CanSelectSharedCardCondition(CardSource cardSource)
  32. {
  33. if (CardEffectCommons.IsExistOnTrash(cardSource))
  34. {
  35. return cardSource.HasText("Gammamon");
  36. }
  37. return false;
  38. }
  39. #endregion
  40. #region On Play
  41. if (timing == EffectTiming.OnEnterFieldAnyone)
  42. {
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("Trash 1 card from your hand", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  46. cardEffects.Add(activateClass);
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (card.Owner.HandCards.Count >= 1)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanActivateThenCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (card.Owner.TrashCards.Count >= 1)
  67. {
  68. if (card.Owner.TrashCards.Any(cardSource => cardSource.HasText("Gammamon")))
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. List<CardSource> selectedCards = new List<CardSource>();
  79. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  80. selectHandEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: (cardSource) => true,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. selectCardCoroutine: null,
  90. afterSelectCardCoroutine: null,
  91. mode: SelectHandEffect.Mode.Discard,
  92. cardEffect: activateClass);
  93. selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash.");
  94. yield return StartCoroutine(selectHandEffect.Activate());
  95. yield return StartCoroutine(ActivatePlacingSource());
  96. }
  97. IEnumerator ActivatePlacingSource()
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Place a Card from hand to digivolution cards to get effects", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateThenCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  102. cardEffects.Add(activateClass);
  103. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  104. List<CardSource> selectedCards = new List<CardSource>();
  105. selectCardEffect.SetUp(
  106. canTargetCondition: CanSelectSharedCardCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. canNoSelect: () => true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. message: "Select 1 card to place at the bottom of digivolution cards.",
  113. maxCount: 1,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. mode: SelectCardEffect.Mode.Custom,
  117. root: SelectCardEffect.Root.Trash,
  118. customRootCardList: null,
  119. canLookReverseCard: true,
  120. selectPlayer: card.Owner,
  121. cardEffect: activateClass);
  122. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  123. yield return StartCoroutine(selectCardEffect.Activate());
  124. IEnumerator SelectCardCoroutine(CardSource cardSource)
  125. {
  126. selectedCards.Add(cardSource);
  127. yield return null;
  128. }
  129. if (selectedCards.Count >= 1)
  130. {
  131. Permanent selectedPermanent = card.PermanentOfThisCard();
  132. if (selectedPermanent != null)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  135. }
  136. }
  137. }
  138. }
  139. #endregion
  140. #region When Digivolving
  141. if (timing == EffectTiming.OnEnterFieldAnyone)
  142. {
  143. ActivateClass activateClass = new ActivateClass();
  144. activateClass.SetUpICardEffect("Trash 1 card from your hand", CanUseCondition, card);
  145. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  146. cardEffects.Add(activateClass);
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. if (card.Owner.HandCards.Count >= 1)
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. bool CanActivateThenCondition(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.IsExistOnBattleArea(card))
  165. {
  166. if (card.Owner.TrashCards.Count >= 1)
  167. {
  168. if (card.Owner.TrashCards.Any(cardSource => cardSource.HasText("Gammamon")))
  169. {
  170. return true;
  171. }
  172. }
  173. }
  174. return false;
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  177. {
  178. List<CardSource> selectedCards = new List<CardSource>();
  179. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  180. selectHandEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: (cardSource) => true,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: 1,
  186. canNoSelect: true,
  187. canEndNotMax: false,
  188. isShowOpponent: true,
  189. selectCardCoroutine: null,
  190. afterSelectCardCoroutine: null,
  191. mode: SelectHandEffect.Mode.Discard,
  192. cardEffect: activateClass);
  193. selectHandEffect.SetUpCustomMessage("Select 1 card to trash.", "The opponent is selecting 1 card to trash.");
  194. yield return StartCoroutine(selectHandEffect.Activate());
  195. yield return StartCoroutine(ActivatePlacingSource());
  196. }
  197. IEnumerator ActivatePlacingSource()
  198. {
  199. ActivateClass activateClass = new ActivateClass();
  200. activateClass.SetUpICardEffect("Place a Card from hand to digivolution cards to get effects", CanUseCondition, card);
  201. activateClass.SetUpActivateClass(CanActivateThenCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  202. cardEffects.Add(activateClass);
  203. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. selectCardEffect.SetUp(
  206. canTargetCondition: CanSelectSharedCardCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. canNoSelect: () => true,
  210. selectCardCoroutine: SelectCardCoroutine,
  211. afterSelectCardCoroutine: null,
  212. message: "Select 1 card to place at the bottom of digivolution cards.",
  213. maxCount: 1,
  214. canEndNotMax: false,
  215. isShowOpponent: true,
  216. mode: SelectCardEffect.Mode.Custom,
  217. root: SelectCardEffect.Root.Trash,
  218. customRootCardList: null,
  219. canLookReverseCard: true,
  220. selectPlayer: card.Owner,
  221. cardEffect: activateClass);
  222. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  223. yield return StartCoroutine(selectCardEffect.Activate());
  224. IEnumerator SelectCardCoroutine(CardSource cardSource)
  225. {
  226. selectedCards.Add(cardSource);
  227. yield return null;
  228. }
  229. if (selectedCards.Count >= 1)
  230. {
  231. Permanent selectedPermanent = card.PermanentOfThisCard();
  232. if (selectedPermanent != null)
  233. {
  234. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  235. }
  236. }
  237. }
  238. }
  239. #endregion
  240. #region All Turns
  241. if (timing == EffectTiming.OnAddDigivolutionCards)
  242. {
  243. ActivateClass activateClass = new ActivateClass();
  244. activateClass.SetUpICardEffect("Delete 1 Digimon, Play 1 Digimon", CanUseCondition, card);
  245. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  246. activateClass.SetHashString("Delete_Play_LM_017");
  247. cardEffects.Add(activateClass);
  248. string EffectDiscription()
  249. {
  250. return "[All Turns] [Once Per Turn] When an effect adds digivolution card to this Digimon, by deleting 1 level 4 or lower Digimon, you may play 1 level 4 or lower Digimon card from your trash without paying the cost.";
  251. }
  252. bool CanSelectPermanentCondition(Permanent permanent)
  253. {
  254. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  255. {
  256. return permanent.IsDigimon && permanent.Level <= 4;
  257. }
  258. return false;
  259. }
  260. bool CanUseCondition(Hashtable hashtable)
  261. {
  262. if (CardEffectCommons.IsExistOnBattleArea(card))
  263. {
  264. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  265. hashtable: hashtable,
  266. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  267. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  268. cardCondition: null))
  269. {
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. bool CanActivateCondition(Hashtable hashtable)
  276. {
  277. return CardEffectCommons.IsExistOnBattleArea(card);
  278. }
  279. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  280. {
  281. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  282. List<Permanent> selectedCards = new List<Permanent>();
  283. selectPermanentEffect.SetUp(
  284. selectPlayer: card.Owner,
  285. canTargetCondition: CanSelectPermanentCondition,
  286. canTargetCondition_ByPreSelecetedList: null,
  287. canEndSelectCondition: null,
  288. canNoSelect: true,
  289. selectPermanentCoroutine: SelectPermanentCoroutine,
  290. afterSelectPermanentCoroutine: null,
  291. maxCount: 1,
  292. canEndNotMax: false,
  293. mode: SelectPermanentEffect.Mode.Destroy,
  294. cardEffect: activateClass);
  295. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to delete.", "The opponent is selecting 1 digimon to delete.");
  296. yield return StartCoroutine(selectPermanentEffect.Activate());
  297. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  298. {
  299. selectedCards.Add(permanent);
  300. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: selectedCards, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  301. yield return null;
  302. }
  303. IEnumerator SuccessProcess()
  304. {
  305. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  306. List<CardSource> selectedCards = new List<CardSource>();
  307. bool CanSelectCardCondition(CardSource cardSource)
  308. {
  309. if (CardEffectCommons.IsExistOnTrash(cardSource))
  310. {
  311. if (cardSource.Owner == card.Owner)
  312. {
  313. return cardSource.IsDigimon && cardSource.Level <= 4;
  314. }
  315. }
  316. return false;
  317. }
  318. selectCardEffect.SetUp(
  319. canTargetCondition: CanSelectCardCondition,
  320. canTargetCondition_ByPreSelecetedList: null,
  321. canEndSelectCondition: null,
  322. canNoSelect: () => true,
  323. selectCardCoroutine: SelectCardCoroutine,
  324. afterSelectCardCoroutine: null,
  325. message: "Select 1 Digimon card to play.",
  326. maxCount: 1,
  327. canEndNotMax: false,
  328. isShowOpponent: true,
  329. mode: SelectCardEffect.Mode.Custom,
  330. root: SelectCardEffect.Root.Trash,
  331. customRootCardList: null,
  332. canLookReverseCard: true,
  333. selectPlayer: card.Owner,
  334. cardEffect: activateClass);
  335. selectCardEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon card to play.");
  336. yield return StartCoroutine(selectCardEffect.Activate());
  337. IEnumerator SelectCardCoroutine(CardSource cardSource)
  338. {
  339. selectedCards.Add(cardSource);
  340. yield return null;
  341. }
  342. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  343. cardSources: selectedCards,
  344. activateClass: activateClass,
  345. payCost: false,
  346. isTapped: false,
  347. root: SelectCardEffect.Root.Trash,
  348. activateETB: true));
  349. }
  350. }
  351. }
  352. #endregion
  353. return cardEffects;
  354. }
  355. }
  356. }