ST20_04.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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.HasAdventureTraits && 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)
  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 colors of tamers you have.",
  78. "The opponent is selecting 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors 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 colors of tamers you have.",
  131. "The opponent is selecting 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors 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 alliance then attack", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  156. activateClass.SetHashString("alliance-attack-ST20_04");
  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 MyDigimonAdventurePlayedDigid(Permanent permanent)
  163. {
  164. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  165. permanent != card.PermanentOfThisCard() &&
  166. permanent.TopCard.EqualsTraits("ADVENTURE");
  167. }
  168. bool MyDigimonPlayedDigid(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  171. permanent != card.PermanentOfThisCard();
  172. }
  173. bool MyDigimonAlliance(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  176. }
  177. bool MyDigimonAttacking(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  180. permanent.CanAttack(activateClass);
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  185. {
  186. if (CardEffectCommons.IsOwnerTurn(card))
  187. {
  188. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  189. return true;
  190. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  199. {
  200. return true;
  201. }
  202. return false;
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable hashtable)
  205. {
  206. List<Permanent> etbPermanents = new List<Permanent>();
  207. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  208. if (hashtables != null)
  209. {
  210. foreach (Hashtable hashtable1 in hashtables)
  211. {
  212. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  213. if (permanent != null)
  214. etbPermanents.Add(permanent);
  215. }
  216. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  217. }
  218. if (etbPermanents.Count > 0)
  219. {
  220. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  221. {
  222. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  223. selectPermanentEffect.SetUp(
  224. selectPlayer: card.Owner,
  225. canTargetCondition: MyDigimonAlliance,
  226. canTargetCondition_ByPreSelecetedList: null,
  227. canEndSelectCondition: null,
  228. maxCount: 1,
  229. canNoSelect: false,
  230. canEndNotMax: false,
  231. selectPermanentCoroutine: SelectBoostedDigimon,
  232. afterSelectPermanentCoroutine: null,
  233. mode: SelectPermanentEffect.Mode.Custom,
  234. cardEffect: activateClass);
  235. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  236. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  237. IEnumerator SelectBoostedDigimon(Permanent target)
  238. {
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  240. }
  241. }
  242. }
  243. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  244. {
  245. Permanent selectedPermanent = null;
  246. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  247. selectPermanentEffect.SetUp(
  248. selectPlayer: card.Owner,
  249. canTargetCondition: MyDigimonAttacking,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. maxCount: 1,
  253. canNoSelect: true,
  254. canEndNotMax: false,
  255. selectPermanentCoroutine: SelectPermanentCoroutine,
  256. afterSelectPermanentCoroutine: null,
  257. mode: SelectPermanentEffect.Mode.Custom,
  258. cardEffect: activateClass);
  259. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  262. {
  263. selectedPermanent = permanent;
  264. yield return null;
  265. }
  266. if (selectedPermanent != null)
  267. {
  268. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  269. selectAttackEffect.SetUp(
  270. attacker: selectedPermanent,
  271. canAttackPlayerCondition: () => true,
  272. defenderCondition: _ => true,
  273. cardEffect: activateClass);
  274. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  275. }
  276. }
  277. }
  278. }
  279. #endregion
  280. #region Alliance Inherit
  281. if (timing == EffectTiming.OnAllyAttack)
  282. {
  283. bool Condition()
  284. {
  285. return CardEffectCommons.IsExistOnBattleArea(card);
  286. }
  287. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  288. }
  289. #endregion
  290. return cardEffects;
  291. }
  292. }
  293. }