BT25_052.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. // Logimon
  8. public class BT25_052 : 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.HasStandardAppTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, 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: 2, card: card));
  31. }
  32. #endregion
  33. #region App Fusion (Onmon & Gatchmon)
  34. if (timing == EffectTiming.None)
  35. {
  36. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Onmon", "Gatchmon" }, card));
  37. }
  38. #endregion
  39. #region Main
  40. if (timing == EffectTiming.OnDeclaration)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("Link for -1", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
  45. activateClass.SetHashString("BT25_052_Main");
  46. cardEffects.Add(activateClass);
  47. string EffectDescription()
  48. => "[Main] [Once Per 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 1.";
  49. bool CanUseCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleArea(card)
  52. && (CardEffectCommons.HasMatchConditionOwnersHand(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. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. #region Link Cost Reduction
  68. ICardEffect GetCardEffect(EffectTiming _timing)
  69. {
  70. if (_timing == EffectTiming.None)
  71. {
  72. return CardEffectFactory.GrantedReduceLinkCostClass(
  73. card: card,
  74. reducedCost: 1,
  75. cardSourceCondition: _ => true,
  76. permanentCondition: _ => true,
  77. rootCondition: _ => true
  78. );
  79. }
  80. return null;
  81. }
  82. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  83. #endregion
  84. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanLinkCardEffectCondition);
  85. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCardEffectCondition);
  86. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  87. if (canSelectHand)
  88. {
  89. selectionElements.Add(new SelectionElement<int>(message: $"From hand", value : 1, spriteIndex: 0));
  90. }
  91. if (canSelectSources)
  92. {
  93. selectionElements.Add(new SelectionElement<int>(message: $"From digivolution cards", value : 2, spriteIndex: 0));
  94. }
  95. selectionElements.Add(new SelectionElement<int>(message: $"Do not Link", value : 3, spriteIndex: 1));
  96. string selectPlayerMessage = "From which area will you link a card?";
  97. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  98. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  100. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  101. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  102. if (doLink)
  103. {
  104. if (fromHand)
  105. {
  106. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  107. selectHandEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanLinkCardEffectCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: 1,
  113. canNoSelect: true,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. selectCardCoroutine: SelectCardCoroutine,
  117. afterSelectCardCoroutine: null,
  118. mode: SelectHandEffect.Mode.Custom,
  119. cardEffect: activateClass);
  120. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  121. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  122. yield return StartCoroutine(selectHandEffect.Activate());
  123. }
  124. else
  125. {
  126. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  127. selectCardEffect.SetUp(
  128. canTargetCondition: CanLinkCardEffectCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. canNoSelect: () => true,
  132. selectCardCoroutine: SelectCardCoroutine,
  133. afterSelectCardCoroutine: null,
  134. message: "Select 1 card to add as source.",
  135. maxCount: 1,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. mode: SelectCardEffect.Mode.Custom,
  139. root: SelectCardEffect.Root.DigivolutionCards,
  140. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  141. canLookReverseCard: true,
  142. selectPlayer: card.Owner,
  143. cardEffect: activateClass);
  144. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  145. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  146. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  147. }
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, cardSource, card.PermanentOfThisCard(), activateClass).LinkCard());
  151. }
  152. }
  153. #region Remove Link Cost Reduction
  154. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  155. #endregion
  156. }
  157. }
  158. #endregion
  159. #region Your Turns
  160. if (timing == EffectTiming.WhenLinked)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("Play 1 [Kazuki & Itsuki]", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  165. activateClass.SetHashString("BT25_052_YT");
  166. cardEffects.Add(activateClass);
  167. string EffectDescription()
  168. => "[Your Turn] [Once Per Turn] When this Digimon get linked, if you have 1 or fewer Tamers, you may play 1 [Kazuki & Itsuki] from your hand without paying the cost.";
  169. bool PermanentCondition(Permanent permanent)
  170. {
  171. return permanent == card.PermanentOfThisCard();
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleArea(card)
  176. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  177. }
  178. bool CanActivateCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleArea(card)
  181. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  182. && CardEffectCommons.MatchConditionPermanentCount(IsTamerCondition) <= 1;
  183. }
  184. bool IsTamerCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card);
  185. bool CanSelectCardCondition(CardSource cardSource)
  186. {
  187. return cardSource.EqualsCardName("Kazuki & Itsuki")
  188. && cardSource.HasPlayCost
  189. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  194. selectHandEffect.SetUp(
  195. selectPlayer: card.Owner,
  196. canTargetCondition: CanSelectCardCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. maxCount: 1,
  200. canNoSelect: true,
  201. canEndNotMax: false,
  202. isShowOpponent: true,
  203. selectCardCoroutine: null,
  204. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  205. mode: SelectHandEffect.Mode.PlayForFree,
  206. cardEffect: activateClass);
  207. yield return StartCoroutine(selectHandEffect.Activate());
  208. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  209. {
  210. if (cardSources.Count == 0)
  211. activateClass.RemoveUse();
  212. yield return null;
  213. }
  214. }
  215. }
  216. #endregion
  217. #region Link
  218. if (timing == EffectTiming.OnDeclaration)
  219. {
  220. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  221. }
  222. #endregion
  223. #region When Linking
  224. if (timing == EffectTiming.WhenLinked)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Suspend 1 enemy Digimon or Tamers", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  229. activateClass.SetIsLinkedEffect(true);
  230. cardEffects.Add(activateClass);
  231. string EffectDiscription()
  232. {
  233. return "[When Linking] Suspend 1 of your opponent's Digimon or Tamers.";
  234. }
  235. bool CanSelectPermanentCondition(Permanent permanent)
  236. {
  237. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  238. && (permanent.IsDigimon || permanent.IsTamer);
  239. }
  240. bool CanUseCondition(Hashtable hashtable)
  241. {
  242. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  243. }
  244. bool CanActivateCondition(Hashtable hashtable)
  245. {
  246. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  247. }
  248. IEnumerator ActivateCoroutine(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  251. {
  252. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  253. selectPermanentEffect.SetUp(
  254. selectPlayer: card.Owner,
  255. canTargetCondition: CanSelectPermanentCondition,
  256. canTargetCondition_ByPreSelecetedList: null,
  257. canEndSelectCondition: null,
  258. maxCount: 1,
  259. canNoSelect: false,
  260. canEndNotMax: false,
  261. selectPermanentCoroutine: null,
  262. afterSelectPermanentCoroutine: null,
  263. mode: SelectPermanentEffect.Mode.Tap,
  264. cardEffect: activateClass);
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. }
  267. }
  268. }
  269. #endregion
  270. return cardEffects;
  271. }
  272. }
  273. }