BT25_092.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Asuna Shiroki
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_092 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Shared Condition
  14. bool Valid3MOrTSCard(CardSource cardSource)
  15. {
  16. return cardSource.HasText("Three Musketeers")
  17. || cardSource.HasTSTraits;
  18. }
  19. #endregion
  20. #region Start of your Main Phase
  21. if(timing == EffectTiming.OnStartMainPhase)
  22. {
  23. cardEffects.Add(CardEffectFactory.StartOfYourMainPhaseClass(
  24. card,
  25. "By trashing a [Three Musketeers] in test or [TS] trait card form hand, <Draw 1> and gain 1 memory",
  26. ActivateCoroutine,
  27. EffectDescription(),
  28. additionalActivateCondition: AdditionalActivateCondition,
  29. optional: false,
  30. isSkippable: true
  31. ));
  32. string EffectDescription() => "[Start of Your Main Phase] By trashing 1 card with [Three Musketeers] in its text or [TS] trait from your hand, <Draw 1> and gain 1 memory.";
  33. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass) => CardEffectCommons.HasMatchConditionOwnersHand(card, Valid3MOrTSCard);
  34. IEnumerator ActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  35. {
  36. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  37. selectHandEffect.SetUp(
  38. selectPlayer: card.Owner,
  39. canTargetCondition: Valid3MOrTSCard,
  40. canTargetCondition_ByPreSelecetedList: null,
  41. canEndSelectCondition: null,
  42. maxCount: 1,
  43. canNoSelect: true,
  44. canEndNotMax: false,
  45. isShowOpponent: true,
  46. selectCardCoroutine: null,
  47. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  48. mode: SelectHandEffect.Mode.Discard,
  49. cardEffect: activateClass);
  50. yield return StartCoroutine(selectHandEffect.Activate());
  51. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  52. {
  53. if (cardSources.Count >= 1)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  56. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  57. }
  58. }
  59. }
  60. }
  61. #endregion
  62. #region Main
  63. if (timing == EffectTiming.OnDeclaration)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect("Suspend and trash an option from hand or sources to digivolve into [Three Musketeers]/[TS] Digimon for 1 less", CanUseCondition, card);
  67. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  68. cardEffects.Add(activateClass);
  69. string EffectDescription()
  70. => "[Main] By suspending this Tamer and trashing 1 Option card from your hand or your Digimon's digivolution cards, 1 of your Digimon may digivolve into a Digimon card with [Three Musketeers] in its text or the [TS] trait in the hand or trash with the cost reduced by 1.";
  71. bool ValidTrashCard(CardSource cardSource) => cardSource.IsOption;
  72. bool PermanentCondition(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  75. && permanent.DigivolutionCards.Any(ValidTrashCard);
  76. }
  77. bool CanDigivolveDigimon(Permanent permanent)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  80. && (CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Hand, permanent))
  81. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Trash, permanent)));
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.CanActivateSuspendCostEffect(card)
  86. && (CardEffectCommons.HasMatchConditionOwnersHand(card, ValidTrashCard)
  87. || CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition));
  88. }
  89. bool ValidTarget(CardSource cardSource, SelectCardEffect.Root root, Permanent permanent)
  90. {
  91. return Valid3MOrTSCard(cardSource)
  92. && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root);
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable hashtable)
  95. {
  96. #region Pay costs
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
  98. new List<Permanent>() { card.PermanentOfThisCard() },
  99. activateClass,
  100. SuccessProcess,
  101. null));
  102. IEnumerator SuccessProcess(List<Permanent> suspendedPermaments)
  103. {
  104. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, ValidTrashCard);
  105. bool validDigivolutionCard = CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition);
  106. if (validHandCard && validDigivolutionCard)
  107. {
  108. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  109. {
  110. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  111. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  112. };
  113. string selectPlayerMessage1 = "From which area will you trash an option?";
  114. string notSelectPlayerMessage1 = "The opponent is choosing from which area to trash a card.";
  115. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  116. }
  117. else
  118. {
  119. GManager.instance.userSelectionManager.SetBool(validHandCard);
  120. }
  121. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  122. var fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  123. if (fromHand)
  124. {
  125. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  126. selectHandEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: ValidTrashCard,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: 1,
  132. canNoSelect: false,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. selectCardCoroutine: null,
  136. afterSelectCardCoroutine: null,
  137. mode: SelectHandEffect.Mode.Discard,
  138. cardEffect: activateClass);
  139. yield return StartCoroutine(selectHandEffect.Activate());
  140. }
  141. else
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  144. permanentCondition: PermanentCondition,
  145. cardCondition: ValidTrashCard,
  146. maxCount: 1,
  147. canNoTrash: false,
  148. isFromOnly1Permanent: true,
  149. activateClass: activateClass
  150. ));
  151. }
  152. #endregion
  153. #region Digivolve
  154. if(CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanDigivolveDigimon))
  155. {
  156. Permanent selectedPermanent = null;
  157. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  158. selectPermanentEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: CanDigivolveDigimon,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. maxCount: 1,
  164. canNoSelect: true,
  165. canEndNotMax: false,
  166. selectPermanentCoroutine: SelectPermanentCoroutine,
  167. afterSelectPermanentCoroutine: null,
  168. mode: SelectPermanentEffect.Mode.Custom,
  169. cardEffect: activateClass);
  170. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to Digivolve", "The opponent is selecting 1 Digimon to return to digivolve");
  171. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  172. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  173. {
  174. selectedPermanent = permanent;
  175. yield return null;
  176. }
  177. if (selectedPermanent != null)
  178. {
  179. bool ValidCardInHand = card.Owner.HandCards.Any(cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Hand, selectedPermanent));
  180. bool ValidCardInTrash = card.Owner.TrashCards.Any(cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Trash, selectedPermanent));
  181. if (ValidCardInHand && ValidCardInTrash)
  182. {
  183. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  184. {
  185. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  186. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  187. };
  188. string selectPlayerMessage1 = "From which area do you select a card?";
  189. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  190. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  191. }
  192. else
  193. {
  194. GManager.instance.userSelectionManager.SetBool(ValidCardInHand);
  195. }
  196. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  197. var fromHand1 = GManager.instance.userSelectionManager.SelectedBoolValue;
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  199. selectedPermanent,
  200. Valid3MOrTSCard,
  201. payCost: true,
  202. reduceCostTuple: (1, null),
  203. fixedCostTuple: null,
  204. ignoreDigivolutionRequirementFixedCost: -1,
  205. isHand: fromHand1,
  206. activateClass,
  207. successProcess: null
  208. ));
  209. #endregion
  210. }
  211. }
  212. }
  213. }
  214. }
  215. #endregion
  216. #region Security
  217. if (timing == EffectTiming.SecuritySkill)
  218. {
  219. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }