ST20_06.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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, EffectDescription());
  209. activateClass.SetIsSkippableFunction(IsSkippable);
  210. activateClass.SetHashString("alliance-attack-ST20_06");
  211. cardEffects.Add(activateClass);
  212. string EffectDescription()
  213. {
  214. 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.";
  215. }
  216. bool IsSkippable(Hashtable hashtable)
  217. {
  218. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  219. if (hashtables != null)
  220. {
  221. foreach (Hashtable hashtable1 in hashtables)
  222. {
  223. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  224. if (permanent != null && MyDigimonAdventurePlayedDigid(permanent))
  225. return false;
  226. }
  227. }
  228. return true;
  229. }
  230. bool MyDigimonAdventurePlayedDigid(Permanent permanent)
  231. {
  232. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  233. permanent != card.PermanentOfThisCard() &&
  234. permanent.TopCard.EqualsTraits("ADVENTURE");
  235. }
  236. bool MyDigimonPlayedDigid(Permanent permanent)
  237. {
  238. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  239. permanent != card.PermanentOfThisCard();
  240. }
  241. bool MyDigimonAlliance(Permanent permanent)
  242. {
  243. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  244. }
  245. bool MyDigimonAttacking(Permanent permanent)
  246. {
  247. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  248. permanent.CanAttack(activateClass);
  249. }
  250. bool CanUseCondition(Hashtable hashtable)
  251. {
  252. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  253. {
  254. if (CardEffectCommons.IsOwnerTurn(card))
  255. {
  256. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, MyDigimonPlayedDigid))
  257. return true;
  258. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, MyDigimonPlayedDigid))
  259. return true;
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  267. {
  268. return true;
  269. }
  270. return false;
  271. }
  272. IEnumerator ActivateCoroutine(Hashtable hashtable)
  273. {
  274. bool Used = false;
  275. List<Permanent> etbPermanents = new List<Permanent>();
  276. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  277. if (hashtables != null)
  278. {
  279. foreach (Hashtable hashtable1 in hashtables)
  280. {
  281. Permanent permanent = CardEffectCommons.GetPermanentFromHashtable(hashtable1);
  282. if (permanent != null)
  283. etbPermanents.Add(permanent);
  284. }
  285. etbPermanents = etbPermanents.Filter(MyDigimonAdventurePlayedDigid);
  286. }
  287. if (etbPermanents.Count > 0)
  288. {
  289. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAlliance))
  290. {
  291. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  292. selectPermanentEffect.SetUp(
  293. selectPlayer: card.Owner,
  294. canTargetCondition: MyDigimonAlliance,
  295. canTargetCondition_ByPreSelecetedList: null,
  296. canEndSelectCondition: null,
  297. maxCount: 1,
  298. canNoSelect: false,
  299. canEndNotMax: false,
  300. selectPermanentCoroutine: SelectBoostedDigimon,
  301. afterSelectPermanentCoroutine: null,
  302. mode: SelectPermanentEffect.Mode.Custom,
  303. cardEffect: activateClass);
  304. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance>", "The opponent is selecting 1 Digimon to gain <Alliance>");
  305. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  306. IEnumerator SelectBoostedDigimon(Permanent target)
  307. {
  308. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: target, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  309. }
  310. Used = true;
  311. }
  312. }
  313. if (CardEffectCommons.HasMatchConditionPermanent(MyDigimonAttacking))
  314. {
  315. Permanent selectedPermanent = null;
  316. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  317. selectPermanentEffect.SetUp(
  318. selectPlayer: card.Owner,
  319. canTargetCondition: MyDigimonAttacking,
  320. canTargetCondition_ByPreSelecetedList: null,
  321. canEndSelectCondition: null,
  322. maxCount: 1,
  323. canNoSelect: true,
  324. canEndNotMax: false,
  325. selectPermanentCoroutine: SelectPermanentCoroutine,
  326. afterSelectPermanentCoroutine: null,
  327. mode: SelectPermanentEffect.Mode.Custom,
  328. cardEffect: activateClass);
  329. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.", "The opponent is selecting 1 Digimon to attack.");
  330. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  331. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  332. {
  333. selectedPermanent = permanent;
  334. yield return null;
  335. }
  336. if (selectedPermanent != null)
  337. {
  338. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  339. selectAttackEffect.SetUp(
  340. attacker: selectedPermanent,
  341. canAttackPlayerCondition: () => true,
  342. defenderCondition: _ => true,
  343. cardEffect: activateClass);
  344. selectAttackEffect.SetAfterOnAttackCoroutine(AfterOnAttackCoroutine);
  345. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  346. }
  347. IEnumerator AfterOnAttackCoroutine()
  348. {
  349. Used = true;
  350. yield return null;
  351. }
  352. }
  353. if (!Used)
  354. {
  355. activateClass.RemoveUse();
  356. }
  357. }
  358. }
  359. #endregion
  360. #region Alliance Inherit
  361. if (timing == EffectTiming.OnAllyAttack)
  362. {
  363. bool Condition()
  364. {
  365. return CardEffectCommons.IsExistOnBattleArea(card);
  366. }
  367. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: true, card: card, condition: Condition));
  368. }
  369. #endregion
  370. return cardEffects;
  371. }
  372. }
  373. }