ST17_13.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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.ST17
  9. {
  10. public class ST17_13 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Blocker and Armor Purge
  16. if (timing == EffectTiming.None)
  17. {
  18. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  21. {
  22. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card: card));
  23. }
  24. #endregion
  25. #region Digivolution Condition
  26. if (timing == EffectTiming.None)
  27. {
  28. bool PermanentCondition(Permanent targetPermanent)
  29. {
  30. if ((targetPermanent.TopCard.CardNames.Contains("Veemon")))
  31. {
  32. return true;
  33. }
  34. return false;
  35. }
  36. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  37. }
  38. #endregion
  39. #region Security Effect
  40. if (timing == EffectTiming.SecuritySkill)
  41. {
  42. #region De-Digivolve
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("De-Digivolve 1 to 1 Digimon", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  46. activateClass.SetIsSecurityEffect(true);
  47. activateClass.SetIsDigimonEffect(true);
  48. cardEffects.Add(activateClass);
  49. string EffectDiscription()
  50. {
  51. return "[Security] <De-Digivolve 1> 1 Digimon. At the end of the battle, 1 of your Digimon may digivolve into this card without paying the digivolution cost.";
  52. }
  53. bool CanSelectPermanentCondition(Permanent permanent)
  54. {
  55. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnExecutingArea(card);
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable1)
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. Permanent selectedPermanent = permanent;
  88. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  89. }
  90. }
  91. }
  92. #endregion
  93. #region Digivolve into this card
  94. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  95. ActivateClass activateClassDigivolve = new ActivateClass();
  96. activateClassDigivolve.SetUpICardEffect("Digivolve into this Digimon", CanUseConditionAfterBattle, card);
  97. activateClassDigivolve.SetUpActivateClass(null, ActivateCoroutineAfterBattle, -1, true, EffectDiscriptionAfterBattle());
  98. activateClass.SetIsSecurityEffect(true);
  99. activateClass.SetIsDigimonEffect(true);
  100. card.Owner.UntilEndBattleEffects.Add(GetCardEffectAfterBattle);
  101. string EffectDiscriptionAfterBattle()
  102. {
  103. return "[Security] At the end of the battle, 1 of your Digimon may digivolve into this card without paying the digivolution cost.";
  104. }
  105. bool CanSelectCardConditionAferBattle(CardSource cardSource)
  106. {
  107. return cardSource == card;
  108. }
  109. bool CanSelectPermanentConditionAfterBattle(Permanent permanent)
  110. {
  111. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  112. {
  113. if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClassDigivolve, root: SelectCardEffect.Root.Execution))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseConditionAfterBattle(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionAfterBattle);
  123. }
  124. IEnumerator ActivateCoroutineAfterBattle(Hashtable _hashtable)
  125. {
  126. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionAfterBattle))
  127. {
  128. Permanent selectedPermanent = null;
  129. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionAfterBattle));
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectPermanentConditionAfterBattle,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: maxCount,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: SelectPermanentCoroutine,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Custom,
  142. cardEffect: activateClass);
  143. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  144. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  145. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  146. {
  147. selectedPermanent = permanent;
  148. yield return null;
  149. }
  150. if (selectedPermanent != null)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoExcecutingAreaCard(
  153. targetPermanent: selectedPermanent,
  154. cardCondition: CanSelectCardConditionAferBattle,
  155. payCost: false,
  156. reduceCostTuple: null,
  157. fixedCostTuple: null,
  158. ignoreDigivolutionRequirementFixedCost: -1,
  159. activateClass: activateClass,
  160. successProcess: null));
  161. }
  162. }
  163. }
  164. ICardEffect GetCardEffectAfterBattle(EffectTiming _timing)
  165. {
  166. if (_timing == EffectTiming.OnEndBattle)
  167. {
  168. return activateClassDigivolve;
  169. }
  170. return null;
  171. }
  172. #endregion
  173. }
  174. #endregion
  175. #region When Digivolving
  176. if (timing == EffectTiming.OnEnterFieldAnyone)
  177. {
  178. ActivateClass activateClass = new ActivateClass();
  179. activateClass.SetUpICardEffect("Trash digivolution cards", CanUseCondition, card);
  180. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  181. activateClass.SetIsDigimonEffect(true);
  182. cardEffects.Add(activateClass);
  183. string EffectDiscription()
  184. {
  185. return "[When Digivolving] For each color of 1 of your opponent's Digimon has, trash that Digimon's top digivolution card. Then, return 1 of your opponent's Digimon without digivolution cards to the hand.";
  186. }
  187. bool CanSelectPermanentCondition(Permanent permanent)
  188. {
  189. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  190. }
  191. bool CanSelectPermanentCondition1(Permanent permanent)
  192. {
  193. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  194. {
  195. if (permanent.HasNoDigivolutionCards)
  196. {
  197. return true;
  198. }
  199. }
  200. return false;
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  211. {
  212. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  213. {
  214. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  215. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  216. selectPermanentEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: CanSelectPermanentCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: maxCount,
  222. canNoSelect: false,
  223. canEndNotMax: false,
  224. selectPermanentCoroutine: SelectPermanentCoroutine,
  225. afterSelectPermanentCoroutine: null,
  226. mode: SelectPermanentEffect.Mode.Custom,
  227. cardEffect: activateClass);
  228. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  229. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  230. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  231. {
  232. Permanent selectedPermanent = permanent;
  233. int count()
  234. {
  235. return selectedPermanent.TopCard.CardColors.Count();
  236. }
  237. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: count(), isFromTop: true, activateClass: activateClass));
  238. }
  239. }
  240. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  241. {
  242. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  243. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  244. selectPermanentEffect1.SetUp(
  245. selectPlayer: card.Owner,
  246. canTargetCondition: CanSelectPermanentCondition1,
  247. canTargetCondition_ByPreSelecetedList: null,
  248. canEndSelectCondition: null,
  249. maxCount: maxCount1,
  250. canNoSelect: false,
  251. canEndNotMax: false,
  252. selectPermanentCoroutine: null,
  253. afterSelectPermanentCoroutine: null,
  254. mode: SelectPermanentEffect.Mode.Bounce,
  255. cardEffect: activateClass);
  256. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  257. }
  258. }
  259. }
  260. #endregion
  261. return cardEffects;
  262. }
  263. }
  264. }