ST13_06.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. namespace DCGO.CardEffects.ST13
  9. {
  10. public class ST13_06 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region DNA Requirements
  16. if (timing == EffectTiming.None)
  17. {
  18. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  19. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  20. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  21. addJogressConditionClass.SetNotShowUI(true);
  22. cardEffects.Add(addJogressConditionClass);
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return true;
  26. }
  27. JogressCondition GetJogress(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. bool PermanentCondition1(Permanent permanent)
  32. {
  33. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  34. {
  35. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  36. {
  37. if (permanent.Levels_ForJogress(card).Contains(6))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. bool PermanentCondition2(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.TopCard.CardColors.Contains(CardColor.Black))
  50. {
  51. if (permanent.Levels_ForJogress(card).Contains(6))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. JogressConditionElement[] elements = new JogressConditionElement[]
  60. {
  61. new JogressConditionElement(PermanentCondition1, "a level 6 red Digimon"),
  62. new JogressConditionElement(PermanentCondition2, "a level 6 black Digimon"),
  63. };
  64. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  65. return jogressCondition;
  66. }
  67. return null;
  68. }
  69. }
  70. #endregion
  71. #region When Digivolving
  72. if (timing == EffectTiming.OnEnterFieldAnyone)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Blitz, delete Digimon and trash opponent's Security", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  77. cardEffects.Add(activateClass);
  78. string EffectDiscription()
  79. {
  80. return "[When Digivolving] <Blitz> (This Digimon can attack when your opponent has 1 or more memory.) When DNA digivolving, for every 4 cards in this Digimon's digivolution cards, delete 1 of your opponent's Digimon with a play cost of 20 or less and trash the top card of your opponent's security stack.";
  81. }
  82. int count()
  83. {
  84. int count = 0;
  85. if (CardEffectCommons.IsExistOnBattleArea(card))
  86. {
  87. count = card.PermanentOfThisCard().DigivolutionCards.Count / 4;
  88. }
  89. return count;
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent)
  92. {
  93. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  94. {
  95. if (permanent.TopCard.GetCostItself <= 20)
  96. {
  97. if (permanent.TopCard.HasPlayCost)
  98. {
  99. return true;
  100. }
  101. }
  102. }
  103. return false;
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  108. {
  109. return true;
  110. }
  111. return false;
  112. }
  113. bool CanActivateCondition(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.IsExistOnBattleArea(card))
  116. {
  117. if (CardEffectCommons.CanActivateBlitz(card, activateClass))
  118. {
  119. return true;
  120. }
  121. if (CardEffectCommons.IsJogress(hashtable))
  122. {
  123. if (count() >= 1)
  124. {
  125. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  126. {
  127. return true;
  128. }
  129. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  139. {
  140. if (CardEffectCommons.CanActivateBlitz(card, activateClass))
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BlitzProcess(card, activateClass, BeforeOnAttackCoroutine));
  143. IEnumerator BeforeOnAttackCoroutine()
  144. {
  145. if (CardEffectCommons.IsJogress(_hashtable))
  146. {
  147. if (count() >= 1)
  148. {
  149. int maxCount = Math.Min(count(), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: maxCount,
  157. canNoSelect: false,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: null,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.Destroy,
  162. cardEffect: activateClass);
  163. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  164. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  165. player: card.Owner.Enemy,
  166. destroySecurityCount: count(),
  167. cardEffect: activateClass,
  168. fromTop: true).DestroySecurity());
  169. }
  170. }
  171. }
  172. if(GManager.instance.attackProcess.IsAttacking && GManager.instance.attackProcess.AttackingPermanent == card.PermanentOfThisCard())
  173. {
  174. if (CardEffectCommons.IsJogress(_hashtable))
  175. {
  176. if (count() >= 1)
  177. {
  178. int maxCount = Math.Min(count(), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: null,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Destroy,
  191. cardEffect: activateClass);
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  194. player: card.Owner.Enemy,
  195. destroySecurityCount: count(),
  196. cardEffect: activateClass,
  197. fromTop: true).DestroySecurity());
  198. }
  199. }
  200. }
  201. }
  202. else
  203. {
  204. if (CardEffectCommons.IsJogress(_hashtable))
  205. {
  206. if (count() >= 1)
  207. {
  208. int maxCount = Math.Min(count(), CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  209. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  210. selectPermanentEffect.SetUp(
  211. selectPlayer: card.Owner,
  212. canTargetCondition: CanSelectPermanentCondition,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. maxCount: maxCount,
  216. canNoSelect: false,
  217. canEndNotMax: false,
  218. selectPermanentCoroutine: null,
  219. afterSelectPermanentCoroutine: null,
  220. mode: SelectPermanentEffect.Mode.Destroy,
  221. cardEffect: activateClass);
  222. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  223. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  224. player: card.Owner.Enemy,
  225. destroySecurityCount: count(),
  226. cardEffect: activateClass,
  227. fromTop: true).DestroySecurity());
  228. }
  229. }
  230. }
  231. }
  232. }
  233. #endregion
  234. #region All Turns
  235. if (timing == EffectTiming.OnLoseSecurity)
  236. {
  237. ActivateClass activateClass = new ActivateClass();
  238. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  239. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  240. activateClass.SetHashString("Unsuspend_ ST13_06");
  241. cardEffects.Add(activateClass);
  242. string EffectDiscription()
  243. {
  244. return "[All Turns][Once Per Turn] When a card is removed from a player's security stack, unsuspend this Digimon.";
  245. }
  246. bool CanUseCondition(Hashtable hashtable)
  247. {
  248. if (CardEffectCommons.IsExistOnBattleArea(card))
  249. {
  250. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => true))
  251. {
  252. return true;
  253. }
  254. }
  255. return false;
  256. }
  257. bool CanActivateCondition(Hashtable hashtable)
  258. {
  259. if (CardEffectCommons.IsExistOnBattleArea(card))
  260. {
  261. return true;
  262. }
  263. return false;
  264. }
  265. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  266. {
  267. Permanent selectedPermanent = card.PermanentOfThisCard();
  268. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  269. }
  270. }
  271. #endregion
  272. return cardEffects;
  273. }
  274. }
  275. }