ST21_04.cs 16 KB

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