EX12_048.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Unity.Mathematics;
  5. // SeitenGokuumon
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_048 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasText("Gokuumon")
  19. || targetPermanent.TopCard.EqualsTraits("Shambala");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null, level: 5));
  22. }
  23. #endregion
  24. #region Static Keywords
  25. #region Rush
  26. if (timing == EffectTiming.None)
  27. {
  28. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Raid
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region Piercing
  38. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  39. {
  40. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Security A. +1
  44. if (timing == EffectTiming.None)
  45. {
  46. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  47. }
  48. #endregion
  49. #endregion
  50. #region Shared OP/WD
  51. string SharedEffectName = "Give 1 enemy Digimon -8K DP + -3K DP per lvl 5 in source, then this may attack";
  52. CardEffectFactory.ActivateClassesForSharedEffects
  53. (ref cardEffects, timing, card,
  54. SharedEffectName,
  55. SharedActivateCoroutine,
  56. SharedEffectDescription,
  57. optional: false,
  58. onPlay: true,
  59. whenDigivolving: true);
  60. string SharedEffectDescription(string tag)
  61. {
  62. return $"[{tag}] 1 of your opponent's Digimon gets -8000 DP until their turn ends. It further gets -3000 DP for each of this Digimon's level 5 digivolution cards. Then, this Digimon may attack.";
  63. }
  64. bool CanSelectPermanentCondition(Permanent permanent)
  65. {
  66. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  67. }
  68. bool DigivolutionCardCondition(CardSource cardSource)
  69. {
  70. return cardSource.IsLevel5;
  71. }
  72. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  73. {
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. int dpMinus = -8000 + card.PermanentOfThisCard().DigivolutionCards.Filter(DigivolutionCardCondition).Count() * -3000;
  77. Permanent selectedPermament = null;
  78. #region Select Permanent
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. selectPermanentEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CanSelectPermanentCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: false,
  87. canEndNotMax: false,
  88. selectPermanentCoroutine: SelectPermanentCoroutine,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Custom,
  91. cardEffect: activateClass);
  92. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  93. {
  94. selectedPermament = permanent;
  95. yield return null;
  96. }
  97. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to {dpMinus} DP", $"The opponent is selecting 1 Digimon to {dpMinus} DP");
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. #endregion
  100. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  101. targetPermanent: selectedPermament,
  102. changeValue: dpMinus,
  103. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  104. activateClass: activateClass
  105. ));
  106. }
  107. if (card.PermanentOfThisCard().CanAttack(activateClass))
  108. {
  109. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  110. selectAttackEffect.SetUp(
  111. attacker: card.PermanentOfThisCard(),
  112. canAttackPlayerCondition: () => true,
  113. defenderCondition: _ => true,
  114. cardEffect: activateClass);
  115. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  116. }
  117. }
  118. #endregion
  119. #region All Turns
  120. if (timing == EffectTiming.WhenRemoveField)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("May play 2 [Gokuumon] in text/[SW] trait cards from sources for free", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  125. cardEffects.Add(activateClass);
  126. string EffectDescription()
  127. {
  128. return "[All Turns] When this Digimon would leave the battle area other than by your effects, you may play 2 level 5 cards with [Gokuumon] in their texts or the [SW] trait from its digivolution cards without paying the costs.";
  129. }
  130. bool CanSelectSourceCardCondition(CardSource cardSource)
  131. {
  132. return cardSource.IsLevel5
  133. && (cardSource.HasText("Gokuumon")
  134. || cardSource.EqualsTraits("SW"))
  135. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  140. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  141. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  146. && card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. List<CardSource> selectedCards = new List<CardSource>();
  151. int maxCount = math.min(2, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition));
  152. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  153. selectCardEffect.SetUp(
  154. canTargetCondition: CanSelectSourceCardCondition,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. canNoSelect: () => true,
  158. selectCardCoroutine: SelectCardCoroutine,
  159. afterSelectCardCoroutine: null,
  160. message: "Select card(s) to play",
  161. maxCount: maxCount,
  162. canEndNotMax: false,
  163. isShowOpponent: true,
  164. mode: SelectCardEffect.Mode.Custom,
  165. root: SelectCardEffect.Root.DigivolutionCards,
  166. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  167. canLookReverseCard: true,
  168. selectPlayer: card.Owner,
  169. cardEffect: activateClass);
  170. selectCardEffect.SetUpCustomMessage(
  171. "Select [Gokuumon] in text/[SW] trait card(s) to play.",
  172. "The opponent is selecting [Gokuumon] in text/[SW] trait card(s) to play.");
  173. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card(s)");
  174. yield return StartCoroutine(selectCardEffect.Activate());
  175. IEnumerator SelectCardCoroutine(CardSource cardSource)
  176. {
  177. selectedCards.Add(cardSource);
  178. yield return null;
  179. }
  180. yield return ContinuousController.instance.StartCoroutine(
  181. CardEffectCommons.PlayPermanentCards(
  182. cardSources: selectedCards,
  183. activateClass: activateClass,
  184. payCost: false,
  185. isTapped: false,
  186. root: SelectCardEffect.Root.DigivolutionCards,
  187. activateETB: true));
  188. }
  189. }
  190. #endregion
  191. #region Assembly
  192. if (timing == EffectTiming.None)
  193. {
  194. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  195. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  196. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  197. addAssemblyConditionClass.SetNotShowUI(true);
  198. cardEffects.Add(addAssemblyConditionClass);
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. return true;
  202. }
  203. AssemblyCondition GetAssembly(CardSource cardSource)
  204. {
  205. if (cardSource == card)
  206. {
  207. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  208. bool CanSelectCardCondition(CardSource cardSource)
  209. {
  210. return cardSource != null
  211. && cardSource.Owner == card.Owner
  212. && cardSource.IsDigimon
  213. && (cardSource.EqualsCardName("Gokuumon")
  214. || cardSource.EqualsCardName("Sagomon")
  215. || cardSource.EqualsCardName("Cho-Hakkaimon")
  216. || cardSource.EqualsCardName("Sanzomon"));
  217. }
  218. bool CanTargetCondition_ByPreSelecetedList(List<CardSource> cardSources, CardSource cardSource)
  219. {
  220. List<string> cardNames = new List<string>();
  221. foreach (CardSource cardSource1 in cardSources)
  222. {
  223. foreach (string cardName in cardSource1.CardNames)
  224. {
  225. if (!cardNames.Contains(cardName))
  226. {
  227. cardNames.Add(cardName);
  228. }
  229. }
  230. }
  231. if (cardSource.CardNames.Count((cardName) => cardNames.Contains(cardName)) >= 1)
  232. {
  233. return false;
  234. }
  235. return true;
  236. }
  237. AssemblyCondition assemblyCondition = new AssemblyCondition(
  238. element: element,
  239. CanTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  240. selectMessage: "3 [Gokuumon] / [Sagomon] / [Cho - Hakkaimon] / [Sanzomon] w/ different names",
  241. elementCount: 3,
  242. reduceCost: 6);
  243. return assemblyCondition;
  244. }
  245. return null;
  246. }
  247. }
  248. #endregion
  249. return cardEffects;
  250. }
  251. }
  252. }