ST21_09.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  182. {
  183. return true;
  184. }
  185. return false;
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. List<Permanent> etbPermanents = new List<Permanent>();
  190. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  191. if (hashtables != null)
  192. {
  193. foreach (Hashtable hashtable1 in hashtables)
  194. {
  195. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  196. if (permanent != null)
  197. etbPermanents.Add(permanent);
  198. }
  199. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  200. }
  201. if (etbPermanents.Count > 0)
  202. {
  203. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  204. {
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: MyDigimonAlliance,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: 1,
  212. canNoSelect: false,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: SelectBoostedDigimon,
  215. afterSelectPermanentCoroutine: null,
  216. mode: SelectPermanentEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  219. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  220. IEnumerator SelectBoostedDigimon(Permanent target)
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  223. }
  224. }
  225. }
  226. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  227. {
  228. Permanent selectedPermanent = null;
  229. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: MyDigimonAttacking,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: 1,
  236. canNoSelect: true,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: SelectPermanentCoroutine,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  243. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  244. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  245. {
  246. selectedPermanent = permanent;
  247. yield return null;
  248. }
  249. if (selectedPermanent != null)
  250. {
  251. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  252. selectAttackEffect.SetUp(
  253. attacker: selectedPermanent,
  254. canAttackPlayerCondition: () => true,
  255. defenderCondition: _ => true,
  256. cardEffect: activateClass);
  257. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  258. }
  259. }
  260. }
  261. }
  262. #endregion
  263. #region Alliance Inherit
  264. if (timing == EffectTiming.OnAllyAttack)
  265. {
  266. bool Condition()
  267. {
  268. return CardEffectCommons.IsExistOnBattleArea(card);
  269. }
  270. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  271. }
  272. #endregion
  273. return cardEffects;
  274. }
  275. }
  276. }