ST21_04.cs 17 KB

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