BT23_033.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Beautymon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_033 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasSuperAppTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 4,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion Alternative Digivolution Condition
  29. #region App Fusion (Coordemon & Consulmon)
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Coordemon", "Consulmon" }, card));
  33. }
  34. #endregion App Fusion (Coordemon & Consulmon)
  35. #region Linking
  36. if (timing == EffectTiming.OnDeclaration)
  37. {
  38. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  39. }
  40. #endregion Linking
  41. #region Link condition
  42. if (timing == EffectTiming.None)
  43. {
  44. bool PermanentCondition(Permanent permanent)
  45. {
  46. return permanent.TopCard.HasAppmonTraits;
  47. }
  48. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  49. }
  50. #endregion Link condition
  51. #region Barrier
  52. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  53. {
  54. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  55. }
  56. #endregion
  57. #endregion Static Effects
  58. #region OP/WD Shared
  59. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. Permanent thisPermament = card.PermanentOfThisCard();
  62. bool CanSelectCardSource(CardSource cardSource)
  63. {
  64. return cardSource.IsDigimon
  65. && cardSource.HasLevel && cardSource.Level <= 4
  66. && cardSource.CanLinkToTargetPermanent(thisPermament, false);
  67. }
  68. bool canSelectSources = thisPermament.DigivolutionCards.Exists(CanSelectCardSource);
  69. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardSource);
  70. if (canSelectSources || canSelectTrash)
  71. {
  72. if (canSelectSources && canSelectTrash)
  73. {
  74. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  75. {
  76. new SelectionElement<bool>(message: $"From digivolution sources", value : true, spriteIndex: 0),
  77. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  78. };
  79. string selectPlayerMessage = "From which area do you select a card?";
  80. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  81. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  82. }
  83. else
  84. {
  85. GManager.instance.userSelectionManager.SetBool(canSelectSources);
  86. }
  87. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  88. bool fromSources = GManager.instance.userSelectionManager.SelectedBoolValue;
  89. CardSource selectedCard = null;
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCard = cardSource;
  93. yield return null;
  94. }
  95. if (fromSources)
  96. {
  97. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  98. selectCardEffect.SetUp(
  99. canTargetCondition: CanSelectCardSource,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. canNoSelect: () => true,
  103. selectCardCoroutine: SelectCardCoroutine,
  104. afterSelectCardCoroutine: null,
  105. message: "elect 1 card to link to digimon.",
  106. maxCount: 1,
  107. canEndNotMax: false,
  108. isShowOpponent: true,
  109. mode: SelectCardEffect.Mode.Custom,
  110. root: SelectCardEffect.Root.DigivolutionCards,
  111. customRootCardList: thisPermament.DigivolutionCards,
  112. canLookReverseCard: true,
  113. selectPlayer: card.Owner,
  114. cardEffect: activateClass);
  115. selectCardEffect.SetUpCustomMessage("Select 1 card to link to digimon.", "The opponent is selecting 1 card to link to digimon.");
  116. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  117. }
  118. else
  119. {
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: CanSelectCardSource,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 card to link to digimon.",
  129. maxCount: 1,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.Custom,
  133. root: SelectCardEffect.Root.Trash,
  134. customRootCardList: null,
  135. canLookReverseCard: true,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. selectCardEffect.SetUpCustomMessage("Select 1 card to link to digimon.", "The opponent is selecting 1 card to link to digimon.");
  139. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  140. }
  141. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(thisPermament.AddLinkCard(
  142. addedLinkCard: selectedCard,
  143. cardEffect: activateClass));
  144. }
  145. }
  146. #endregion OP/WD Shared
  147. #region On Play
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("link 1 level 4- digimon from trash or digivolution sources to this digimon", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  153. cardEffects.Add(activateClass);
  154. string EffectDiscription()
  155. {
  156. return "[On Play] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  161. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  166. }
  167. }
  168. #endregion On Play
  169. #region When Digivolving
  170. if (timing == EffectTiming.OnEnterFieldAnyone)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("link 1 level 4- digimon from trash or digivolution sources to this digimon", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  183. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  188. }
  189. }
  190. #endregion When Digivolving
  191. #region Your Turn - OPT
  192. if (timing == EffectTiming.WhenLinked)
  193. {
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect("If 5 or less security, <Recovery +1(Deck)>. then -1k DP for each security card", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  197. activateClass.SetHashString("BT23_033_YT");
  198. cardEffects.Add(activateClass);
  199. string EffectDiscription()
  200. {
  201. return "[Your Turn] [Once Per Turn] When this Digimon gets linked, if you have 5 or fewer security cards, <Recovery +1 (Deck)>. Then to 1 of your opponent's Digimon, give -1000 DP until their turn ends for each of your security cards.";
  202. }
  203. bool CanUseCondition(Hashtable hashtable)
  204. {
  205. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  206. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  211. && CardEffectCommons.IsOwnerTurn(card);
  212. }
  213. bool PermanentCondition(Permanent permanent)
  214. {
  215. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  216. && permanent == card.PermanentOfThisCard();
  217. }
  218. bool CanSelectPermanentCondition(Permanent permanent)
  219. {
  220. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  221. }
  222. IEnumerator ActivateCoroutine(Hashtable hashtable)
  223. {
  224. if (card.Owner.SecurityCards.Count <= 5 && card.Owner.CanAddSecurity(activateClass))
  225. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  226. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  227. {
  228. int dpMinus = card.Owner.SecurityCards.Count * 1000;
  229. Permanent selectedPermament = null;
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  232. selectPermanentEffect.SetUp(
  233. selectPlayer: card.Owner,
  234. canTargetCondition: CanSelectPermanentCondition,
  235. canTargetCondition_ByPreSelecetedList: null,
  236. canEndSelectCondition: null,
  237. maxCount: maxCount,
  238. canNoSelect: false,
  239. canEndNotMax: false,
  240. selectPermanentCoroutine: SelectPermanentCoroutine,
  241. afterSelectPermanentCoroutine: null,
  242. mode: SelectPermanentEffect.Mode.Custom,
  243. cardEffect: activateClass);
  244. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  245. {
  246. selectedPermament = permanent;
  247. yield return null;
  248. }
  249. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will gain -{dpMinus} DP.", $"The opponent is selecting 1 Digimon that will gain -{dpMinus} DP.");
  250. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  251. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  252. targetPermanent: selectedPermament,
  253. changeValue: -dpMinus,
  254. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  255. activateClass: activateClass));
  256. }
  257. }
  258. }
  259. #endregion Your Turn - OPT
  260. #region When Linking - Link Effect
  261. if (timing == EffectTiming.WhenLinked)
  262. {
  263. ActivateClass activateClass = new ActivateClass();
  264. activateClass.SetUpICardEffect("Gain deck and hand bounce & De-Digivolve immunity", CanUseCondition, card);
  265. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  266. activateClass.SetIsLinkedEffect(true);
  267. cardEffects.Add(activateClass);
  268. string EffectDiscription()
  269. {
  270. return "[When Linking] Until your opponent's turn ends, their effects can't return this Digimon to hands or decks or affect it with <De-Digivolve> effects.";
  271. }
  272. bool CanUseCondition(Hashtable hashtable)
  273. {
  274. return CardEffectCommons.IsExistOnBattleArea(card)
  275. && CardEffectCommons.CanTriggerWhenLinking(hashtable, PermamentCondition, card);
  276. }
  277. bool CanActivateCondition(Hashtable hashtable)
  278. {
  279. return CardEffectCommons.IsExistOnBattleArea(card);
  280. }
  281. bool PermamentCondition(Permanent permanent)
  282. {
  283. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  284. && permanent.LinkedCards.Contains(card);
  285. }
  286. IEnumerator ActivateCoroutine(Hashtable hashtable)
  287. {
  288. Permanent thisPermament = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  289. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  290. targetPermanent: thisPermament,
  291. cardEffectCondition: null,
  292. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  293. activateClass: activateClass,
  294. effectName: "Cannot be returned to the deck"));
  295. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  296. targetPermanent: thisPermament,
  297. cardEffectCondition: null,
  298. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  299. activateClass: activateClass,
  300. effectName: "Cannot be returned to the hand"));
  301. bool CanUseImmunityCondition(Hashtable hashtable1)
  302. {
  303. return thisPermament.TopCard != null;
  304. }
  305. bool PermanentImmunityCondition(Permanent permanent)
  306. {
  307. return permanent == thisPermament;
  308. }
  309. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  310. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition, thisPermament.TopCard);
  311. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  312. thisPermament.UntilOpponentTurnEndEffects.Add(_ => immuneFromDeDigivolveClass);
  313. }
  314. }
  315. #endregion When Linking - Link Effect
  316. return cardEffects;
  317. }
  318. }
  319. }