EX11_032.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. // GrandGalemon
  8. public class EX11_032 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Hand Main
  14. if (timing == EffectTiming.OnDeclaration)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Place 1 [Galemon] from trash under 1 [Pteromon], to digivolve for 3", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. => "[Hand] [Main] If you have [Shoto Kazama], by placing 1 [Galemon] from your trash as your [Pteromon]'s bottom digivolution card, it digivolves into this card for a digivolution cost of 3, ignoring digivolution requirements.";
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsExistOnHand(card)
  25. && CardEffectCommons.IsOwnerTurn(card)
  26. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsShoto)
  27. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsPteromon)
  28. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsGalemon);
  29. }
  30. bool IsShoto(Permanent permanent)
  31. {
  32. return permanent.TopCard.EqualsCardName("Shoto Kazama");
  33. }
  34. bool IsPteromon(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  37. permanent.TopCard.EqualsCardName("Pteromon");
  38. }
  39. bool IsGalemon(CardSource source)
  40. {
  41. return source.IsDigimon && source.EqualsCardName("Galemon");
  42. }
  43. bool IsGrandGalemon(CardSource source)
  44. {
  45. return CardEffectCommons.IsExistOnHand(source) && source == card;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsShoto))
  50. {
  51. Permanent pteromon = null;
  52. CardSource galemon = null;
  53. #region Select Galemon From Trash
  54. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsGalemon));
  55. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  56. selectCardEffect.SetUp(
  57. canTargetCondition: IsGalemon,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. canNoSelect: () => false,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. message: "Select 1 [Galemon] to add as digivolution source",
  64. maxCount: maxCount,
  65. canEndNotMax: false,
  66. isShowOpponent: true,
  67. mode: SelectCardEffect.Mode.Custom,
  68. root: SelectCardEffect.Root.Trash,
  69. customRootCardList: null,
  70. canLookReverseCard: true,
  71. selectPlayer: card.Owner,
  72. cardEffect: activateClass);
  73. IEnumerator SelectCardCoroutine(CardSource cardSource)
  74. {
  75. galemon = cardSource;
  76. yield return null;
  77. }
  78. selectCardEffect.SetUpCustomMessage("Select 1 [Galemon] to add as digivolution source.", "The opponent is selecting 1 [Galemon] to add as digivolution source.");
  79. yield return StartCoroutine(selectCardEffect.Activate());
  80. #endregion
  81. if (galemon != null)
  82. {
  83. #region Select Pteromon Permanent
  84. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsPteromon));
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: IsPteromon,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount1,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: SelectPermanentCoroutine,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. pteromon = permanent;
  101. yield return null;
  102. }
  103. selectPermanentEffect.SetUpCustomMessage("Select 1 [Pteromon] to add digivolution sources.", "The opponent is selecting 1 [Pteromon] to add digivolution sources.");
  104. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  105. #endregion
  106. if (pteromon != null)
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(pteromon.AddDigivolutionCardsBottom(new List<CardSource>() { galemon }, activateClass));
  109. if (pteromon.DigivolutionCards.Contains(galemon))
  110. {
  111. #region Digivolve into GrandGalemon
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  113. pteromon,
  114. IsGrandGalemon,
  115. payCost: true,
  116. reduceCostTuple: null,
  117. fixedCostTuple: null,
  118. ignoreDigivolutionRequirementFixedCost: 3,
  119. isHand: true,
  120. activateClass: activateClass,
  121. successProcess: null,
  122. ignoreSelection: true,
  123. failedProcess: FailureProcess(),
  124. isOptional: false));
  125. #endregion
  126. }
  127. IEnumerator FailureProcess()
  128. {
  129. List<IDiscardHand> discardHands = new List<IDiscardHand>() { new IDiscardHand(card, null) };
  130. yield return ContinuousController.instance.StartCoroutine(new IDiscardHands(discardHands, null).DiscardHands());
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. #endregion
  138. #region When Digivolving
  139. if (timing == EffectTiming.OnEnterFieldAnyone)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("May Suspend 1 Digimon. May play 1 [Avian] or [Bird] in traits with 3k DP + 1k per suspended digimon.", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  144. cardEffects.Add(activateClass);
  145. string EffectDescription()
  146. => "[When Digivolving] You may suspend 1 Digimon. Then, you may play 1 3000 DP or lower green Digimon card with [Avian] or [Bird] in any of its traits from your hand without paying the cost. For each suspended Digimon, add 1000 to this effect's DP maximum.";
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleArea(card)
  150. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  153. bool CanSuspendPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  154. bool CanPlayBirdCondition(CardSource cardSource, int maxDP)
  155. {
  156. return cardSource.IsDigimon
  157. && cardSource.HasBirdTraits
  158. && cardSource.HasDP
  159. && cardSource.CardDP <= maxDP;
  160. }
  161. bool IsSuspendedPermanent(Permanent permanent) => permanent.IsDigimon && permanent.IsSuspended;
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSuspendPermanentCondition))
  165. {
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSuspendPermanentCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: 1,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: null,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Tap,
  178. cardEffect: activateClass);
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. }
  181. int maxDP = 3000 + (1000 * CardEffectCommons.MatchConditionPermanentCount(IsSuspendedPermanent));
  182. if (card.Owner.HandCards.Count(cardSource => CanPlayBirdCondition(cardSource, maxDP)) >= 1)
  183. {
  184. List<CardSource> selectedCards = new List<CardSource>();
  185. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  186. selectHandEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: cardSource => CanPlayBirdCondition(cardSource, maxDP),
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: 1,
  192. canNoSelect: true,
  193. canEndNotMax: false,
  194. isShowOpponent: true,
  195. selectCardCoroutine: SelectCardCoroutine,
  196. afterSelectCardCoroutine: null,
  197. mode: SelectHandEffect.Mode.Custom,
  198. cardEffect: activateClass);
  199. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  200. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  201. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  202. IEnumerator SelectCardCoroutine(CardSource cardSource)
  203. {
  204. selectedCards.Add(cardSource);
  205. yield return null;
  206. }
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  208. cardSources: selectedCards,
  209. activateClass: activateClass,
  210. payCost: false,
  211. isTapped: false,
  212. root: SelectCardEffect.Root.Hand,
  213. activateETB: true));
  214. }
  215. }
  216. }
  217. #endregion
  218. #region ESS - Win Battle
  219. if (timing == EffectTiming.OnEndBattle)
  220. {
  221. ActivateClass activateClass = new ActivateClass();
  222. activateClass.SetUpICardEffect("May Unsuspend", CanUseCondition, card);
  223. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  224. activateClass.SetIsInheritedEffect(true);
  225. activateClass.SetHashString("EX11_032_ESS_Unsuspend");
  226. cardEffects.Add(activateClass);
  227. string EffectDescription()
  228. => "[Your Turn] [Once Per Turn] When this Digimon wins a battle, this [Vortex Warriors] trait Digimon may unsuspend.";
  229. bool CanUseCondition(Hashtable hashtable)
  230. {
  231. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  232. {
  233. if (CardEffectCommons.IsOwnerTurn(card))
  234. {
  235. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  236. if (CardEffectCommons.CanTriggerWhenWinBattle(
  237. hashtable: hashtable,
  238. winnerCondition: WinnerCondition))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. return false;
  245. }
  246. bool CanActivateCondition(Hashtable hashtable)
  247. {
  248. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  249. && card.PermanentOfThisCard().TopCard.EqualsTraits("Vortex Warriors")
  250. && card.PermanentOfThisCard().IsSuspended;
  251. }
  252. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  253. {
  254. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  255. }
  256. }
  257. #endregion
  258. return cardEffects;
  259. }
  260. }
  261. }