ST20_09.cs 14 KB

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