ST20_09.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. //ST20 Megakabuterimon
  5. namespace DCGO.CardEffects.ST20
  6. {
  7. public class ST20_09 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasAdventureTraits && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play/When Digivolving shared
  23. bool CanActivateConditionShared(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  26. }
  27. int TamerTwoColourCount()
  28. {
  29. List<CardSource> tamerCards = new List<CardSource>();
  30. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  31. {
  32. if (permanent.IsTamer && permanent.TopCard.HasAdventureTraits)
  33. {
  34. tamerCards.Add(permanent.TopCard);
  35. }
  36. }
  37. return Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  38. }
  39. bool CanSelectYourDigimonCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. #endregion
  48. #region On Play
  49. if (timing == EffectTiming.OnEnterFieldAnyone)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect("Unsuspend, then for every 2 colours in adventure tamers, suspend opposing digimon", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDiscription());
  54. cardEffects.Add(activateClass);
  55. string EffectDiscription()
  56. {
  57. return "[On Play] 1 of your Digimon unsuspends. Then, for every 2 colors your Tamers with the [ADVENTURE] trait have, suspend 1 of your opponent's Digimon.";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. SelectPermanentEffect selectUnsuspendEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  66. selectUnsuspendEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanSelectYourDigimonCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: 1,
  72. canNoSelect: false,
  73. canEndNotMax: false,
  74. selectPermanentCoroutine: null,
  75. afterSelectPermanentCoroutine: null,
  76. mode: SelectPermanentEffect.Mode.UnTap,
  77. cardEffect: activateClass);
  78. yield return ContinuousController.instance.StartCoroutine(selectUnsuspendEffect.Activate());
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && TamerTwoColourCount() > 0)
  80. {
  81. int maxCount = Mathf.Min(CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition), TamerTwoColourCount());
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Tap,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage(
  96. "Select 1 Digimon to suspend per 2 colours of ADVENTURE Tamers you have",
  97. "The opponent is selecting 1 Digimon to suspend per 2 colours of ADVENTURE Tamers they have.");
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. }
  100. }
  101. }
  102. #endregion
  103. #region When Digivolving
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Unsuspend, then for every 2 colours in adventure tamers, suspend opposing digimon", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDiscription());
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. return "[When Digivolving] 1 of your Digimon unsuspends. Then, for every 2 colors your Tamers with the [ADVENTURE] trait have, suspend 1 of your opponent's Digimon.";
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  117. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable hashtable)
  120. {
  121. SelectPermanentEffect selectUnsuspendEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  122. selectUnsuspendEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectYourDigimonCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: 1,
  128. canNoSelect: false,
  129. canEndNotMax: false,
  130. selectPermanentCoroutine: null,
  131. afterSelectPermanentCoroutine: null,
  132. mode: SelectPermanentEffect.Mode.UnTap,
  133. cardEffect: activateClass);
  134. yield return ContinuousController.instance.StartCoroutine(selectUnsuspendEffect.Activate());
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && TamerTwoColourCount() > 0)
  136. {
  137. int maxCount = Mathf.Min(CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition), TamerTwoColourCount());
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: null,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Tap,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage(
  152. "Select 1 Digimon to suspend per 2 colours of ADVENTURE Tamers you have",
  153. "The opponent is selecting 1 Digimon to suspend per 2 colours of ADVENTURE Tamers they have.");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. }
  156. }
  157. }
  158. #endregion
  159. #region Your Turn
  160. if (timing == EffectTiming.OnEnterFieldAnyone)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  165. activateClass.SetHashString("alliance-attack-ST20-09");
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[Your Turn][Once Per Turn] When your other Digimon are played or digivolve, if any of them have the [ADVENTURE] trait, 1 of your Digimon gains <Alliance> for the turn. Then, 1 of your Digimon may attack.";
  170. }
  171. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  174. permanent != card.PermanentOfThisCard() &&
  175. permanent.TopCard.EqualsTraits("ADVENTURE");
  176. }
  177. bool MyDigimonPlayedDigid(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  180. permanent != card.PermanentOfThisCard();
  181. }
  182. bool MyDigimonAlliance(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  185. }
  186. bool MyDigimonAttacking(Permanent permanent)
  187. {
  188. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  189. permanent.CanAttack(activateClass);
  190. }
  191. bool CanUseCondition(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  194. {
  195. if (CardEffectCommons.IsOwnerTurn(card))
  196. {
  197. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  198. return true;
  199. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  200. return true;
  201. }
  202. }
  203. return false;
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  208. }
  209. IEnumerator ActivateCoroutine(Hashtable hashtable)
  210. {
  211. List<Permanent> etbPermanents = new List<Permanent>();
  212. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  213. if (hashtables != null)
  214. {
  215. foreach (Hashtable hashtable1 in hashtables)
  216. {
  217. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  218. if (permanent != null)
  219. etbPermanents.Add(permanent);
  220. }
  221. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  222. }
  223. if (etbPermanents.Count > 0)
  224. {
  225. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  226. {
  227. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  228. selectPermanentEffect.SetUp(
  229. selectPlayer: card.Owner,
  230. canTargetCondition: MyDigimonAlliance,
  231. canTargetCondition_ByPreSelecetedList: null,
  232. canEndSelectCondition: null,
  233. maxCount: 1,
  234. canNoSelect: false,
  235. canEndNotMax: false,
  236. selectPermanentCoroutine: SelectBoostedDigimon,
  237. afterSelectPermanentCoroutine: null,
  238. mode: SelectPermanentEffect.Mode.Custom,
  239. cardEffect: activateClass);
  240. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. IEnumerator SelectBoostedDigimon(Permanent target)
  243. {
  244. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  245. }
  246. }
  247. }
  248. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  249. {
  250. Permanent selectedPermanent = null;
  251. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  252. selectPermanentEffect.SetUp(
  253. selectPlayer: card.Owner,
  254. canTargetCondition: MyDigimonAttacking,
  255. canTargetCondition_ByPreSelecetedList: null,
  256. canEndSelectCondition: null,
  257. maxCount: 1,
  258. canNoSelect: true,
  259. canEndNotMax: false,
  260. selectPermanentCoroutine: SelectPermanentCoroutine,
  261. afterSelectPermanentCoroutine: null,
  262. mode: SelectPermanentEffect.Mode.Custom,
  263. cardEffect: activateClass);
  264. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  267. {
  268. selectedPermanent = permanent;
  269. yield return null;
  270. }
  271. if (selectedPermanent.CanAttack(activateClass))
  272. {
  273. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  274. selectAttackEffect.SetUp(
  275. attacker: selectedPermanent,
  276. canAttackPlayerCondition: () => true,
  277. defenderCondition: _ => true,
  278. cardEffect: activateClass);
  279. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  280. }
  281. }
  282. }
  283. }
  284. #endregion
  285. #region Alliance Inherit
  286. if (timing == EffectTiming.OnAllyAttack)
  287. {
  288. bool Condition()
  289. {
  290. return CardEffectCommons.IsExistOnBattleArea(card);
  291. }
  292. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  293. }
  294. #endregion
  295. return cardEffects;
  296. }
  297. }
  298. }