BT25_056.cs 15 KB

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