ST20_09.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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.IsPermanentExistsOnOpponentBattleAreaDigimon(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) && TamerTwoColourCount() > 0)
  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.IsExistOnBattleAreaDigimon(card) &&
  99. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable hashtable)
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(
  104. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  105. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition) && TamerTwoColourCount() > 0)
  106. {
  107. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  108. selectPermanentEffect.SetUp(
  109. selectPlayer: card.Owner,
  110. canTargetCondition: CanSelectPermanentCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: TamerTwoColourCount(),
  114. canNoSelect: false,
  115. canEndNotMax: false,
  116. selectPermanentCoroutine: null,
  117. afterSelectPermanentCoroutine: null,
  118. mode: SelectPermanentEffect.Mode.Tap,
  119. cardEffect: activateClass);
  120. selectPermanentEffect.SetUpCustomMessage(
  121. "Select 1 Digimon to suspend per 2 colours of ADVENTURE Tamers you have",
  122. "The opponent is selecting 1 Digimon to suspend per 2 colours of ADVENTURE Tamers they have.");
  123. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  124. }
  125. }
  126. }
  127. #endregion
  128. #region Your Turn
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  134. activateClass.SetHashString("alliance-attack-ST20-009");
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. 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.";
  139. }
  140. bool MyDigimonPlayedDigid(Permanent permanent)
  141. {
  142. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent != card.PermanentOfThisCard())
  143. {
  144. return permanent.TopCard.EqualsTraits("ADVENTURE");
  145. }
  146. return false;
  147. }
  148. bool MyDigimonAlliance(Permanent permanent)
  149. {
  150. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  151. }
  152. bool MyDigimonAttacking(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  155. permanent.CanAttack(activateClass);
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  160. {
  161. if (CardEffectCommons.IsOwnerTurn(card))
  162. {
  163. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  164. return true;
  165. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  174. {
  175. return true;
  176. }
  177. return false;
  178. }
  179. IEnumerator ActivateCoroutine(Hashtable hashtable)
  180. {
  181. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  182. {
  183. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  184. selectPermanentEffect.SetUp(
  185. selectPlayer: card.Owner,
  186. canTargetCondition: MyDigimonAlliance,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. maxCount: 1,
  190. canNoSelect: false,
  191. canEndNotMax: false,
  192. selectPermanentCoroutine: SelectBoostedDigimon,
  193. afterSelectPermanentCoroutine: null,
  194. mode: SelectPermanentEffect.Mode.Custom,
  195. cardEffect: activateClass);
  196. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. IEnumerator SelectBoostedDigimon(Permanent target)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  201. }
  202. }
  203. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  204. {
  205. Permanent selectedPermanent = null;
  206. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  207. selectPermanentEffect.SetUp(
  208. selectPlayer: card.Owner,
  209. canTargetCondition: MyDigimonAttacking,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: null,
  212. maxCount: 1,
  213. canNoSelect: false,
  214. canEndNotMax: false,
  215. selectPermanentCoroutine: SelectPermanentCoroutine,
  216. afterSelectPermanentCoroutine: null,
  217. mode: SelectPermanentEffect.Mode.Custom,
  218. cardEffect: activateClass);
  219. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  220. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  221. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  222. {
  223. selectedPermanent = permanent;
  224. yield return null;
  225. }
  226. if (selectedPermanent != null)
  227. {
  228. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  229. selectAttackEffect.SetUp(
  230. attacker: selectedPermanent,
  231. canAttackPlayerCondition: () => true,
  232. defenderCondition: _ => true,
  233. cardEffect: activateClass);
  234. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  235. }
  236. }
  237. }
  238. }
  239. #endregion
  240. #region Alliance Inherit
  241. if (timing == EffectTiming.OnAllyAttack)
  242. {
  243. bool Condition()
  244. {
  245. return CardEffectCommons.IsExistOnBattleArea(card);
  246. }
  247. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  248. }
  249. #endregion
  250. return cardEffects;
  251. }
  252. }
  253. }