ST10_06.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class ST10_06 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  16. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  17. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  18. addJogressConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addJogressConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. JogressCondition GetJogress(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool PermanentCondition1(Permanent permanent)
  29. {
  30. if (permanent != null)
  31. {
  32. if (permanent.TopCard != null)
  33. {
  34. if (permanent.TopCard.Owner == card.Owner)
  35. {
  36. if (permanent.IsDigimon)
  37. {
  38. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  39. {
  40. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  41. {
  42. if (permanent.Levels_ForJogress(card).Contains(5))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool PermanentCondition2(Permanent permanent)
  55. {
  56. if (permanent != null)
  57. {
  58. if (permanent.TopCard != null)
  59. {
  60. if (permanent.TopCard.Owner == card.Owner)
  61. {
  62. if (permanent.IsDigimon)
  63. {
  64. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  65. {
  66. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  67. {
  68. if (permanent.Levels_ForJogress(card).Contains(5))
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. JogressConditionElement[] elements = new JogressConditionElement[]
  81. {
  82. new JogressConditionElement(PermanentCondition1, "a level 5 yellow Digimon"),
  83. new JogressConditionElement(PermanentCondition2, "a level 5 purple Digimon"),
  84. };
  85. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  86. return jogressCondition;
  87. }
  88. return null;
  89. }
  90. }
  91. if (timing == EffectTiming.OnEnterFieldAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Add 1 Security from trash and play 1 Digimon from security", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[When Digivolving] Place 1 yellow or purple Digimon card from your trash on top of your security stack face down. When DNA digivolving, you may search your security stack for 1 level 5 or lower Digimon card and play it without paying its memory cost. Then, shuffle your security stack.";
  100. }
  101. bool CanSelectCardCondition(CardSource cardSource)
  102. {
  103. if (cardSource.IsDigimon)
  104. {
  105. if (cardSource.HasCardColor(CardColor.Yellow))
  106. {
  107. return true;
  108. }
  109. if (cardSource.HasCardColor(CardColor.Purple))
  110. {
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. bool CanSelectCardCondition1(CardSource cardSource)
  117. {
  118. if (cardSource.IsDigimon)
  119. {
  120. if (cardSource.HasLevel)
  121. {
  122. if (cardSource.Level <= 5)
  123. {
  124. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  125. {
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.IsExistOnBattleArea(card))
  140. {
  141. return true;
  142. }
  143. return false;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  146. {
  147. if (card.Owner.CanAddSecurity(activateClass))
  148. {
  149. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  150. {
  151. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  152. List<CardSource> selectedCards = new List<CardSource>();
  153. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  154. selectCardEffect.SetUp(
  155. canTargetCondition: CanSelectCardCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. canNoSelect: () => false,
  159. selectCardCoroutine: SelectCardCoroutine,
  160. afterSelectCardCoroutine: null,
  161. message: "Select 1 yellow or purple Digimon card to add to security.",
  162. maxCount: maxCount,
  163. canEndNotMax: false,
  164. isShowOpponent: true,
  165. mode: SelectCardEffect.Mode.Custom,
  166. root: SelectCardEffect.Root.Trash,
  167. customRootCardList: null,
  168. canLookReverseCard: true,
  169. selectPlayer: card.Owner,
  170. cardEffect: activateClass);
  171. selectCardEffect.SetUpCustomMessage("Select 1 card to add to security.", "The opponent is selecting 1 card to add to security.");
  172. selectCardEffect.SetUpCustomMessage_ShowCard("Security Card");
  173. yield return StartCoroutine(selectCardEffect.Activate());
  174. IEnumerator SelectCardCoroutine(CardSource cardSource)
  175. {
  176. selectedCards.Add(cardSource);
  177. yield return null;
  178. }
  179. if (selectedCards.Count >= 1)
  180. {
  181. foreach (CardSource selectedCard in selectedCards)
  182. {
  183. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard));
  184. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateRecoveryEffect(selectedCard.Owner));
  185. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(selectedCard).AddSecurity());
  186. }
  187. }
  188. }
  189. }
  190. if (CardEffectCommons.IsJogress(_hashtable))
  191. {
  192. if (card.Owner.SecurityCards.Count >= 1)
  193. {
  194. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count(CanSelectCardCondition1));
  195. List<CardSource> selectedCards = new List<CardSource>();
  196. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  197. selectCardEffect.SetUp(
  198. canTargetCondition: CanSelectCardCondition1,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. canNoSelect: () => true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  204. message: "Select 1 card to play.",
  205. maxCount: maxCount,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. mode: SelectCardEffect.Mode.Custom,
  209. root: SelectCardEffect.Root.Security,
  210. customRootCardList: null,
  211. canLookReverseCard: true,
  212. selectPlayer: card.Owner,
  213. cardEffect: activateClass);
  214. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  215. IEnumerator SelectCardCoroutine(CardSource cardSource)
  216. {
  217. selectedCards.Add(cardSource);
  218. yield return null;
  219. }
  220. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  221. {
  222. if (cardSources.Count >= 1)
  223. {
  224. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  225. player: card.Owner,
  226. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  227. activateClass).ReduceSecurity());
  228. }
  229. yield return null;
  230. }
  231. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  232. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  233. cardSources: selectedCards,
  234. activateClass: activateClass,
  235. payCost: false,
  236. isTapped: false,
  237. root: SelectCardEffect.Root.Security,
  238. activateETB: true));
  239. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  240. if (card.Owner.SecurityCards.Count >= 1)
  241. {
  242. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  243. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  244. }
  245. }
  246. }
  247. }
  248. }
  249. if (timing == EffectTiming.OnEnterFieldAnyone)
  250. {
  251. int maxLevel = -1;
  252. ActivateClass activateClass = new ActivateClass();
  253. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  254. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  255. cardEffects.Add(activateClass);
  256. string EffectDiscription()
  257. {
  258. return "[All Turns] When you play another Digimon using an effect, delete 1 of your opponent's Digimon whose level is less than or equal to the played Digimon's level.";
  259. }
  260. bool PermanentCondition(Permanent permanent)
  261. {
  262. return CardEffectCommons.IsOwnerPermanent(permanent, card) &&
  263. permanent.IsDigimon &&
  264. permanent != card.PermanentOfThisCard();
  265. }
  266. bool CanSelectPermanentCondition(Permanent permanent)
  267. {
  268. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  269. {
  270. if (permanent.TopCard.HasLevel)
  271. {
  272. if (permanent.Level <= maxLevel)
  273. {
  274. return true;
  275. }
  276. }
  277. }
  278. return false;
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. if (CardEffectCommons.IsExistOnBattleArea(card))
  283. {
  284. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  285. {
  286. if (CardEffectCommons.IsByEffect(hashtable, null))
  287. {
  288. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  289. hashtable: hashtable,
  290. rootCondition: null);
  291. if (permanents != null)
  292. {
  293. List<int> levels = permanents
  294. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  295. .Map(permanent => permanent.LevelJustAfterPlayed);
  296. if (levels.Count >= 1)
  297. {
  298. maxLevel = levels.Max();
  299. }
  300. }
  301. return true;
  302. }
  303. }
  304. }
  305. return false;
  306. }
  307. bool CanActivateCondition(Hashtable hashtable)
  308. {
  309. if (CardEffectCommons.IsExistOnBattleArea(card))
  310. {
  311. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  312. {
  313. return true;
  314. }
  315. }
  316. return false;
  317. }
  318. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  319. {
  320. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  321. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  322. selectPermanentEffect.SetUp(
  323. selectPlayer: card.Owner,
  324. canTargetCondition: CanSelectPermanentCondition,
  325. canTargetCondition_ByPreSelecetedList: null,
  326. canEndSelectCondition: null,
  327. maxCount: maxCount,
  328. canNoSelect: false,
  329. canEndNotMax: false,
  330. selectPermanentCoroutine: null,
  331. afterSelectPermanentCoroutine: null,
  332. mode: SelectPermanentEffect.Mode.Destroy,
  333. cardEffect: activateClass);
  334. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  335. }
  336. }
  337. return cardEffects;
  338. }
  339. }