LM_017.cs 19 KB

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