ST20_06.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //ST20 Angewomon
  5. namespace DCGO.CardEffects.ST20
  6. {
  7. public class ST20_06 : 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. #endregion
  24. #region On Play
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Digivolve for free", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  30. cardEffects.Add(activateClass);
  31. string EffectDescription()
  32. {
  33. return "[On Play] 1 of your other Digimon may digivolve into a Digimon card with the [ADVENTURE] trait in the hand without paying the cost.";
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  42. {
  43. if(permanent != card.PermanentOfThisCard())
  44. {
  45. foreach (CardSource cardSource in card.Owner.HandCards)
  46. {
  47. if (cardSource.HasAdventureTraits)
  48. {
  49. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool ValidDigivolveIntoHand(CardSource source)
  60. {
  61. return source.HasAdventureTraits;
  62. }
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable hashtable)
  68. {
  69. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  70. {
  71. if (CardEffectCommons.HasMatchConditionOwnersHand(card, ValidDigivolveIntoHand))
  72. {
  73. Permanent selectedPermanent = null;
  74. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  75. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectPermanentCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: maxCount,
  82. canNoSelect: true,
  83. canEndNotMax: false,
  84. selectPermanentCoroutine: SelectPermanentCoroutine,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve into a Digimon with the [ADVENTURE] trait.", "The opponent is selecting 1 Digimon to digivolve into a Digimon with the [ADVENTURE] trait.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  91. {
  92. selectedPermanent = permanent;
  93. yield return null;
  94. }
  95. if (selectedPermanent != null)
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  98. targetPermanent: selectedPermanent,
  99. cardCondition: ValidDigivolveIntoHand,
  100. payCost: false,
  101. reduceCostTuple: null,
  102. fixedCostTuple: null,
  103. ignoreDigivolutionRequirementFixedCost: -1,
  104. isHand: true,
  105. activateClass: activateClass,
  106. successProcess: null));
  107. }
  108. }
  109. }
  110. }
  111. }
  112. #endregion
  113. #region When Digivolving
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect("Digivolve for free", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  119. cardEffects.Add(activateClass);
  120. string EffectDescription()
  121. {
  122. return "[When Digivolving] 1 of your other Digimon may digivolve into a Digimon card with the [ADVENTURE] trait in the hand without paying the cost.";
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
  127. }
  128. bool CanSelectPermanentCondition(Permanent permanent)
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  131. {
  132. if (permanent != card.PermanentOfThisCard())
  133. {
  134. foreach (CardSource cardSource in card.Owner.HandCards)
  135. {
  136. if (cardSource.HasAdventureTraits)
  137. {
  138. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  139. {
  140. return true;
  141. }
  142. }
  143. }
  144. }
  145. }
  146. return false;
  147. }
  148. bool ValidDigivolveIntoHand(CardSource source)
  149. {
  150. return source.HasAdventureTraits;
  151. }
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  155. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  156. }
  157. IEnumerator ActivateCoroutine(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  160. {
  161. if (CardEffectCommons.HasMatchConditionOwnersHand(card, ValidDigivolveIntoHand))
  162. {
  163. Permanent selectedPermanent = null;
  164. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  165. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectPermanentCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: SelectPermanentCoroutine,
  175. afterSelectPermanentCoroutine: null,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve into a Digimon with the [ADVENTURE] trait.", "The opponent is selecting 1 Digimon to digivolve into a Digimon with the [ADVENTURE] trait.");
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  181. {
  182. selectedPermanent = permanent;
  183. yield return null;
  184. }
  185. if (selectedPermanent != null)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  188. targetPermanent: selectedPermanent,
  189. cardCondition: ValidDigivolveIntoHand,
  190. payCost: false,
  191. reduceCostTuple: null,
  192. fixedCostTuple: null,
  193. ignoreDigivolutionRequirementFixedCost: -1,
  194. isHand: true,
  195. activateClass: activateClass,
  196. successProcess: null));
  197. }
  198. }
  199. }
  200. }
  201. }
  202. #endregion
  203. #region Your Turn
  204. if (timing == EffectTiming.OnEnterFieldAnyone)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("Gain alliance then attack", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  209. activateClass.SetHashString("alliance-attack-ST20-06");
  210. cardEffects.Add(activateClass);
  211. string EffectDiscription()
  212. {
  213. 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.";
  214. }
  215. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  216. {
  217. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  218. permanent != card.PermanentOfThisCard() &&
  219. permanent.TopCard.EqualsTraits("ADVENTURE");
  220. }
  221. bool MyDigimonPlayedDigid(Permanent permanent)
  222. {
  223. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  224. permanent != card.PermanentOfThisCard();
  225. }
  226. bool MyDigimonAlliance(Permanent permanent)
  227. {
  228. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  229. }
  230. bool MyDigimonAttacking(Permanent permanent)
  231. {
  232. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  233. permanent.CanAttack(activateClass);
  234. }
  235. bool CanUseCondition(Hashtable hashtable)
  236. {
  237. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  238. {
  239. if (CardEffectCommons.IsOwnerTurn(card))
  240. {
  241. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  242. return true;
  243. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  244. return true;
  245. }
  246. }
  247. return false;
  248. }
  249. bool CanActivateCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. List<Permanent> etbPermanents = new List<Permanent>();
  256. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  257. if (hashtables != null)
  258. {
  259. foreach (Hashtable hashtable1 in hashtables)
  260. {
  261. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  262. if (permanent != null)
  263. etbPermanents.Add(permanent);
  264. }
  265. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  266. }
  267. if (etbPermanents.Count > 0)
  268. {
  269. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  270. {
  271. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  272. selectPermanentEffect.SetUp(
  273. selectPlayer: card.Owner,
  274. canTargetCondition: MyDigimonAlliance,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. maxCount: 1,
  278. canNoSelect: false,
  279. canEndNotMax: false,
  280. selectPermanentCoroutine: SelectBoostedDigimon,
  281. afterSelectPermanentCoroutine: null,
  282. mode: SelectPermanentEffect.Mode.Custom,
  283. cardEffect: activateClass);
  284. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  285. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  286. IEnumerator SelectBoostedDigimon(Permanent target)
  287. {
  288. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  289. }
  290. }
  291. }
  292. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  293. {
  294. Permanent selectedPermanent = null;
  295. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  296. selectPermanentEffect.SetUp(
  297. selectPlayer: card.Owner,
  298. canTargetCondition: MyDigimonAttacking,
  299. canTargetCondition_ByPreSelecetedList: null,
  300. canEndSelectCondition: null,
  301. maxCount: 1,
  302. canNoSelect: true,
  303. canEndNotMax: false,
  304. selectPermanentCoroutine: SelectPermanentCoroutine,
  305. afterSelectPermanentCoroutine: null,
  306. mode: SelectPermanentEffect.Mode.Custom,
  307. cardEffect: activateClass);
  308. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  309. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  310. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  311. {
  312. selectedPermanent = permanent;
  313. yield return null;
  314. }
  315. if (selectedPermanent.CanAttack(activateClass))
  316. {
  317. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  318. selectAttackEffect.SetUp(
  319. attacker: selectedPermanent,
  320. canAttackPlayerCondition: () => true,
  321. defenderCondition: _ => true,
  322. cardEffect: activateClass);
  323. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  324. }
  325. }
  326. }
  327. }
  328. #endregion
  329. #region Alliance Inherit
  330. if (timing == EffectTiming.OnAllyAttack)
  331. {
  332. bool Condition()
  333. {
  334. return CardEffectCommons.IsExistOnBattleArea(card);
  335. }
  336. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  337. }
  338. #endregion
  339. return cardEffects;
  340. }
  341. }
  342. }