ST20_09.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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 colors 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 colors of ADVENTURE Tamers you have",
  97. "The opponent is selecting 1 Digimon to suspend per 2 colors 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 colors 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 colors of ADVENTURE Tamers you have",
  153. "The opponent is selecting 1 Digimon to suspend per 2 colors 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, EffectDescription());
  165. activateClass.SetIsSkippableFunction(IsSkippable);
  166. activateClass.SetHashString("alliance-attack-ST20_09");
  167. cardEffects.Add(activateClass);
  168. string EffectDescription()
  169. {
  170. 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.";
  171. }
  172. bool IsSkippable(Hashtable hashtable)
  173. {
  174. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  175. if (hashtables != null)
  176. {
  177. foreach (Hashtable hashtable1 in hashtables)
  178. {
  179. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  180. if (permanent != null && MyDigimonAdventurePlayedDigid(permanent))
  181. return false;
  182. }
  183. }
  184. return true;
  185. }
  186. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  187. {
  188. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  189. permanent != card.PermanentOfThisCard() &&
  190. permanent.TopCard.EqualsTraits("ADVENTURE");
  191. }
  192. bool MyDigimonPlayedDigid(Permanent permanent)
  193. {
  194. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  195. permanent != card.PermanentOfThisCard();
  196. }
  197. bool MyDigimonAlliance(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  200. }
  201. bool MyDigimonAttacking(Permanent permanent)
  202. {
  203. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  204. permanent.CanAttack(activateClass);
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  209. {
  210. if (CardEffectCommons.IsOwnerTurn(card))
  211. {
  212. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  213. return true;
  214. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  223. {
  224. return true;
  225. }
  226. return false;
  227. }
  228. IEnumerator ActivateCoroutine(Hashtable hashtable)
  229. {
  230. bool Used = false;
  231. List<Permanent> etbPermanents = new List<Permanent>();
  232. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  233. if (hashtables != null)
  234. {
  235. foreach (Hashtable hashtable1 in hashtables)
  236. {
  237. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  238. if (permanent != null)
  239. etbPermanents.Add(permanent);
  240. }
  241. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  242. }
  243. if (etbPermanents.Count > 0)
  244. {
  245. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  246. {
  247. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  248. selectPermanentEffect.SetUp(
  249. selectPlayer: card.Owner,
  250. canTargetCondition: MyDigimonAlliance,
  251. canTargetCondition_ByPreSelecetedList: null,
  252. canEndSelectCondition: null,
  253. maxCount: 1,
  254. canNoSelect: false,
  255. canEndNotMax: false,
  256. selectPermanentCoroutine: SelectBoostedDigimon,
  257. afterSelectPermanentCoroutine: null,
  258. mode: SelectPermanentEffect.Mode.Custom,
  259. cardEffect: activateClass);
  260. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  262. IEnumerator SelectBoostedDigimon(Permanent target)
  263. {
  264. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  265. }
  266. Used = true;
  267. }
  268. }
  269. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  270. {
  271. Permanent selectedPermanent = null;
  272. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  273. selectPermanentEffect.SetUp(
  274. selectPlayer: card.Owner,
  275. canTargetCondition: MyDigimonAttacking,
  276. canTargetCondition_ByPreSelecetedList: null,
  277. canEndSelectCondition: null,
  278. maxCount: 1,
  279. canNoSelect: true,
  280. canEndNotMax: false,
  281. selectPermanentCoroutine: SelectPermanentCoroutine,
  282. afterSelectPermanentCoroutine: null,
  283. mode: SelectPermanentEffect.Mode.Custom,
  284. cardEffect: activateClass);
  285. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  286. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  287. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  288. {
  289. selectedPermanent = permanent;
  290. yield return null;
  291. }
  292. if (selectedPermanent != null)
  293. {
  294. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  295. selectAttackEffect.SetUp(
  296. attacker: selectedPermanent,
  297. canAttackPlayerCondition: () => true,
  298. defenderCondition: _ => true,
  299. cardEffect: activateClass);
  300. selectAttackEffect.SetAfterOnAttackCoroutine(AfterOnAttackCoroutine);
  301. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  302. }
  303. IEnumerator AfterOnAttackCoroutine()
  304. {
  305. Used = true;
  306. yield return null;
  307. }
  308. }
  309. if (!Used)
  310. {
  311. activateClass.RemoveUse();
  312. }
  313. }
  314. }
  315. #endregion
  316. #region Alliance Inherit
  317. if (timing == EffectTiming.OnAllyAttack)
  318. {
  319. bool Condition()
  320. {
  321. return CardEffectCommons.IsExistOnBattleArea(card);
  322. }
  323. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  324. }
  325. #endregion
  326. return cardEffects;
  327. }
  328. }
  329. }