ST20_06.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  252. {
  253. return true;
  254. }
  255. return false;
  256. }
  257. IEnumerator ActivateCoroutine(Hashtable hashtable)
  258. {
  259. List<Permanent> etbPermanents = new List<Permanent>();
  260. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  261. if (hashtables != null)
  262. {
  263. foreach (Hashtable hashtable1 in hashtables)
  264. {
  265. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  266. if (permanent != null)
  267. etbPermanents.Add(permanent);
  268. }
  269. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  270. }
  271. if (etbPermanents.Count > 0)
  272. {
  273. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  274. {
  275. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  276. selectPermanentEffect.SetUp(
  277. selectPlayer: card.Owner,
  278. canTargetCondition: MyDigimonAlliance,
  279. canTargetCondition_ByPreSelecetedList: null,
  280. canEndSelectCondition: null,
  281. maxCount: 1,
  282. canNoSelect: false,
  283. canEndNotMax: false,
  284. selectPermanentCoroutine: SelectBoostedDigimon,
  285. afterSelectPermanentCoroutine: null,
  286. mode: SelectPermanentEffect.Mode.Custom,
  287. cardEffect: activateClass);
  288. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  289. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  290. IEnumerator SelectBoostedDigimon(Permanent target)
  291. {
  292. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); ;
  293. }
  294. }
  295. }
  296. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  297. {
  298. Permanent selectedPermanent = null;
  299. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  300. selectPermanentEffect.SetUp(
  301. selectPlayer: card.Owner,
  302. canTargetCondition: MyDigimonAttacking,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. maxCount: 1,
  306. canNoSelect: true,
  307. canEndNotMax: false,
  308. selectPermanentCoroutine: SelectPermanentCoroutine,
  309. afterSelectPermanentCoroutine: null,
  310. mode: SelectPermanentEffect.Mode.Custom,
  311. cardEffect: activateClass);
  312. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  313. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  314. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  315. {
  316. selectedPermanent = permanent;
  317. yield return null;
  318. }
  319. if (selectedPermanent != null)
  320. {
  321. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  322. selectAttackEffect.SetUp(
  323. attacker: selectedPermanent,
  324. canAttackPlayerCondition: () => true,
  325. defenderCondition: _ => true,
  326. cardEffect: activateClass);
  327. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  328. }
  329. }
  330. }
  331. }
  332. #endregion
  333. #region Alliance Inherit
  334. if (timing == EffectTiming.OnAllyAttack)
  335. {
  336. bool Condition()
  337. {
  338. return CardEffectCommons.IsExistOnBattleArea(card);
  339. }
  340. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  341. }
  342. #endregion
  343. return cardEffects;
  344. }
  345. }
  346. }