BT23_032.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Shakkoumon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_032 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4
  18. && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region DNA Digivolution - Yellow Lv.4 + Black/Blue Lv.4: Cost 0
  30. if (timing == EffectTiming.None)
  31. {
  32. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  33. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  34. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  35. addJogressConditionClass.SetNotShowUI(true);
  36. cardEffects.Add(addJogressConditionClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return true;
  40. }
  41. JogressCondition GetJogress(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. bool PermanentCondition1(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  50. {
  51. if (permanent.Levels_ForJogress(card).Contains(4))
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool PermanentCondition2(Permanent permanent)
  60. {
  61. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  62. {
  63. if (permanent.TopCard.CardColors.Contains(CardColor.Black) || permanent.TopCard.CardColors.Contains(CardColor.Blue))
  64. {
  65. if (permanent.Levels_ForJogress(card).Contains(4))
  66. {
  67. return true;
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. JogressConditionElement[] elements = new JogressConditionElement[]
  74. {
  75. new JogressConditionElement(PermanentCondition1, "a level 4 Yellow Digimon"),
  76. new JogressConditionElement(PermanentCondition2, "a level 4 Black or Blue Digimon"),
  77. };
  78. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  79. return jogressCondition;
  80. }
  81. return null;
  82. }
  83. }
  84. #endregion
  85. #region When Digivolving
  86. if (timing == EffectTiming.OnEnterFieldAnyone)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("1 digimon gains [This digimon attacks at start of main phase]. then if DNA digivolved, <De-Digivolve 1>", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[When Digivolving] Until your opponent's turn ends, give 1 of their Digimon '[Start of Your Main Phase] This Digimon attacks.'. Then, if DNA digivolving, <De-Digivolve 1> 1 of your opponent's Digimon.";
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  99. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  104. }
  105. bool CanSelectPermamentCondition(Permanent permanent)
  106. {
  107. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  112. {
  113. Permanent selectedPermanent = null;
  114. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  115. selectPermanentEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectPermamentCondition,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: 1,
  121. canNoSelect: false,
  122. canEndNotMax: false,
  123. selectPermanentCoroutine: SelectPermanentCoroutine,
  124. afterSelectPermanentCoroutine: null,
  125. mode: SelectPermanentEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  128. "The opponent is selecting 1 Digimon that will get effects.");
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  131. {
  132. selectedPermanent = permanent;
  133. yield return null;
  134. }
  135. if (selectedPermanent != null)
  136. {
  137. ActivateClass activateClassDebuff = new ActivateClass();
  138. activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
  139. selectedPermanent.TopCard);
  140. activateClassDebuff.SetUpActivateClass(CanActivateConditionDebuff, ActivateCoroutineDebuff, -1, false,
  141. EffectDescriptionDebuff());
  142. activateClassDebuff.SetEffectSourcePermanent(selectedPermanent);
  143. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  144. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  145. {
  146. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  147. .CreateDebuffEffect(selectedPermanent));
  148. }
  149. string EffectDescriptionDebuff()
  150. {
  151. return "[Start of Your Main Phase] Attack with this Digimon.";
  152. }
  153. bool CanUseConditionDebuff(Hashtable hashtable1)
  154. {
  155. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  156. selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent) &&
  157. GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  158. }
  159. bool CanActivateConditionDebuff(Hashtable hashtable1)
  160. {
  161. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  162. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  163. selectedPermanent.CanAttack(activateClassDebuff);
  164. }
  165. IEnumerator ActivateCoroutineDebuff(Hashtable hashtableDebuff)
  166. {
  167. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  168. selectedPermanent.CanAttack(activateClassDebuff))
  169. {
  170. SelectAttackEffect selectAttackEffect =
  171. GManager.instance.GetComponent<SelectAttackEffect>();
  172. selectAttackEffect.SetUp(
  173. attacker: selectedPermanent,
  174. canAttackPlayerCondition: () => true,
  175. defenderCondition: _ => true,
  176. cardEffect: activateClassDebuff);
  177. selectAttackEffect.SetCanNotSelectNotAttack();
  178. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  179. }
  180. }
  181. ICardEffect GetCardEffect(EffectTiming timingDebuff)
  182. {
  183. return timingDebuff == EffectTiming.OnStartMainPhase ? activateClassDebuff : null;
  184. }
  185. }
  186. }
  187. if (CardEffectCommons.IsJogress(hashtable) && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  188. {
  189. Permanent selectedPermanent = null;
  190. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: CanSelectPermamentCondition,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: 1,
  197. canNoSelect: false,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: SelectPermanentCoroutine,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.Custom,
  202. cardEffect: activateClass);
  203. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <De-digivolve 1>.", "The opponent is selecting 1 Digimon to gain <De-digivolve 1>.");
  204. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  205. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  206. {
  207. selectedPermanent = permanent;
  208. yield return null;
  209. }
  210. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  211. permanent: selectedPermanent,
  212. DegenerationCount: 1,
  213. cardEffect: activateClass).Degeneration());
  214. }
  215. }
  216. }
  217. #endregion
  218. #region All Turns Shared
  219. string SharedEffectName() => "Play 1 level 4- [Yellow]/[Black]/[CS] trait digimon from digivolution sources";
  220. string SharedEffectDiscription(string tag) => $"[{tag}] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, you may play 1 level 4 or lower yellow, black or [CS] trait Digimon card from its digivolution cards without paying the cost.";
  221. bool SharedCanActivateCondition(Hashtable hashtable)
  222. {
  223. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  224. }
  225. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass, bool IsTopCard)
  226. {
  227. bool CanSelectCardCondition(CardSource cardSource)
  228. {
  229. return cardSource.IsDigimon
  230. && cardSource.HasLevel && cardSource.Level <= 4
  231. && (cardSource.HasCardColor(CardColor.Yellow) || cardSource.HasCardColor(CardColor.Black) || cardSource.HasCSTraits)
  232. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  233. }
  234. var thisPermament = card.PermanentOfThisCard();
  235. if (thisPermament.StackCards.Exists(CanSelectCardCondition))
  236. {
  237. CardSource selectedCard = null;
  238. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  239. int maxCount = Math.Min(1, thisPermament.StackCards.Filter(CanSelectCardCondition).Count);
  240. selectCardEffect.SetUp(
  241. canTargetCondition: CanSelectCardCondition,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. canNoSelect: () => true,
  245. selectCardCoroutine: SelectCardCoroutine,
  246. afterSelectCardCoroutine: null,
  247. message: "Select 1 digivolution card to play.",
  248. maxCount: maxCount,
  249. canEndNotMax: false,
  250. isShowOpponent: true,
  251. mode: SelectCardEffect.Mode.Custom,
  252. root: SelectCardEffect.Root.Custom,
  253. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  254. canLookReverseCard: true,
  255. selectPlayer: card.Owner,
  256. cardEffect: null);
  257. IEnumerator SelectCardCoroutine(CardSource cardSource)
  258. {
  259. selectedCard = cardSource;
  260. yield return null;
  261. }
  262. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  263. selectCardEffect.SetUpCustomMessage_ShowCard("Selected card");
  264. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  265. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  266. cardSources: new List<CardSource>() { selectedCard },
  267. activateClass: activateClass,
  268. payCost: false,
  269. isTapped: false,
  270. root: SelectCardEffect.Root.DigivolutionCards,
  271. activateETB: true));
  272. }
  273. }
  274. #endregion
  275. #region All Turns - OPT
  276. if (timing == EffectTiming.WhenRemoveField)
  277. {
  278. ActivateClass activateClass = new ActivateClass();
  279. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  280. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass, true), 1, true, SharedEffectDiscription("All Turns"));
  281. activateClass.SetHashString("BT23_032_AT");
  282. cardEffects.Add(activateClass);
  283. bool CanUseCondition(Hashtable hashtable)
  284. {
  285. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  286. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  287. && !CardEffectCommons.IsByEffect(hashtable, effect => effect.EffectSourceCard.Owner == card.Owner);
  288. }
  289. }
  290. #endregion
  291. #region All Turns - OPT - ESS
  292. if (timing == EffectTiming.WhenRemoveField)
  293. {
  294. ActivateClass activateClass = new ActivateClass();
  295. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  296. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass, false), 1, true, SharedEffectDiscription("Inherited All Turns"));
  297. activateClass.SetIsInheritedEffect(true);
  298. activateClass.SetHashString("BT23_032_AT_ESS");
  299. cardEffects.Add(activateClass);
  300. bool CanUseCondition(Hashtable hashtable)
  301. {
  302. return CardEffectCommons.IsExistOnField(card)
  303. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermamentCondition)
  304. && !CardEffectCommons.IsByEffect(hashtable, effect => effect.EffectSourceCard.Owner == card.Owner);
  305. }
  306. bool PermamentCondition(Permanent permanent)
  307. {
  308. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  309. && permanent == card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  310. }
  311. }
  312. #endregion
  313. return cardEffects;
  314. }
  315. }
  316. }