BT25_070.cs 16 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. // Logamon
  8. public class BT25_070 : 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 (Offmon & Hackmon)
  34. if (timing == EffectTiming.None)
  35. {
  36. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Offmon", "Hackmon" }, 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. cardEffects.Add(activateClass);
  46. string EffectDescription()
  47. => "[Main] [Once Per 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 1.";
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleArea(card)
  51. && (CardEffectCommons.HasMatchConditionOwnersCardInTrash(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. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. #region Link Cost Reduction
  67. ICardEffect GetCardEffect(EffectTiming _timing)
  68. {
  69. if (_timing == EffectTiming.None)
  70. {
  71. return CardEffectFactory.GrantedReduceLinkCostClass(
  72. card: card,
  73. reducedCost: 1,
  74. cardSourceCondition: _ => true,
  75. permanentCondition: _ => true,
  76. rootCondition: _ => true
  77. );
  78. }
  79. return null;
  80. }
  81. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  82. #endregion
  83. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCardEffectCondition);
  84. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCardEffectCondition);
  85. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  86. if (canSelectTrash)
  87. {
  88. selectionElements.Add(new SelectionElement<int>(message: $"From trash", value : 1, spriteIndex: 0));
  89. }
  90. if (canSelectSources)
  91. {
  92. selectionElements.Add(new SelectionElement<int>(message: $"From digivolution cards", value : 2, spriteIndex: 0));
  93. }
  94. selectionElements.Add(new SelectionElement<int>(message: $"Do not Link", value : 3, spriteIndex: 1));
  95. string selectPlayerMessage = "From which area will you link a card?";
  96. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  97. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  100. bool fromTrash = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  101. if (doLink)
  102. {
  103. if (fromTrash)
  104. {
  105. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  106. selectCardEffect.SetUp(
  107. canTargetCondition: CanLinkCardEffectCondition,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. canNoSelect: () => true,
  111. selectCardCoroutine: SelectCardCoroutine,
  112. afterSelectCardCoroutine: null,
  113. message: "Select 1 card to add as source.",
  114. maxCount: 1,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. mode: SelectCardEffect.Mode.Custom,
  118. root: SelectCardEffect.Root.Trash,
  119. customRootCardList: null,
  120. canLookReverseCard: true,
  121. selectPlayer: card.Owner,
  122. cardEffect: activateClass);
  123. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  124. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  125. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  126. }
  127. else
  128. {
  129. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  130. selectCardEffect.SetUp(
  131. canTargetCondition: CanLinkCardEffectCondition,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. canNoSelect: () => true,
  135. selectCardCoroutine: SelectCardCoroutine,
  136. afterSelectCardCoroutine: null,
  137. message: "Select 1 card to add as source.",
  138. maxCount: 1,
  139. canEndNotMax: false,
  140. isShowOpponent: true,
  141. mode: SelectCardEffect.Mode.Custom,
  142. root: SelectCardEffect.Root.DigivolutionCards,
  143. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  144. canLookReverseCard: true,
  145. selectPlayer: card.Owner,
  146. cardEffect: activateClass);
  147. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  148. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  149. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  150. }
  151. IEnumerator SelectCardCoroutine(CardSource cardSource)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, cardSource, card.PermanentOfThisCard(), activateClass).LinkCard());
  154. }
  155. }
  156. #region Remove Link Cost Reduction
  157. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  158. #endregion
  159. }
  160. }
  161. #endregion
  162. #region Your Turns
  163. if (timing == EffectTiming.WhenLinked)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Delete 1 enemy 4 cost or less Digimon", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  168. activateClass.SetHashString("BT25_070_YT");
  169. cardEffects.Add(activateClass);
  170. string EffectDescription()
  171. => "[Your Turn] [Once Per Turn] When this Digimon gets linked, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  172. bool PermanentCondition(Permanent permanent)
  173. {
  174. return permanent == card.PermanentOfThisCard();
  175. }
  176. bool CanUseCondition(Hashtable hashtable)
  177. {
  178. return CardEffectCommons.IsExistOnBattleArea(card)
  179. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleArea(card);
  184. }
  185. bool CanSelectPermanentCondition(Permanent permanent)
  186. {
  187. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  188. && permanent.TopCard.HasPlayCost
  189. && permanent.TopCard.GetCostItself <= 4;
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  194. {
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: CanSelectPermanentCondition,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: 1,
  202. canNoSelect: false,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: null,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Destroy,
  207. cardEffect: activateClass);
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Link
  214. if (timing == EffectTiming.OnDeclaration)
  215. {
  216. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  217. }
  218. #endregion
  219. #region When Linking
  220. if (timing == EffectTiming.WhenLinked)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect("1 enemy Digimon or Tamers can't unsuspend until their turn ends", CanUseCondition, card);
  224. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  225. activateClass.SetIsLinkedEffect(true);
  226. cardEffects.Add(activateClass);
  227. string EffectDescription()
  228. {
  229. return "[When Linking] 1 of your opponent's Digimon or Tamers can't unsuspend until their turn ends.";
  230. }
  231. bool CanSelectPermanentCondition(Permanent permanent)
  232. {
  233. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  234. && (permanent.IsDigimon || permanent.IsTamer);
  235. }
  236. bool CanUseCondition(Hashtable hashtable)
  237. {
  238. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  239. }
  240. bool CanActivateCondition(Hashtable hashtable)
  241. {
  242. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  243. }
  244. IEnumerator ActivateCoroutine(Hashtable hashtable)
  245. {
  246. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  247. {
  248. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  249. selectPermanentEffect.SetUp(
  250. selectPlayer: card.Owner,
  251. canTargetCondition: CanSelectPermanentCondition,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. maxCount: 1,
  255. canNoSelect: false,
  256. canEndNotMax: false,
  257. selectPermanentCoroutine: SelectPermanentCoroutine,
  258. afterSelectPermanentCoroutine: null,
  259. mode: SelectPermanentEffect.Mode.Custom,
  260. cardEffect: activateClass);
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  262. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  263. {
  264. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  265. targetPermanent: permanent,
  266. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  267. activateClass: activateClass,
  268. condition: null,
  269. effectName: "Can't unsuspend"
  270. ));
  271. }
  272. }
  273. }
  274. }
  275. #endregion
  276. return cardEffects;
  277. }
  278. }
  279. }