YellowScramble_LM_029.cs 17 KB

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