BT25_072.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. // Shutmon
  8. public class BT25_072 : 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.HasSuperAppTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Link Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. static bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.HasAppmonTraits;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  31. }
  32. #endregion
  33. #region App Fusion (Logamon & Timemon)
  34. if (timing == EffectTiming.None)
  35. {
  36. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Logamon", "Timemon" }, card));
  37. }
  38. #endregion
  39. #region Jamming
  40. if (timing == EffectTiming.None)
  41. {
  42. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  43. }
  44. #endregion
  45. #region Shared OP / WD / WA
  46. string SharedEffectName = "Link from trash or digivolution cards to this for -2";
  47. string SharedEffectDescription(string tag)
  48. => $"[{tag}] If it's your turn, you may link 1 [Social], [Tool] or [Game] trait Digimon card from your trash or this Digimon's digivolution cards to this Digimon with the cost reduced by 2.";
  49. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  50. {
  51. return CardEffectCommons.IsOwnerTurn(card)
  52. && (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCardActivateCondition)
  53. || card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCardActivateCondition));
  54. }
  55. bool CanLinkCardActivateCondition(CardSource cardSource) => CanLinkCardCondition(cardSource, false);
  56. bool CanLinkCardEffectCondition(CardSource cardSource) => CanLinkCardCondition(cardSource, true);
  57. bool CanLinkCardCondition(CardSource cardSource, bool payCost)
  58. {
  59. return cardSource.IsDigimon
  60. && (cardSource.EqualsTraits("Social")
  61. || cardSource.EqualsTraits("Tool")
  62. || cardSource.EqualsTraits("Game"))
  63. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), payCost);
  64. }
  65. CardEffectFactory.ActivateClassesForSharedEffects
  66. (ref cardEffects, timing, card,
  67. SharedEffectName,
  68. SharedActivateCoroutine,
  69. SharedEffectDescription,
  70. additionalActivateCondition: AdditionalActivateCondition,
  71. optional: false,
  72. isSkippable: true,
  73. onPlay: true,
  74. whenDigivolving: true,
  75. whenAttacking: true);
  76. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  77. {
  78. #region Link Cost Reduction
  79. ICardEffect GetCardEffect(EffectTiming _timing)
  80. {
  81. if (_timing == EffectTiming.None)
  82. {
  83. return CardEffectFactory.GrantedReduceLinkCostClass(
  84. card: card,
  85. reducedCost: 2,
  86. cardSourceCondition: _ => true,
  87. permanentCondition: _ => true,
  88. rootCondition: _ => true
  89. );
  90. }
  91. return null;
  92. }
  93. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  94. #endregion
  95. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCardEffectCondition);
  96. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCardEffectCondition);
  97. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  98. if (canSelectTrash)
  99. {
  100. selectionElements.Add(new SelectionElement<int>(message: $"From trash", value : 1, spriteIndex: 0));
  101. }
  102. if (canSelectSources)
  103. {
  104. selectionElements.Add(new SelectionElement<int>(message: $"From digivolution cards", value : 2, spriteIndex: 0));
  105. }
  106. selectionElements.Add(new SelectionElement<int>(message: $"Do not Link", value : 3, spriteIndex: 1));
  107. string selectPlayerMessage = "From which area will you link a card?";
  108. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  109. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  110. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  111. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  112. bool fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  113. if (doLink)
  114. {
  115. if (fromTrash)
  116. {
  117. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  118. selectCardEffect.SetUp(
  119. canTargetCondition: CanLinkCardEffectCondition,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. canNoSelect: () => true,
  123. selectCardCoroutine: SelectCardCoroutine,
  124. afterSelectCardCoroutine: null,
  125. message: "Select 1 card to add as source.",
  126. maxCount: 1,
  127. canEndNotMax: false,
  128. isShowOpponent: true,
  129. mode: SelectCardEffect.Mode.Custom,
  130. root: SelectCardEffect.Root.Trash,
  131. customRootCardList: null,
  132. canLookReverseCard: true,
  133. selectPlayer: card.Owner,
  134. cardEffect: activateClass);
  135. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  136. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  137. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  138. }
  139. else
  140. {
  141. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  142. selectCardEffect.SetUp(
  143. canTargetCondition: CanLinkCardEffectCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. canNoSelect: () => true,
  147. selectCardCoroutine: SelectCardCoroutine,
  148. afterSelectCardCoroutine: null,
  149. message: "Select 1 card to add as source.",
  150. maxCount: 1,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. mode: SelectCardEffect.Mode.Custom,
  154. root: SelectCardEffect.Root.DigivolutionCards,
  155. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  156. canLookReverseCard: true,
  157. selectPlayer: card.Owner,
  158. cardEffect: activateClass);
  159. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  160. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  161. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  162. }
  163. IEnumerator SelectCardCoroutine(CardSource cardSource)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, cardSource, card.PermanentOfThisCard(), activateClass).LinkCard());
  166. }
  167. }
  168. #region Remove Link Cost Reduction
  169. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  170. #endregion
  171. }
  172. #endregion
  173. #region All Turns
  174. if (timing == EffectTiming.WhenLinked)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect("1 enemy digimon or Tamer cannot digivolve until their turn ends", CanUseCondition, card);
  178. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  179. activateClass.SetHashString("BT25_072_AT");
  180. cardEffects.Add(activateClass);
  181. string EffectDescription()
  182. {
  183. return "[All Turns] [Once Per Turn] When this Digimon gets linked, 1 of your opponent's Digimon or Tamers can't digivolve until their turn ends.";
  184. }
  185. bool PermanentCondition(Permanent permanent)
  186. {
  187. return permanent == card.PermanentOfThisCard();
  188. }
  189. bool IsOpponentsPermanent(Permanent permanent)
  190. {
  191. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  192. && (permanent.IsDigimon
  193. || permanent.IsTamer);
  194. }
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleArea(card)
  198. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  199. }
  200. bool CanActivateCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsExistOnBattleArea(card);
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable hashtable)
  205. {
  206. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsPermanent))
  207. {
  208. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  209. selectPermanentEffect.SetUp(
  210. selectPlayer: card.Owner,
  211. canTargetCondition: IsOpponentsPermanent,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. maxCount: 1,
  215. canNoSelect: false,
  216. canEndNotMax: false,
  217. selectPermanentCoroutine: SelectPermanentCoroutine,
  218. afterSelectPermanentCoroutine: null,
  219. mode: SelectPermanentEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  222. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  223. {
  224. bool PermanentCondition(Permanent otherPermanent) => otherPermanent == permanent;
  225. CanNotDigivolveClass canNotEvolveClass = CardEffectFactory.CanNotDigivolveStaticEffect(
  226. permanentCondition: PermanentCondition,
  227. cardCondition: (cardSource) => true,
  228. isInheritedEffect: false,
  229. card: card,
  230. condition: () => true,
  231. effectName: "Can't digivolve");
  232. CardEffectCommons.AddEffectToPermanent(
  233. targetPermanent: permanent,
  234. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  235. card: card,
  236. cardEffect: canNotEvolveClass,
  237. timing: EffectTiming.None);
  238. yield return null;
  239. }
  240. }
  241. }
  242. }
  243. #endregion
  244. #region Link
  245. if (timing == EffectTiming.OnDeclaration)
  246. {
  247. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  248. }
  249. #endregion
  250. #region When Linking
  251. if (timing == EffectTiming.WhenLinked)
  252. {
  253. ActivateClass activateClass = new ActivateClass();
  254. activateClass.SetUpICardEffect("2 enemy Digimon or Tamers can't unsuspend until their turn ends", CanUseCondition, card);
  255. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  256. activateClass.SetIsLinkedEffect(true);
  257. cardEffects.Add(activateClass);
  258. string EffectDescription()
  259. {
  260. return "[When Linking] 2 of your opponent's Digimon or Tamers can't unsuspend until their turn ends.";
  261. }
  262. bool CanSelectPermanentCondition(Permanent permanent)
  263. {
  264. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  265. && (permanent.IsDigimon || permanent.IsTamer);
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  270. }
  271. bool CanActivateCondition(Hashtable hashtable)
  272. {
  273. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  274. }
  275. IEnumerator ActivateCoroutine(Hashtable hashtable)
  276. {
  277. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  278. {
  279. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  280. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  281. selectPermanentEffect.SetUp(
  282. selectPlayer: card.Owner,
  283. canTargetCondition: CanSelectPermanentCondition,
  284. canTargetCondition_ByPreSelecetedList: null,
  285. canEndSelectCondition: null,
  286. maxCount: maxCount,
  287. canNoSelect: false,
  288. canEndNotMax: false,
  289. selectPermanentCoroutine: SelectPermanentCoroutine,
  290. afterSelectPermanentCoroutine: null,
  291. mode: SelectPermanentEffect.Mode.Custom,
  292. cardEffect: activateClass);
  293. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  294. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  295. {
  296. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  297. targetPermanent: permanent,
  298. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  299. activateClass: activateClass,
  300. condition: null,
  301. effectName: "Can't unsuspend"
  302. ));
  303. }
  304. }
  305. }
  306. }
  307. #endregion
  308. return cardEffects;
  309. }
  310. }
  311. }