ST20_11.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //ST20 Wargreymon
  6. namespace DCGO.CardEffects.ST20
  7. {
  8. public class ST20_11 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt digivolution condition
  14. if(timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return (permanent.TopCard.EqualsTraits("ADVENTURE") || permanent.TopCard.EqualsTraits("Hero"))
  19. && permanent.Level == 5;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null));
  22. }
  23. #endregion
  24. #region Ace - Blast Digivolve
  25. if (timing == EffectTiming.OnCounterTiming)
  26. {
  27. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  28. }
  29. #endregion
  30. #region On Play/When Digivolving shared
  31. bool CanActivateConditionShared(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  34. }
  35. int TamerTwoColourCount()
  36. {
  37. List<CardSource> tamerCards = new List<CardSource>();
  38. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  39. {
  40. if (permanent.IsTamer)
  41. {
  42. tamerCards.Add(permanent.TopCard);
  43. }
  44. }
  45. return Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  46. }
  47. bool CanSelectProtectCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  50. }
  51. #endregion
  52. #region On Play
  53. if(timing == EffectTiming.OnEnterFieldAnyone)
  54. {
  55. ActivateClass activateClass = new ActivateClass();
  56. activateClass.SetUpICardEffect("Make digimon immune", CanUseCondition, card);
  57. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  58. cardEffects.Add(activateClass);
  59. string EffectDescription()
  60. {
  61. 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.";
  62. }
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable hashtable)
  68. {
  69. List<Permanent> selectedPermanents = new List<Permanent>();
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectProtectCondition))
  71. {
  72. //Probably could get away with just 1 min and don't check against min 1, but I'm not going to change what I don't understand for no reason
  73. int maxCount = Math.Min(Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectProtectCondition)), TamerTwoColourCount());
  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 colours 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 colours 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. //Probably could get away with just 1 min and don't check against min 1, but I'm not going to change what I don't understand for no reason
  168. int maxCount = Math.Min(Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectProtectCondition)), TamerTwoColourCount());
  169. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  170. selectPermanentEffect.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: CanSelectProtectCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: maxCount,
  176. canNoSelect: false,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: SelectPermanentCoroutine,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Custom,
  181. cardEffect: activateClass);
  182. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon for every 2 tamer colours you have that will not be affected by the effects of your opponent's Digimon.",
  183. "The opponent is selecting 1 Digimon for every 2 tamer colours they have that will not be affected by the effects of your Digimon.");
  184. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  185. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  186. {
  187. selectedPermanents.Add(permanent);
  188. yield return null;
  189. }
  190. }
  191. if (selectedPermanents.Count() > 0)
  192. {
  193. foreach (Permanent selectedPermanent in selectedPermanents)
  194. {
  195. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  196. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseConditionImmunity, card);
  197. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  198. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  199. bool CanUseConditionImmunity(Hashtable hashtable)
  200. {
  201. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(selectedPermanent, card);
  202. }
  203. bool CardCondition(CardSource cardSource)
  204. {
  205. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  206. {
  207. if (cardSource == selectedPermanent.TopCard)
  208. {
  209. return true;
  210. }
  211. }
  212. return false;
  213. }
  214. bool SkillCondition(ICardEffect cardEffect)
  215. {
  216. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  217. {
  218. if (cardEffect.IsDigimonEffect)
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. ICardEffect GetCardEffect(EffectTiming _timing)
  226. {
  227. if (_timing == EffectTiming.None)
  228. {
  229. return canNotAffectedClass;
  230. }
  231. return null;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. #endregion
  238. #region When Digivolving-When Attacking shared
  239. bool CanSelectTargetCondition(Permanent permanent)
  240. {
  241. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  242. }
  243. bool CanActivateAtkDigivolveCondition(Hashtable hashtable)
  244. {
  245. if (CardEffectCommons.IsExistOnBattleArea(card))
  246. {
  247. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  248. {
  249. return true;
  250. }
  251. }
  252. return false;
  253. }
  254. #endregion
  255. #region When Digivolving (removal)
  256. if (timing == EffectTiming.OnEnterFieldAnyone)
  257. {
  258. ActivateClass activateClass = new ActivateClass();
  259. activateClass.SetUpICardEffect("Delete lowest DP", CanUseCondition, card);
  260. activateClass.SetUpActivateClass(CanActivateAtkDigivolveCondition, ActivateCoroutine, -1, false, EffectDescription());
  261. cardEffects.Add(activateClass);
  262. string EffectDescription()
  263. {
  264. return "[When Digivolving] Delete 1 of your opponent's lowest DP Digimon.";
  265. }
  266. bool CanUseCondition(Hashtable hashtable)
  267. {
  268. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable hashtable)
  271. {
  272. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  273. {
  274. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  275. selectPermanentEffect.SetUp(
  276. selectPlayer: card.Owner,
  277. canTargetCondition: CanSelectTargetCondition,
  278. canTargetCondition_ByPreSelecetedList: null,
  279. canEndSelectCondition: null,
  280. maxCount: 1,
  281. canNoSelect: false,
  282. canEndNotMax: false,
  283. selectPermanentCoroutine: null,
  284. afterSelectPermanentCoroutine: null,
  285. mode: SelectPermanentEffect.Mode.Destroy,
  286. cardEffect: activateClass);
  287. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  288. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  289. }
  290. }
  291. }
  292. #endregion
  293. #region When Attacking
  294. if (timing == EffectTiming.OnAllyAttack)
  295. {
  296. ActivateClass activateClass = new ActivateClass();
  297. activateClass.SetUpICardEffect("Delete lowest DP", CanUseCondition, card);
  298. activateClass.SetUpActivateClass(CanActivateAtkDigivolveCondition, ActivateCoroutine, -1, false, EffectDescription());
  299. cardEffects.Add(activateClass);
  300. string EffectDescription()
  301. {
  302. return "[When Digivolving] Delete 1 of your opponent's lowest DP Digimon.";
  303. }
  304. bool CanUseCondition(Hashtable hashtable)
  305. {
  306. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  307. }
  308. IEnumerator ActivateCoroutine(Hashtable hashtable)
  309. {
  310. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTargetCondition))
  311. {
  312. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  313. selectPermanentEffect.SetUp(
  314. selectPlayer: card.Owner,
  315. canTargetCondition: CanSelectTargetCondition,
  316. canTargetCondition_ByPreSelecetedList: null,
  317. canEndSelectCondition: null,
  318. maxCount: 1,
  319. canNoSelect: false,
  320. canEndNotMax: false,
  321. selectPermanentCoroutine: null,
  322. afterSelectPermanentCoroutine: null,
  323. mode: SelectPermanentEffect.Mode.Destroy,
  324. cardEffect: activateClass);
  325. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  326. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  327. }
  328. }
  329. }
  330. #endregion
  331. return cardEffects;
  332. }
  333. }
  334. }