ST20_04.cs 16 KB

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