BlueScramble_LM_028.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 BlueScramble_LM_028 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Digivolve into a blue Digimon from hand with reduced cost", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Main] 1 of your blue Digimon may digivolve into a blue Digimon card in the hand with the digivolution cost reduced by 3. Then, place this card in the battle area.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. bool CanSelectHandCardCondition(CardSource cardSource)
  28. {
  29. return cardSource.IsDigimon && cardSource.CardColors.Contains(CardColor.Blue);
  30. }
  31. bool CanSelectOwnPermanentCondition(Permanent permanent)
  32. {
  33. return CanSelectHandCardCondition(permanent.TopCard) &&
  34. card.Owner.HandCards.Where(CanSelectHandCardCondition).Any(cardSource => cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  39. {
  40. Permanent selectedPermanent = null;
  41. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: CanSelectOwnPermanentCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: 1,
  48. canNoSelect: true,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. selectPermanentEffect.SetUpCustomMessage("Select 1 blue Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  55. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  56. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  57. {
  58. selectedPermanent = permanent;
  59. yield return null;
  60. }
  61. if (selectedPermanent != null)
  62. {
  63. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  64. targetPermanent: selectedPermanent,
  65. cardCondition: CanSelectHandCardCondition,
  66. payCost: true,
  67. reduceCostTuple: (reduceCost: 3, reduceCostCardCondition: null),
  68. fixedCostTuple: null,
  69. ignoreDigivolutionRequirementFixedCost: -1,
  70. isHand: true,
  71. activateClass: activateClass,
  72. successProcess: null));
  73. }
  74. }
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  76. }
  77. }
  78. #endregion
  79. #region Main Delay
  80. if (timing == EffectTiming.OnStartTurn)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect("Return a blue Digimon to top of the deck from trash, then play a blue Digimon from trash.", CanUseCondition, card);
  84. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  85. cardEffects.Add(activateClass);
  86. string EffectDiscription()
  87. {
  88. return "[Start of your Turn] If your opponent has a Digimon, <Delay>.\r\n• Return 1 blue Digimon card from your trash to the top of the deck. Then, if you don't have a Digimon, you may play 1 blue Digimon card with 2000 DP or less from your trash without paying the cost.";
  89. }
  90. bool CanSelectCardCondition(CardSource cardSource)
  91. {
  92. return cardSource.IsDigimon && cardSource.CardColors.Contains(CardColor.Blue);
  93. }
  94. bool CanSelectCardCondition1(CardSource cardSource)
  95. {
  96. if (cardSource != null)
  97. {
  98. if (cardSource.Owner == card.Owner)
  99. {
  100. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  101. {
  102. if (cardSource.IsDigimon)
  103. {
  104. if (cardSource.CardColors.Contains(CardColor.Blue) && cardSource.CardDP <= 2000)
  105. {
  106. return true;
  107. }
  108. }
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsOwnerTurn(card) &&
  117. CardEffectCommons.IsExistOnBattleArea(card) &&
  118. card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1 &&
  119. CardEffectCommons.CanDeclareOptionDelayEffect(card);
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable hashtable)
  122. {
  123. bool deleted = false;
  124. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  125. IEnumerator SuccessProcess()
  126. {
  127. deleted = true;
  128. yield return null;
  129. }
  130. if (deleted)
  131. {
  132. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  133. {
  134. int maxCount = 1;
  135. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  136. selectCardEffect.SetUp(
  137. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. canNoSelect: () => true,
  141. selectCardCoroutine: null,
  142. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  143. message: "Select a blue Digimon to place at the top of the deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).",
  144. maxCount: maxCount,
  145. canEndNotMax: false,
  146. isShowOpponent: false,
  147. mode: SelectCardEffect.Mode.Custom,
  148. root: SelectCardEffect.Root.Trash,
  149. customRootCardList: null,
  150. canLookReverseCard: true,
  151. selectPlayer: card.Owner,
  152. cardEffect: activateClass);
  153. selectCardEffect.SetNotAddLog();
  154. selectCardEffect.SetUpCustomMessage_ShowCard("Deck Top Cards");
  155. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  156. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  157. {
  158. if (cardSources.Count == 1)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(cardSources));
  161. }
  162. }
  163. }
  164. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition1(cardSource)))
  165. {
  166. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition1(cardSource)));
  167. List<CardSource> selectedCards = new List<CardSource>();
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. selectCardEffect.SetUp(
  170. canTargetCondition: CanSelectCardCondition1,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. canNoSelect: () => true,
  174. selectCardCoroutine: SelectCardCoroutine,
  175. afterSelectCardCoroutine: null,
  176. message: "Select 1 blue Digimon with 2000 DP or less to play.",
  177. maxCount: maxCount,
  178. canEndNotMax: false,
  179. isShowOpponent: true,
  180. mode: SelectCardEffect.Mode.Custom,
  181. root: SelectCardEffect.Root.Trash,
  182. customRootCardList: null,
  183. canLookReverseCard: true,
  184. selectPlayer: card.Owner,
  185. cardEffect: activateClass);
  186. selectCardEffect.SetUpCustomMessage("Select 1 blue Digimon with 2000 DP or less to play.", "The opponent is selecting 1 card to play.");
  187. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  188. yield return StartCoroutine(selectCardEffect.Activate());
  189. IEnumerator SelectCardCoroutine(CardSource cardSource)
  190. {
  191. selectedCards.Add(cardSource);
  192. yield return null;
  193. }
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Security
  201. if (timing == EffectTiming.SecuritySkill)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect($"Play a blue Digimon from trash.", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  206. activateClass.SetIsSecurityEffect(true);
  207. cardEffects.Add(activateClass);
  208. string EffectDiscription()
  209. {
  210. return "[Security] You may play 1 blue Digimon card with 2000 DP or less from your trash without paying the cost. Then, add this card to the hand.";
  211. }
  212. bool CanSelectCardCondition(CardSource cardSource)
  213. {
  214. if (cardSource != null)
  215. {
  216. if (cardSource.Owner == card.Owner)
  217. {
  218. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  219. {
  220. if (cardSource.IsDigimon)
  221. {
  222. if (cardSource.CardColors.Contains(CardColor.Blue) && cardSource.CardDP <= 2000)
  223. {
  224. return true;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. return false;
  231. }
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  237. {
  238. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  239. {
  240. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  241. List<CardSource> selectedCards = new List<CardSource>();
  242. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  243. selectCardEffect.SetUp(
  244. canTargetCondition: CanSelectCardCondition,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. canNoSelect: () => true,
  248. selectCardCoroutine: SelectCardCoroutine,
  249. afterSelectCardCoroutine: null,
  250. message: "Select 1 blue Digimon with 2000 DP or less to play.",
  251. maxCount: maxCount,
  252. canEndNotMax: false,
  253. isShowOpponent: true,
  254. mode: SelectCardEffect.Mode.Custom,
  255. root: SelectCardEffect.Root.Trash,
  256. customRootCardList: null,
  257. canLookReverseCard: true,
  258. selectPlayer: card.Owner,
  259. cardEffect: activateClass);
  260. selectCardEffect.SetUpCustomMessage("Select 1 blue Digimon with 2000 DP or less to play.", "The opponent is selecting 1 card to play.");
  261. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  262. yield return StartCoroutine(selectCardEffect.Activate());
  263. IEnumerator SelectCardCoroutine(CardSource cardSource)
  264. {
  265. selectedCards.Add(cardSource);
  266. yield return null;
  267. }
  268. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  269. }
  270. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  271. }
  272. }
  273. #endregion
  274. return cardEffects;
  275. }
  276. }
  277. }