ST20_11.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. //ST20 Wargreymon
  7. namespace DCGO.CardEffects.ST20
  8. {
  9. public class ST20_11 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alt digivolution condition
  15. if(timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent permanent)
  18. {
  19. return (permanent.TopCard.HasAdventureTraits || permanent.TopCard.EqualsTraits("Hero"))
  20. && permanent.Level == 5;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null));
  23. }
  24. #endregion
  25. #region Ace - Blast Digivolve
  26. if (timing == EffectTiming.OnCounterTiming)
  27. {
  28. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  29. }
  30. #endregion
  31. #region On Play/When Digivolving shared
  32. bool CanActivateConditionShared(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  35. }
  36. int TamerTwoColourCount()
  37. {
  38. List<CardSource> tamerCards = new List<CardSource>();
  39. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  40. {
  41. if (permanent.IsTamer)
  42. {
  43. tamerCards.Add(permanent.TopCard);
  44. }
  45. }
  46. return Mathf.FloorToInt(Combinations.GetDifferenetColorCardCount(tamerCards) / 2);
  47. }
  48. bool CanSelectProtectCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  51. }
  52. #endregion
  53. #region On Play
  54. if(timing == EffectTiming.OnEnterFieldAnyone)
  55. {
  56. ActivateClass activateClass = new ActivateClass();
  57. activateClass.SetUpICardEffect("Make digimon immune", CanUseCondition, card);
  58. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  59. cardEffects.Add(activateClass);
  60. string EffectDescription()
  61. {
  62. return "[On Play] Until your opponent's turn ends, for every 2 colors your Tamers have, their Digimon's effects don't affect 1 of your Digimon.";
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable hashtable)
  69. {
  70. List<Permanent> selectedPermanents = new List<Permanent>();
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectProtectCondition) && TamerTwoColourCount() > 0)
  72. {
  73. int maxCount = Math.Min(Math.Max(1, TamerTwoColourCount()), CardEffectCommons.MatchConditionPermanentCount(CanSelectProtectCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectProtectCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon for every 2 tamer colors you have that will not be affected by the effects of your opponent's Digimon.",
  88. "The opponent is selecting 1 Digimon for every 2 tamer colors they have that will not be affected by the effects of your Digimon.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  91. {
  92. selectedPermanents.Add(permanent);
  93. yield return null;
  94. }
  95. }
  96. if (selectedPermanents.Count() > 0)
  97. {
  98. foreach (Permanent selectedPermanent in selectedPermanents)
  99. {
  100. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  101. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseConditionImmunity, card);
  102. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  103. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  104. bool CanUseConditionImmunity(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  107. }
  108. bool CardCondition(CardSource cardSource)
  109. {
  110. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  111. {
  112. if (cardSource == selectedPermanent.TopCard)
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool SkillCondition(ICardEffect cardEffect)
  120. {
  121. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  122. {
  123. if (cardEffect.IsDigimonEffect)
  124. {
  125. return true;
  126. }
  127. if (cardEffect.IsDigimonEffect && cardEffect.IsSecurityEffect)
  128. {
  129. return true;
  130. }
  131. }
  132. return false;
  133. }
  134. ICardEffect GetCardEffect(EffectTiming _timing)
  135. {
  136. if (_timing == EffectTiming.None)
  137. {
  138. return canNotAffectedClass;
  139. }
  140. return null;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. #endregion
  147. #region When Digivolving (immunity)
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Make digimon immune", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  153. cardEffects.Add(activateClass);
  154. string EffectDescription()
  155. {
  156. return "[When Digivolving] Until your opponent's turn ends, for every 2 colors your Tamers have, their Digimon's effects don't affect 1 of your Digimon.";
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. List<Permanent> selectedPermanents = new List<Permanent>();
  165. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectProtectCondition) && TamerTwoColourCount() > 0)
  166. {
  167. int maxCount = Math.Min(Math.Max(1, TamerTwoColourCount()), CardEffectCommons.MatchConditionPermanentCount(CanSelectProtectCondition));
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectProtectCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: maxCount,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon for every 2 tamer colors you have that will not be affected by the effects of your opponent's Digimon.",
  182. "The opponent is selecting 1 Digimon for every 2 tamer colors they have that will not be affected by the effects of your Digimon.");
  183. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  184. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  185. {
  186. selectedPermanents.Add(permanent);
  187. yield return null;
  188. }
  189. }
  190. if (selectedPermanents.Count() > 0)
  191. {
  192. foreach (Permanent selectedPermanent in selectedPermanents)
  193. {
  194. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  195. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseConditionImmunity, card);
  196. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  197. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  198. bool CanUseConditionImmunity(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  201. }
  202. bool CardCondition(CardSource cardSource)
  203. {
  204. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  205. {
  206. if (cardSource == selectedPermanent.TopCard)
  207. {
  208. return true;
  209. }
  210. }
  211. return false;
  212. }
  213. bool SkillCondition(ICardEffect cardEffect)
  214. {
  215. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  216. {
  217. if (cardEffect.IsDigimonEffect)
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. ICardEffect GetCardEffect(EffectTiming _timing)
  225. {
  226. if (_timing == EffectTiming.None)
  227. {
  228. return canNotAffectedClass;
  229. }
  230. return null;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. #endregion
  237. #region When Digivolving-When Attacking shared
  238. bool CanSelectTargetCondition(Permanent permanent)
  239. {
  240. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  241. }
  242. bool CanActivateAtkDigivolveCondition(Hashtable hashtable)
  243. {
  244. if (CardEffectCommons.IsExistOnBattleArea(card))
  245. {
  246. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  247. {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253. #endregion
  254. #region When Digivolving (removal)
  255. if (timing == EffectTiming.OnEnterFieldAnyone)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("Delete lowest DP", CanUseCondition, card);
  259. activateClass.SetUpActivateClass(CanActivateAtkDigivolveCondition, ActivateCoroutine, -1, false, EffectDescription());
  260. cardEffects.Add(activateClass);
  261. string EffectDescription()
  262. {
  263. return "[When Digivolving] Delete 1 of your opponent's lowest DP Digimon.";
  264. }
  265. bool CanUseCondition(Hashtable hashtable)
  266. {
  267. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  268. }
  269. IEnumerator ActivateCoroutine(Hashtable hashtable)
  270. {
  271. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  272. {
  273. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  274. selectPermanentEffect.SetUp(
  275. selectPlayer: card.Owner,
  276. canTargetCondition: CanSelectTargetCondition,
  277. canTargetCondition_ByPreSelecetedList: null,
  278. canEndSelectCondition: null,
  279. maxCount: 1,
  280. canNoSelect: false,
  281. canEndNotMax: false,
  282. selectPermanentCoroutine: null,
  283. afterSelectPermanentCoroutine: null,
  284. mode: SelectPermanentEffect.Mode.Destroy,
  285. cardEffect: activateClass);
  286. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  287. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  288. }
  289. }
  290. }
  291. #endregion
  292. #region When Attacking
  293. if (timing == EffectTiming.OnAllyAttack)
  294. {
  295. ActivateClass activateClass = new ActivateClass();
  296. activateClass.SetUpICardEffect("Delete lowest DP", CanUseCondition, card);
  297. activateClass.SetUpActivateClass(CanActivateAtkDigivolveCondition, ActivateCoroutine, -1, false, EffectDescription());
  298. cardEffects.Add(activateClass);
  299. string EffectDescription()
  300. {
  301. return "[When Attacking] Delete 1 of your opponent's lowest DP Digimon.";
  302. }
  303. bool CanUseCondition(Hashtable hashtable)
  304. {
  305. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  306. }
  307. IEnumerator ActivateCoroutine(Hashtable hashtable)
  308. {
  309. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  310. {
  311. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  312. selectPermanentEffect.SetUp(
  313. selectPlayer: card.Owner,
  314. canTargetCondition: CanSelectTargetCondition,
  315. canTargetCondition_ByPreSelecetedList: null,
  316. canEndSelectCondition: null,
  317. maxCount: 1,
  318. canNoSelect: false,
  319. canEndNotMax: false,
  320. selectPermanentCoroutine: null,
  321. afterSelectPermanentCoroutine: null,
  322. mode: SelectPermanentEffect.Mode.Destroy,
  323. cardEffect: activateClass);
  324. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  325. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  326. }
  327. }
  328. }
  329. #endregion
  330. return cardEffects;
  331. }
  332. }
  333. }