ST20_04.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //ST20-04 garudamon
  4. namespace DCGO.CardEffects.ST20
  5. {
  6. public class ST20_04 : 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.HasAdventureTraits && 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)
  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("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);
  48. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  49. cardEffects.Add(activateClass);
  50. string EffectDescription()
  51. {
  52. 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.)";
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: SelectPermanentCoroutine,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectPermanentEffect.SetUpCustomMessage(
  76. "Select 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors of tamers you have.",
  77. "The opponent is selecting 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors of tamers they have.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  82. targetPermanent: permanent,
  83. changeValue: 1,
  84. effectDuration: EffectDuration.UntilEachTurnEnd,
  85. activateClass: activateClass));
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  87. targetPermanent: permanent,
  88. changeValue: 2000 * TamerTwoColourCount(),
  89. effectDuration: EffectDuration.UntilEachTurnEnd,
  90. activateClass: activateClass));
  91. }
  92. }
  93. }
  94. }
  95. #endregion
  96. #region When Digivolving
  97. if (timing == EffectTiming.OnEnterFieldAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. 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);
  101. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  102. cardEffects.Add(activateClass);
  103. string EffectDescription()
  104. {
  105. 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.)";
  106. }
  107. bool CanUseCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable hashtable)
  112. {
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  114. {
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: CanSelectPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: SelectPermanentCoroutine,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Custom,
  127. cardEffect: activateClass);
  128. selectPermanentEffect.SetUpCustomMessage(
  129. "Select 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors of tamers you have.",
  130. "The opponent is selecting 1 Digimon that will gain <Security A. +1>, and +2000DP per 2 colors of tamers they have.");
  131. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  132. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  135. targetPermanent: permanent,
  136. changeValue: 1,
  137. effectDuration: EffectDuration.UntilEachTurnEnd,
  138. activateClass: activateClass));
  139. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  140. targetPermanent: permanent,
  141. changeValue: 2000 * TamerTwoColourCount(),
  142. effectDuration: EffectDuration.UntilEachTurnEnd,
  143. activateClass: activateClass));
  144. }
  145. }
  146. }
  147. }
  148. #endregion
  149. #region Your Turn
  150. if (timing == EffectTiming.OnEnterFieldAnyone)
  151. {
  152. ActivateClass activateClass = new ActivateClass();
  153. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  154. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  155. activateClass.SetIsSkippableFunction(IsSkippable);
  156. activateClass.SetHashString("alliance-attack-ST20_04");
  157. cardEffects.Add(activateClass);
  158. string EffectDescription()
  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 IsSkippable(Hashtable hashtable)
  163. {
  164. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  165. if (hashtables != null)
  166. {
  167. foreach (Hashtable hashtable1 in hashtables)
  168. {
  169. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  170. if (permanent != null && MyDigimonAdventurePlayedDigid(permanent))
  171. return false;
  172. }
  173. }
  174. return true;
  175. }
  176. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  177. {
  178. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  179. permanent != card.PermanentOfThisCard() &&
  180. permanent.TopCard.EqualsTraits("ADVENTURE");
  181. }
  182. bool MyDigimonPlayedDigid(Permanent permanent)
  183. {
  184. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  185. permanent != card.PermanentOfThisCard();
  186. }
  187. bool MyDigimonAlliance(Permanent permanent)
  188. {
  189. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  190. }
  191. bool MyDigimonAttacking(Permanent permanent)
  192. {
  193. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  194. permanent.CanAttack(activateClass);
  195. }
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  199. {
  200. if (CardEffectCommons.IsOwnerTurn(card))
  201. {
  202. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  203. return true;
  204. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. bool CanActivateCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  213. {
  214. return true;
  215. }
  216. return false;
  217. }
  218. IEnumerator ActivateCoroutine(Hashtable hashtable)
  219. {
  220. bool Used = false;
  221. List<Permanent> etbPermanents = new List<Permanent>();
  222. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  223. if (hashtables != null)
  224. {
  225. foreach (Hashtable hashtable1 in hashtables)
  226. {
  227. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  228. if (permanent != null)
  229. etbPermanents.Add(permanent);
  230. }
  231. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  232. }
  233. if (etbPermanents.Count > 0)
  234. {
  235. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  236. {
  237. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  238. selectPermanentEffect.SetUp(
  239. selectPlayer: card.Owner,
  240. canTargetCondition: MyDigimonAlliance,
  241. canTargetCondition_ByPreSelecetedList: null,
  242. canEndSelectCondition: null,
  243. maxCount: 1,
  244. canNoSelect: false,
  245. canEndNotMax: false,
  246. selectPermanentCoroutine: SelectBoostedDigimon,
  247. afterSelectPermanentCoroutine: null,
  248. mode: SelectPermanentEffect.Mode.Custom,
  249. cardEffect: activateClass);
  250. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  251. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  252. IEnumerator SelectBoostedDigimon(Permanent target)
  253. {
  254. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  255. }
  256. Used = true;
  257. }
  258. }
  259. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  260. {
  261. Permanent selectedPermanent = null;
  262. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  263. selectPermanentEffect.SetUp(
  264. selectPlayer: card.Owner,
  265. canTargetCondition: MyDigimonAttacking,
  266. canTargetCondition_ByPreSelecetedList: null,
  267. canEndSelectCondition: null,
  268. maxCount: 1,
  269. canNoSelect: true,
  270. canEndNotMax: false,
  271. selectPermanentCoroutine: SelectPermanentCoroutine,
  272. afterSelectPermanentCoroutine: null,
  273. mode: SelectPermanentEffect.Mode.Custom,
  274. cardEffect: activateClass);
  275. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  276. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  277. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  278. {
  279. selectedPermanent = permanent;
  280. yield return null;
  281. }
  282. if (selectedPermanent != null)
  283. {
  284. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  285. selectAttackEffect.SetUp(
  286. attacker: selectedPermanent,
  287. canAttackPlayerCondition: () => true,
  288. defenderCondition: _ => true,
  289. cardEffect: activateClass);
  290. selectAttackEffect.SetAfterOnAttackCoroutine(AfterOnAttackCoroutine);
  291. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  292. }
  293. IEnumerator AfterOnAttackCoroutine()
  294. {
  295. Used = true;
  296. yield return null;
  297. }
  298. }
  299. if (!Used)
  300. {
  301. activateClass.RemoveUse();
  302. }
  303. }
  304. }
  305. #endregion
  306. #region Alliance Inherit
  307. if (timing == EffectTiming.OnAllyAttack)
  308. {
  309. bool Condition()
  310. {
  311. return CardEffectCommons.IsExistOnBattleArea(card);
  312. }
  313. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  314. }
  315. #endregion
  316. return cardEffects;
  317. }
  318. }
  319. }