ST21_09.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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 && permanent.TopCard.HasAdventureTraits)
  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, EffectDiscription());
  139. activateClass.SetHashString("alliance-attack-ST21-09");
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. {
  143. 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.";
  144. }
  145. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  146. {
  147. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  148. permanent != card.PermanentOfThisCard() &&
  149. permanent.TopCard.EqualsTraits("ADVENTURE");
  150. }
  151. bool MyDigimonPlayedDigid(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  154. permanent != card.PermanentOfThisCard();
  155. }
  156. bool MyDigimonAlliance(Permanent permanent)
  157. {
  158. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  159. }
  160. bool MyDigimonAttacking(Permanent permanent)
  161. {
  162. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  163. permanent.CanAttack(activateClass);
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  168. {
  169. if (CardEffectCommons.IsOwnerTurn(card))
  170. {
  171. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  172. return true;
  173. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. List<Permanent> etbPermanents = new List<Permanent>();
  186. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  187. if (hashtables != null)
  188. {
  189. foreach (Hashtable hashtable1 in hashtables)
  190. {
  191. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  192. if (permanent != null)
  193. etbPermanents.Add(permanent);
  194. }
  195. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  196. }
  197. if (etbPermanents.Count > 0)
  198. {
  199. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  200. {
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: MyDigimonAlliance,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: 1,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectBoostedDigimon,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectBoostedDigimon(Permanent target)
  217. {
  218. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  219. }
  220. }
  221. }
  222. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  223. {
  224. Permanent selectedPermanent = null;
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: MyDigimonAttacking,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: SelectPermanentCoroutine,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Custom,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  239. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  240. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  241. {
  242. selectedPermanent = permanent;
  243. yield return null;
  244. }
  245. if (selectedPermanent.CanAttack(activateClass))
  246. {
  247. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  248. selectAttackEffect.SetUp(
  249. attacker: selectedPermanent,
  250. canAttackPlayerCondition: () => true,
  251. defenderCondition: _ => true,
  252. cardEffect: activateClass);
  253. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  254. }
  255. }
  256. }
  257. }
  258. #endregion
  259. #region Alliance Inherit
  260. if (timing == EffectTiming.OnAllyAttack)
  261. {
  262. bool Condition()
  263. {
  264. return CardEffectCommons.IsExistOnBattleArea(card);
  265. }
  266. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. }
  272. }