BT25_075.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Vulcanusmon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_075 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.EqualsTraits("TS");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  21. }
  22. #endregion
  23. #region Reduce Play Cost
  24. if (timing == EffectTiming.None)
  25. {
  26. bool Condition()
  27. {
  28. return card.Owner.GetBattleAreaDigimons().Count < card.Owner.Enemy.GetBattleAreaDigimons().Count;
  29. }
  30. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  31. }
  32. #endregion
  33. #region Shared OP / WD
  34. string SharedEffectName = "May link up to 2 cards from hand/trash to your digimon for free. Then <De-Digivolve 1> all enemy Digimon per your link card";
  35. string SharedEffectDescription(string tag)
  36. => $"[{tag}] You may link up to 2 cards from your hand or trash to any of your Digimon without paying the cost. Then, for each of your link cards, <De-Digivolve 1> all of your opponent's Digimon.";
  37. bool CanLinkCardCondition(CardSource cardSource) => cardSource.CanLink(false);
  38. CardEffectFactory.ActivateClassesForSharedEffects
  39. (ref cardEffects, timing, card,
  40. SharedEffectName,
  41. SharedActivateCoroutine,
  42. SharedEffectDescription,
  43. optional: false,
  44. whenDigivolving: true,
  45. onPlay: true);
  46. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  47. {
  48. #region Link 2 cards
  49. int toLink = Math.Min(2, card.Owner.HandCards.Count(CanLinkCardCondition)+card.Owner.TrashCards.Count(CanLinkCardCondition));
  50. while (toLink > 0)
  51. {
  52. int validHandCardCount = card.Owner.HandCards.Count(CanLinkCardCondition);
  53. int validTrashCardCount = card.Owner.TrashCards.Count(CanLinkCardCondition);
  54. if (validHandCardCount > 0 && validTrashCardCount > 0)
  55. {
  56. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  57. {
  58. new(message: "from Hand", value: 1, spriteIndex: 0),
  59. new(message: "from Trash", value: 2, spriteIndex: 0),
  60. new(message: "Do not link", value: 3, spriteIndex: 1)
  61. };
  62. GManager.instance.userSelectionManager.SetIntSelection(
  63. selectionElements: selectionElements,
  64. selectPlayer: card.Owner,
  65. selectPlayerMessage: "From which area will you link a card?",
  66. notSelectPlayerMessage: "The opponent is choosing from which area to link card.");
  67. }
  68. else
  69. {
  70. GManager.instance.userSelectionManager.SetInt(validHandCardCount > 0 ? 1 : 2);
  71. }
  72. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  73. if (GManager.instance.userSelectionManager.SelectedIntValue == 3)
  74. {
  75. break;
  76. }
  77. if (GManager.instance.userSelectionManager.SelectedIntValue == 1)
  78. {
  79. int maxCount = Math.Min(toLink, validHandCardCount);
  80. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  81. selectHandEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanLinkCardCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: true,
  88. canEndNotMax: true,
  89. isShowOpponent: true,
  90. selectCardCoroutine: null,
  91. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  92. mode: SelectHandEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. string messagePluralize = maxCount > 1 ? "Select one or more cards to link to 1 Digimon. You will be able to select a second link card and second Digimon target if you only select 1 card now." : "Select a card to link to 1 Digimon.";
  95. selectHandEffect.SetUpCustomMessage(
  96. messagePluralize,
  97. $"The opponent is selecting cards to link.");
  98. yield return StartCoroutine(selectHandEffect.Activate());
  99. }
  100. else
  101. {
  102. int maxCount = Math.Min(toLink, validTrashCardCount);
  103. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  104. selectCardEffect.SetUp(
  105. canTargetCondition: CanLinkCardCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. canNoSelect: () => true,
  109. selectCardCoroutine: null,
  110. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  111. message: "Select link card(s)",
  112. maxCount: maxCount,
  113. canEndNotMax: true,
  114. isShowOpponent: true,
  115. mode: SelectCardEffect.Mode.Custom,
  116. root: SelectCardEffect.Root.Trash,
  117. customRootCardList: null,
  118. canLookReverseCard: true,
  119. selectPlayer: card.Owner,
  120. cardEffect: activateClass);
  121. string messagePluralize = maxCount > 1 ? "Select one or more cards to link to 1 Digimon. You will be able to select a second link card and second Digimon target if you only select 1 card now." : "Select a card to link to 1 Digimon.";
  122. selectCardEffect.SetUpCustomMessage(
  123. messagePluralize,
  124. $"The opponent is selecting cards to link.");
  125. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  126. }
  127. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  128. {
  129. if (cardSources.Count == 0)
  130. {
  131. toLink = 0;
  132. }
  133. else
  134. {
  135. bool CanLinkPermanentCondition(Permanent permanent)
  136. {
  137. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  138. && cardSources.All(cardSource => cardSource.CanLinkToTargetPermanent(permanent, false));
  139. }
  140. if (CardEffectCommons.HasMatchConditionPermanent(CanLinkPermanentCondition))
  141. {
  142. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: CanLinkPermanentCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: 1,
  149. canNoSelect: true,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: SelectPermanentCoroutine,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. string choicePluralize = cardSources.Count > 1 ? "cards" : "card";
  156. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to link the chosen {choicePluralize}.", "The opponent is selecting 1 Digimon to link.");
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  159. {
  160. foreach (CardSource cardSource in cardSources)
  161. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(false, cardSource, permanent, activateClass).LinkCard());
  162. toLink -= cardSources.Count;
  163. }
  164. }
  165. else
  166. {
  167. List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
  168. {
  169. new(message: "Ok", value: 1, spriteIndex: 1)
  170. };
  171. GManager.instance.userSelectionManager.SetIntSelection(
  172. selectionElements: selectionElements1,
  173. selectPlayer: card.Owner,
  174. selectPlayerMessage: "The cards you chose do not have a valid digimon which could link both. Try choosing 1 at a time.",
  175. notSelectPlayerMessage: "The opponent is selecting cards to link.");
  176. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  177. }
  178. }
  179. }
  180. }
  181. #endregion
  182. #region De-Digivolve
  183. int degenerationCount = card.Owner.GetBattleAreaDigimons().Map(permanent => permanent.LinkedCards).Flat().Count();
  184. for (int i = 0; i < degenerationCount; i++)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(new IMassDegeneration(card.Owner.Enemy.GetBattleAreaDigimons(), 1, activateClass).Degeneration());
  187. }
  188. #endregion
  189. }
  190. #endregion
  191. #region All Turns
  192. if (timing == EffectTiming.None)
  193. {
  194. bool PermanentCondition(Permanent permanent)
  195. {
  196. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  197. && permanent.TopCard.HasTSTraits;
  198. }
  199. bool Condition() => CardEffectCommons.IsExistOnBattleArea(card);
  200. cardEffects.Add(CardEffectFactory.RushStaticEffect(PermanentCondition, false, card, Condition));
  201. cardEffects.Add(CardEffectFactory.ChangeLinkMaxStaticEffect(PermanentCondition, 1, false, card, Condition));
  202. }
  203. #endregion
  204. #region Your Turn
  205. if (timing == EffectTiming.WhenLinked)
  206. {
  207. ActivateClass activateClass = new ActivateClass();
  208. activateClass.SetUpICardEffect("Linked Digimon may Attack", CanUseCondition, card);
  209. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  210. activateClass.SetIsSkippable(true);
  211. activateClass.SetEffectTargets(TargetablePermanents);
  212. cardEffects.Add(activateClass);
  213. string EffectDescription() => "[Your Turn] When your Digimon get linked, one of them may attack.";
  214. bool CanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  215. bool CanUseCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass) &&
  216. CardEffectCommons.IsOwnerTurn(card) &&
  217. CardEffectCommons.CanTriggerWhenLinked(hashtable, CanSelectPermanentCondition, null);
  218. List<Permanent> TargetablePermanents(Hashtable hashtable) => CardEffectCommons.GetPermanentsFromHashtable(hashtable).Where(permanent => permanent.CanAttack(activateClass)).ToList();
  219. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  220. IEnumerator ActivateCoroutine(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  223. {
  224. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: null,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Attack,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage("Select 1 linked Digimon to attack.");
  239. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  240. }
  241. }
  242. }
  243. #endregion
  244. return cardEffects;
  245. }
  246. }
  247. }