ST21_09.cs 17 KB

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