BT22_031.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // GoldNumemon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_031 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return (targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.ContainsCardName("Numemon") || targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasCSTraits);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region OP/WD Shared
  24. bool SharedOpponentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  27. }
  28. bool SharedIsPlatinumNumemon(CardSource cardSource)
  29. {
  30. return CardEffectCommons.IsExistOnHand(cardSource) && cardSource.EqualsCardName("PlatinumNumemon");
  31. }
  32. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  33. {
  34. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedOpponentCondition))
  35. {
  36. #region -2 Sec Attack
  37. Permanent selectedPermament = null;
  38. #region Select Permanent
  39. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, SharedOpponentCondition));
  40. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  41. selectPermanentEffect.SetUp(
  42. selectPlayer: card.Owner,
  43. canTargetCondition: SharedOpponentCondition,
  44. canTargetCondition_ByPreSelecetedList: null,
  45. canEndSelectCondition: null,
  46. maxCount: maxCount,
  47. canNoSelect: false,
  48. canEndNotMax: false,
  49. selectPermanentCoroutine: SelectPermanentCoroutine,
  50. afterSelectPermanentCoroutine: null,
  51. mode: SelectPermanentEffect.Mode.Custom,
  52. cardEffect: activateClass);
  53. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  54. {
  55. selectedPermament = permanent;
  56. yield return null;
  57. }
  58. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to give -2 Sec Atk", "The opponent is selecting 1 Digimon to give -2 Sec Atk");
  59. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  60. #endregion
  61. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(
  62. CardEffectCommons.ChangeDigimonSAttack(selectedPermament, -2, EffectDuration.UntilOpponentTurnEnd, activateClass));
  63. #endregion
  64. }
  65. if (card.PermanentOfThisCard().StackCards
  66. .Filter(x => !x.IsFlipped)
  67. .GroupBy(x => x.Level)
  68. .Any(g => g.Count() >= 2) &&
  69. CardEffectCommons.HasMatchConditionOwnersHand(card, SharedIsPlatinumNumemon))
  70. {
  71. #region Digivolve into PlatinumNumemon
  72. yield return ContinuousController.instance.StartCoroutine(
  73. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  74. targetPermanent: card.PermanentOfThisCard(),
  75. cardCondition: SharedIsPlatinumNumemon,
  76. payCost: true,
  77. reduceCostTuple: null,
  78. fixedCostTuple: null,
  79. ignoreDigivolutionRequirementFixedCost: 4,
  80. isHand: true,
  81. activateClass: activateClass,
  82. successProcess: null));
  83. #endregion
  84. }
  85. }
  86. #endregion
  87. #region On Play
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Give 1 digimon -2 Sec Atk. then if sources has 2 same level digimon, digivolve into [PlatinumNumemon]", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[On Play] Give 1 of your opponent's Digimon <Security A. -2> (This Digimon checks 2 additional security cards.) until their turn ends. Then, if this Digimon's stack has 2 or more same-level cards, this Digimon may digivolve into [PlatinumNumemon] in the hand for a digivolution cost of 4, ignoring digivolution requirements.";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable hashtable)
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  109. }
  110. }
  111. #endregion
  112. #region When Digivolving
  113. if (timing == EffectTiming.OnEnterFieldAnyone)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect("Give 1 digimon -2 Sec Atk. then if sources has 2 same level digimon, digivolve into [PlatinumNumemon]", CanUseCondition, card);
  117. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  118. cardEffects.Add(activateClass);
  119. string EffectDiscription()
  120. {
  121. return "[When Digivolving] Give 1 of your opponent's Digimon <Security A. -2> (This Digimon checks 2 additional security cards.) until their turn ends. Then, if this Digimon's stack has 2 or more same-level cards, this Digimon may digivolve into [PlatinumNumemon] in the hand for a digivolution cost of 4, ignoring digivolution requirements.";
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(SharedActivateCoroutine(hashtable, activateClass));
  134. }
  135. }
  136. #endregion
  137. #region ESS
  138. ActivateClass activateClass2 = new ActivateClass();
  139. activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card);
  140. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2());
  141. activateClass2.SetIsInheritedEffect(true);
  142. activateClass2.SetNotShowUI(true);
  143. activateClass2.SetIsBackgroundProcess(true);
  144. activateClass2.SetHashString("BT22_031_ESS");
  145. string EffectDiscription2()
  146. {
  147. return "[Your Turn] [Once Per Turn] When this Digimon would digivolve into a Digimon card with the [CS] trait, reduce the digivolution cost by 1.";
  148. }
  149. bool CanUseCondition2(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleArea(card))
  152. {
  153. if (CardEffectCommons.IsOwnerTurn(card))
  154. {
  155. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  156. {
  157. List<CardSource> evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable(
  158. hashtable,
  159. permanent => permanent.cardSources.Contains(card));
  160. if (evoRootTops != null)
  161. {
  162. if (!evoRootTops.Contains(card))
  163. {
  164. if (card.PermanentOfThisCard().TopCard.HasCSTraits)
  165. {
  166. return true;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. return false;
  174. }
  175. bool CanActivateCondition2(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleArea(card);
  178. }
  179. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  180. {
  181. yield return null;
  182. }
  183. if (timing == EffectTiming.OnEnterFieldAnyone)
  184. {
  185. cardEffects.Add(activateClass2);
  186. }
  187. #region Setup Reduce Cost Class
  188. if (timing == EffectTiming.None)
  189. {
  190. ChangeCostClass changeCostClass = new ChangeCostClass();
  191. changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card);
  192. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  193. changeCostClass.SetIsInheritedEffect(true);
  194. cardEffects.Add(changeCostClass);
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.IsExistOnBattleArea(card))
  198. {
  199. if (CardEffectCommons.IsOwnerTurn(card))
  200. {
  201. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  202. {
  203. return true;
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  210. {
  211. if (CardSourceCondition(cardSource))
  212. {
  213. if (RootCondition(root))
  214. {
  215. if (PermanentsCondition(targetPermanents))
  216. {
  217. Cost -= 1;
  218. }
  219. }
  220. }
  221. return Cost;
  222. }
  223. bool PermanentsCondition(List<Permanent> targetPermanents)
  224. {
  225. if (targetPermanents != null)
  226. {
  227. if (targetPermanents.Count(PermanentCondition) >= 1)
  228. {
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. bool PermanentCondition(Permanent targetPermanent)
  235. {
  236. return targetPermanent == card.PermanentOfThisCard();
  237. }
  238. bool CardSourceCondition(CardSource cardSource)
  239. {
  240. return cardSource.HasCSTraits;
  241. }
  242. bool RootCondition(SelectCardEffect.Root root)
  243. {
  244. return true;
  245. }
  246. bool isUpDown()
  247. {
  248. return true;
  249. }
  250. }
  251. #endregion
  252. #endregion
  253. return cardEffects;
  254. }
  255. }
  256. }