BT25_073.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Dragomon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_073 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("TS");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Jamming
  24. if (timing == EffectTiming.None)
  25. {
  26. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Shared OP / WD
  30. string SharedEffectName = "By trashing 1 linked card, may play/use 1 [TS] card with play/use cost of 5 or less from hand for free.";
  31. CardEffectFactory.ActivateClassesForSharedEffects
  32. (ref cardEffects, timing, card,
  33. SharedEffectName,
  34. SharedActivateCoroutine,
  35. SharedEffectDescription,
  36. additionalActivateCondition: HasMatchingPermanent,
  37. optional: false,
  38. onPlay: true,
  39. whenDigivolving: true);
  40. string SharedEffectDescription(string tag) => $"[{tag}] By trashing 1 of your Digimon's link cards, you may play or use 1 [TS] trait card with a play or use cost of 5 or less from your hand without paying the cost.";
  41. bool HasMatchingPermanent(Hashtable hashtable, ActivateClass activateClass)
  42. {
  43. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  48. && !permanent.HasNoLinkCards;
  49. }
  50. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  51. {
  52. Permanent selectedPermanent = null;
  53. CardSource selectedCard = null;
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 1,
  61. canNoSelect: true,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: SelectedPermanentCoroutine,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to trash linked card from.", "The opponent is selecting 1 Digimon to trash linked card from.");
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. IEnumerator SelectedPermanentCoroutine(Permanent permanent)
  70. {
  71. selectedPermanent = permanent;
  72. yield return null;
  73. }
  74. if (selectedPermanent != null)
  75. {
  76. int maxCount = Math.Min(1, selectedPermanent.LinkedCards.Count);
  77. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  78. selectCardEffect.SetUp(
  79. canTargetCondition: _ => true,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. canNoSelect: () => true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. message: "Select 1 linked card to trash.",
  86. maxCount: maxCount,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. mode: SelectCardEffect.Mode.Custom,
  90. root: SelectCardEffect.Root.LinkedCards,
  91. customRootCardList: selectedPermanent.LinkedCards,
  92. canLookReverseCard: true,
  93. selectPlayer: card.Owner,
  94. cardEffect: activateClass);
  95. IEnumerator SelectCardCoroutine(CardSource cardSource)
  96. {
  97. selectedCard = cardSource;
  98. yield return null;
  99. }
  100. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  101. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  102. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  103. targetPermanent: selectedPermanent,
  104. targetLinkCards: new List<CardSource>() { selectedCard },
  105. activateClass: activateClass,
  106. successProcess: SuccessProcess,
  107. failureProcess: null));
  108. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  109. {
  110. bool CanSelectCardCondition(CardSource cardSource)
  111. {
  112. return cardSource.EqualsTraits("TS")
  113. && cardSource.GetCostItself <= 5
  114. && ((cardSource.IsOption
  115. && !cardSource.CanNotPlayThisOption)
  116. || (cardSource.HasPlayCost
  117. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass)));
  118. }
  119. CardSource selectCard = null;
  120. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  121. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  122. selectHandEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectCardCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: true,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. mode: SelectHandEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  136. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  137. IEnumerator SelectCardCoroutine(CardSource cardSource)
  138. {
  139. selectCard = cardSource;
  140. yield return null;
  141. }
  142. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  143. if (selectCard != null)
  144. {
  145. if (selectCard.IsOption)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  148. cardSources: new List<CardSource>() { selectCard },
  149. activateClass: activateClass,
  150. payCost: false,
  151. root: SelectCardEffect.Root.Hand));
  152. }
  153. else
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  156. new List<CardSource>() { selectCard },
  157. activateClass: activateClass,
  158. payCost: false,
  159. isTapped: false,
  160. root: SelectCardEffect.Root.Hand,
  161. activateETB: true));
  162. }
  163. }
  164. }
  165. }
  166. }
  167. #endregion
  168. #region All Turns
  169. if (timing == EffectTiming.WhenRemoveField)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Trash 1 linked card to not leave", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  174. activateClass.SetIsInheritedEffect(true);
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[All Turns] When this Digimon would leave the battle area, by trashing 1 of its link cards, it doesn't leave.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  183. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  188. && !card.PermanentOfThisCard().HasNoLinkCards;
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. Permanent thisPermanent = card.PermanentOfThisCard();
  193. bool trashed = false;
  194. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  195. selectCardEffect.SetUp(
  196. canTargetCondition: _=> true,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. canNoSelect: () => true,
  200. selectCardCoroutine: null,
  201. afterSelectCardCoroutine: SelectCardCoroutine,
  202. message: "Select 1 link card to trash.",
  203. maxCount: 1,
  204. canEndNotMax: false,
  205. isShowOpponent: true,
  206. mode: SelectCardEffect.Mode.Discard,
  207. root: SelectCardEffect.Root.LinkedCards,
  208. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  209. canLookReverseCard: true,
  210. selectPlayer: card.Owner,
  211. cardEffect: activateClass);
  212. selectCardEffect.SetUpCustomMessage("Select 1 link card to trash.", "The opponent is selecting 1 link card to trash.");
  213. yield return StartCoroutine(selectCardEffect.Activate());
  214. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  215. {
  216. if (cardSources.Count > 0)
  217. trashed = true;
  218. yield return null;
  219. }
  220. if (trashed)
  221. {
  222. thisPermanent.willBeRemoveField = false;
  223. thisPermanent.HideHandBounceEffect();
  224. thisPermanent.HideDeckBounceEffect();
  225. thisPermanent.HideWillRemoveFieldEffect();
  226. thisPermanent.HideDeleteEffect();
  227. }
  228. }
  229. }
  230. #endregion
  231. return cardEffects;
  232. }
  233. }
  234. }