LM_005.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class LM_005 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. //Counter Timing
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  16. }
  17. #region On Play/When Digivolving Shared
  18. bool CanSelectCardTrashingCondition(CardSource cardSource)
  19. {
  20. if (cardSource.HasCardColor(CardColor.Blue))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. #region trashing sources conditions
  27. bool CanSelectBounceCondition(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  30. {
  31. if(permanent.IsDigimon || permanent.IsTamer)
  32. {
  33. if (permanent.DigivolutionCards.Count() == 0)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. #endregion
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (card.Owner.HandCards.Count >= 1)
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. #endregion
  54. #region On Play
  55. if (timing == EffectTiming.OnEnterFieldAnyone)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Trash sources, return 1 Digimon/Tamer to hand", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  60. cardEffects.Add(activateClass);
  61. string EffectDiscription()
  62. {
  63. return "[On Play] You may trash up to 4 blue cards in your hand. For each one, trash any 1 card under your opponent's Digimon or Tamers. Then, return 1 of their Digimon or Tamers without cards under it to the hand.";
  64. }
  65. bool CanSelectCardCondition(CardSource cardSource)
  66. {
  67. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  68. }
  69. bool CanSelectPermanentCondition(Permanent permanent)
  70. {
  71. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  72. {
  73. if (!permanent.TopCard.IsDigiEgg || !permanent.TopCard.IsOption)
  74. {
  75. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  76. {
  77. return true;
  78. }
  79. }
  80. }
  81. return false;
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  88. {
  89. List<CardSource> discardedCards = new List<CardSource>();
  90. int maxCount = Math.Min(4, card.Owner.HandCards.Count(CanSelectCardCondition));
  91. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  92. selectHandEffect.SetUp(
  93. selectPlayer: card.Owner,
  94. canTargetCondition: CanSelectCardTrashingCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. maxCount: maxCount,
  98. canNoSelect: true,
  99. canEndNotMax: true,
  100. isShowOpponent: true,
  101. selectCardCoroutine: null,
  102. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  103. mode: SelectHandEffect.Mode.Discard,
  104. cardEffect: activateClass);
  105. yield return StartCoroutine(selectHandEffect.Activate());
  106. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  107. {
  108. discardedCards = cardSources.Clone();
  109. yield return null;
  110. }
  111. foreach (CardSource cardSource in discardedCards)
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  114. permanentCondition: CanSelectPermanentCondition,
  115. cardCondition: CanSelectCardCondition,
  116. maxCount: 1,
  117. canNoTrash: false,
  118. isFromOnly1Permanent: true,
  119. activateClass: activateClass
  120. ));
  121. }
  122. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectBounceCondition))
  123. {
  124. int maxBounceCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectBounceCondition));
  125. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectBounceCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxBounceCount,
  132. canNoSelect: false,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: null,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Bounce,
  137. cardEffect: activateClass);
  138. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  139. }
  140. }
  141. }
  142. #endregion
  143. #region When Digivolving
  144. if (timing == EffectTiming.OnEnterFieldAnyone)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Trash sources, return 1 Digimon/Tamer to hand", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[When Digivolving] You may trash up to 4 blue cards in your hand. For each one, trash any 1 card under your opponent's Digimon or Tamers. Then, return 1 of their Digimon or Tamers without cards under it to the hand.";
  153. }
  154. bool CanSelectCardCondition(CardSource cardSource)
  155. {
  156. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  157. }
  158. bool CanSelectPermanentCondition(Permanent permanent)
  159. {
  160. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  161. {
  162. if (permanent.IsDigimon || permanent.IsTamer)
  163. {
  164. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  165. {
  166. return true;
  167. }
  168. }
  169. }
  170. return false;
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  175. }
  176. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  177. {
  178. List<CardSource> discardedCards = new List<CardSource>();
  179. int maxCount = Math.Min(4, card.Owner.HandCards.Count(CanSelectCardCondition));
  180. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  181. selectHandEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectCardTrashingCondition,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: maxCount,
  187. canNoSelect: true,
  188. canEndNotMax: true,
  189. isShowOpponent: true,
  190. selectCardCoroutine: null,
  191. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  192. mode: SelectHandEffect.Mode.Discard,
  193. cardEffect: activateClass);
  194. yield return StartCoroutine(selectHandEffect.Activate());
  195. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  196. {
  197. discardedCards = cardSources.Clone();
  198. yield return null;
  199. }
  200. foreach (CardSource cardSource in discardedCards)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  203. permanentCondition: CanSelectPermanentCondition,
  204. cardCondition: CanSelectCardCondition,
  205. maxCount: 1,
  206. canNoTrash: false,
  207. isFromOnly1Permanent: true,
  208. activateClass: activateClass
  209. ));
  210. }
  211. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectBounceCondition))
  212. {
  213. int maxBounceCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectBounceCondition));
  214. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  215. selectPermanentEffect.SetUp(
  216. selectPlayer: card.Owner,
  217. canTargetCondition: CanSelectBounceCondition,
  218. canTargetCondition_ByPreSelecetedList: null,
  219. canEndSelectCondition: null,
  220. maxCount: maxBounceCount,
  221. canNoSelect: false,
  222. canEndNotMax: false,
  223. selectPermanentCoroutine: null,
  224. afterSelectPermanentCoroutine: null,
  225. mode: SelectPermanentEffect.Mode.Bounce,
  226. cardEffect: activateClass);
  227. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  228. }
  229. }
  230. }
  231. #endregion
  232. #region When Attacking
  233. if (timing == EffectTiming.OnAllyAttack)
  234. {
  235. ActivateClass activateClass = new ActivateClass();
  236. activateClass.SetUpICardEffect("Security Attack +1", CanUseCondition, card);
  237. activateClass.SetUpActivateClass(CanActivateAttackCondition, ActivateCoroutine, -1, true, AttackDescription());
  238. cardEffects.Add(activateClass);
  239. string AttackDescription()
  240. {
  241. return "[When Attacking] By returning 3 cards with [Jellymon] in their texts from your trash to the bottom of your deck, this Digimon gains <Security A. +1> for the turn.";
  242. }
  243. bool CanSelectTrashCardCondition(CardSource cardSource)
  244. {
  245. return cardSource.HasText("Jellymon");
  246. }
  247. bool CanUseCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  250. }
  251. bool CanActivateAttackCondition(Hashtable hashtable)
  252. {
  253. if (CardEffectCommons.IsExistOnBattleArea(card))
  254. {
  255. if (card.Owner.TrashCards.Where(CanSelectTrashCardCondition).Count() >= 3)
  256. {
  257. return true;
  258. }
  259. }
  260. return false;
  261. }
  262. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  263. {
  264. bool returned = false;
  265. if (CardEffectCommons.IsExistOnBattleArea(card))
  266. {
  267. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  268. selectCardEffect.SetUp(
  269. canTargetCondition: CanSelectTrashCardCondition,
  270. canTargetCondition_ByPreSelecetedList: null,
  271. canEndSelectCondition: null,
  272. canNoSelect: () => false,
  273. selectCardCoroutine: null,
  274. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  275. message: "Select 1 card to return to the bottom of deck.",
  276. maxCount: 3,
  277. canEndNotMax: false,
  278. isShowOpponent: true,
  279. mode: SelectCardEffect.Mode.Custom,
  280. root: SelectCardEffect.Root.Trash,
  281. customRootCardList: null,
  282. canLookReverseCard: true,
  283. selectPlayer: card.Owner,
  284. cardEffect: activateClass);
  285. yield return StartCoroutine(selectCardEffect.Activate());
  286. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  287. {
  288. if (cardSources.Count == 3)
  289. {
  290. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  291. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  292. returned = true;
  293. }
  294. }
  295. }
  296. if (returned)
  297. {
  298. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  299. targetPermanent: GManager.instance.attackProcess.AttackingPermanent,
  300. changeValue: 1,
  301. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  302. activateClass: activateClass));
  303. }
  304. }
  305. }
  306. #endregion
  307. return cardEffects;
  308. }
  309. }
  310. }