Magnamon_ST17_13.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 Magnamon_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. cardEffects.Add(activateClass);
  48. string EffectDiscription()
  49. {
  50. 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.";
  51. }
  52. bool CanSelectPermanentCondition(Permanent permanent)
  53. {
  54. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  55. {
  56. if (permanent.IsDigimon)
  57. return true;
  58. }
  59. return false;
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.IsExistOnExecutingArea(card);
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable1)
  70. {
  71. yield return null;
  72. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  73. {
  74. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  75. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectPermanentCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: maxCount,
  82. canNoSelect: false,
  83. canEndNotMax: false,
  84. selectPermanentCoroutine: SelectPermanentCoroutine,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  91. {
  92. Permanent selectedPermanent = permanent;
  93. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  94. }
  95. }
  96. }
  97. #endregion
  98. #region Digivolve into this card
  99. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  100. ActivateClass activateClassDigivolve = new ActivateClass();
  101. activateClassDigivolve.SetUpICardEffect("Digivolve intto this Digimon", CanUseConditionAfterBattle, card);
  102. activateClassDigivolve.SetUpActivateClass(CanActivateConditionAfterBattle, ActivateCoroutineAfterBattle, -1, true, EffectDiscriptionAfterBattle());
  103. card.Owner.UntilEndBattleEffects.Add(GetCardEffectAfterBattle);
  104. string EffectDiscriptionAfterBattle()
  105. {
  106. return "[Security] At the end of the battle, 1 of your Digimon may digivolve into this card without paying the digivolution cost.";
  107. }
  108. bool CanSelectCardConditionAferBattle(CardSource cardSource)
  109. {
  110. return cardSource == card;
  111. }
  112. bool CanSelectPermanentConditionAfterBattle(Permanent permanent)
  113. {
  114. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  115. {
  116. if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClassDigivolve, root: SelectCardEffect.Root.Execution))
  117. {
  118. return true;
  119. }
  120. /*if ((permanent.IsDigimon && permanent.Level == 3 && card.CardColors.Contains(CardColor.Blue) || card.CardColors.Contains(CardColor.Black)) || (card.CardNames.Contains("Veemon") && permanent.Level == 3))
  121. {
  122. return true;
  123. }*/
  124. }
  125. return false;
  126. }
  127. bool CanUseConditionAfterBattle(Hashtable hashtable)
  128. {
  129. return true;
  130. }
  131. bool CanActivateConditionAfterBattle(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionAfterBattle))
  134. {
  135. return true;
  136. }
  137. return false;
  138. }
  139. IEnumerator ActivateCoroutineAfterBattle(Hashtable _hashtable)
  140. {
  141. yield return null;
  142. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionAfterBattle))
  143. {
  144. Permanent selectedPermanent = null;
  145. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionAfterBattle));
  146. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  147. selectPermanentEffect.SetUp(
  148. selectPlayer: card.Owner,
  149. canTargetCondition: CanSelectPermanentConditionAfterBattle,
  150. canTargetCondition_ByPreSelecetedList: null,
  151. canEndSelectCondition: null,
  152. maxCount: maxCount,
  153. canNoSelect: true,
  154. canEndNotMax: false,
  155. selectPermanentCoroutine: SelectPermanentCoroutine,
  156. afterSelectPermanentCoroutine: null,
  157. mode: SelectPermanentEffect.Mode.Custom,
  158. cardEffect: activateClass);
  159. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  160. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  161. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  162. {
  163. selectedPermanent = permanent;
  164. yield return null;
  165. }
  166. if (selectedPermanent != null)
  167. {
  168. if (card.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, false, activateClassDigivolve))
  169. {
  170. PlayCardClass playCardClass = new PlayCardClass(
  171. cardSources: new List<CardSource>() { card },
  172. hashtable: CardEffectCommons.CardEffectHashtable(activateClassDigivolve),
  173. payCost: false,
  174. targetPermanent: selectedPermanent,
  175. isTapped: false,
  176. root: SelectCardEffect.Root.Execution,
  177. activateETB: true);
  178. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  179. }
  180. /*yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoExcecutingAreaCard(
  181. targetPermanent: selectedPermanent,
  182. cardCondition: CanSelectCardConditionAferBattle,
  183. payCost: false,
  184. reduceCostTuple: null,
  185. fixedCostTuple: null,
  186. ignoreDigivolutionRequirementFixedCost: -1,
  187. activateClass: activateClass,
  188. successProcess: null));*/
  189. }
  190. }
  191. }
  192. ICardEffect GetCardEffectAfterBattle(EffectTiming _timing)
  193. {
  194. if (_timing == EffectTiming.OnEndBattle)
  195. {
  196. return activateClassDigivolve;
  197. }
  198. return null;
  199. }
  200. #endregion
  201. }
  202. #endregion
  203. #region When Digivolving
  204. if (timing == EffectTiming.OnEnterFieldAnyone)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("Trash digivolution cards", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  209. cardEffects.Add(activateClass);
  210. string EffectDiscription()
  211. {
  212. 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.";
  213. }
  214. bool CanSelectPermanentCondition(Permanent permanent)
  215. {
  216. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  217. {
  218. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanSelectCardCondition(CardSource cardSource)
  226. {
  227. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  228. }
  229. bool CanSelectPermanentCondition1(Permanent permanent)
  230. {
  231. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  232. {
  233. if (permanent.HasNoDigivolutionCards)
  234. {
  235. return true;
  236. }
  237. }
  238. return false;
  239. }
  240. bool CanUseCondition(Hashtable hashtable)
  241. {
  242. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  243. }
  244. bool CanActivateCondition(Hashtable hashtable)
  245. {
  246. if (CardEffectCommons.IsExistOnBattleArea(card))
  247. {
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  249. {
  250. return true;
  251. }
  252. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  253. {
  254. return true;
  255. }
  256. }
  257. return false;
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  260. {
  261. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  262. {
  263. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  264. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  265. selectPermanentEffect.SetUp(
  266. selectPlayer: card.Owner,
  267. canTargetCondition: CanSelectPermanentCondition,
  268. canTargetCondition_ByPreSelecetedList: null,
  269. canEndSelectCondition: null,
  270. maxCount: maxCount,
  271. canNoSelect: false,
  272. canEndNotMax: false,
  273. selectPermanentCoroutine: SelectPermanentCoroutine,
  274. afterSelectPermanentCoroutine: null,
  275. mode: SelectPermanentEffect.Mode.Custom,
  276. cardEffect: activateClass);
  277. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  278. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  279. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  280. {
  281. Permanent selectedPermanent = permanent;
  282. int count()
  283. {
  284. return selectedPermanent.TopCard.CardColors.Count();
  285. }
  286. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: count(), isFromTop: true, activateClass: activateClass));
  287. }
  288. }
  289. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  290. {
  291. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  292. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  293. selectPermanentEffect1.SetUp(
  294. selectPlayer: card.Owner,
  295. canTargetCondition: CanSelectPermanentCondition1,
  296. canTargetCondition_ByPreSelecetedList: null,
  297. canEndSelectCondition: null,
  298. maxCount: maxCount1,
  299. canNoSelect: false,
  300. canEndNotMax: false,
  301. selectPermanentCoroutine: null,
  302. afterSelectPermanentCoroutine: null,
  303. mode: SelectPermanentEffect.Mode.Bounce,
  304. cardEffect: activateClass);
  305. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  306. }
  307. }
  308. }
  309. #endregion
  310. return cardEffects;
  311. }
  312. }
  313. }