BT25_082.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // BlackGatomon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_082 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasText("Three Musketeers")
  19. || permanent.TopCard.EqualsTraits("TS");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: Condition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP/WD
  25. string SharedEffectName = "Play a tamer with [Three Musketeers] in text from hand for free";
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. additionalActivateCondition: AdditionalActivateCondition,
  32. optional: false,
  33. onPlay: true,
  34. whenDigivolving: true);
  35. string SharedEffectDescription(string tag) => $"[{tag}] If you have 1 or fewer Tamers, you may play 1 Tamer card with [Three Musketeers] in its text from your hand without paying the cost.";
  36. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  37. {
  38. return CardEffectCommons.HasMatchConditionOwnersHand(card, TraitedTamer)
  39. && card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  40. }
  41. bool TraitedTamer(CardSource cardSource)
  42. {
  43. return cardSource.IsTamer
  44. && cardSource.HasText("Three Musketeers");
  45. }
  46. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  47. {
  48. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  49. canTargetCondition: TraitedTamer,
  50. SelectCardEffect.Root.Hand,
  51. activateClass,
  52. payCost: false
  53. ));
  54. }
  55. #endregion
  56. #region All Turns
  57. if (timing == EffectTiming.None)
  58. {
  59. bool Condition()
  60. {
  61. return CardEffectCommons.IsExistOnBattleArea(card)
  62. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TraitedTamerPermanent);
  63. }
  64. bool TraitedTamerPermanent(Permanent permanent)
  65. {
  66. return permanent.IsTamer
  67. && permanent.TopCard.HasText("Three Musketeers");
  68. }
  69. bool PermanentCondition(Permanent targetPermanent)
  70. {
  71. return targetPermanent == card.PermanentOfThisCard();
  72. }
  73. bool CardCondition(CardSource cardSource)
  74. {
  75. return cardSource.IsDigimon
  76. && cardSource.EqualsTraits("Three Musketeers");
  77. }
  78. string effectName = $"Can digivolve to [Three Musketeers] trait";
  79. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: true, card: card, condition: Condition, effectName: effectName, cardCondition: CardCondition));
  80. }
  81. #endregion
  82. #region Inherited When Attacking
  83. if (timing == EffectTiming.OnAllyAttack)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Place 1 card to digivolution cards to Draw 1", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  88. activateClass.SetIsInheritedEffect(true);
  89. activateClass.SetHashString("BT25_082_Inherited");
  90. cardEffects.Add(activateClass);
  91. string EffectDescription() => "[When Attacking] [Once Per Turn] By placing 1 [Three Musketeers] trait card from your hand or trash as this Digimon's bottom digivolution card, <Draw 1>.";
  92. bool CanSelectCardCondition(CardSource cardSource)
  93. {
  94. return cardSource.EqualsTraits("Three Musketeers");
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  99. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleArea(card)
  104. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  105. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition));
  106. }
  107. IEnumerator ActivateCoroutine(Hashtable hashtable)
  108. {
  109. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  110. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  111. if (canSelectHand || canSelectTrash)
  112. {
  113. if (canSelectHand && canSelectTrash)
  114. {
  115. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  116. {
  117. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  118. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  119. };
  120. string selectPlayerMessage = "From which area do you select a card?";
  121. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  122. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  123. }
  124. else
  125. {
  126. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  127. }
  128. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  129. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  130. List<CardSource> selectedCards = new List<CardSource>();
  131. IEnumerator SelectCardCoroutine(CardSource cardSource)
  132. {
  133. selectedCards.Add(cardSource);
  134. yield return null;
  135. }
  136. if (fromHand)
  137. {
  138. int maxCount = 1;
  139. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  140. selectHandEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectCardCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount,
  146. canNoSelect: false,
  147. canEndNotMax: false,
  148. isShowOpponent: true,
  149. selectCardCoroutine: SelectCardCoroutine,
  150. afterSelectCardCoroutine: null,
  151. mode: SelectHandEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  154. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  155. yield return StartCoroutine(selectHandEffect.Activate());
  156. }
  157. else
  158. {
  159. int maxCount = 1;
  160. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  161. selectCardEffect.SetUp(
  162. canTargetCondition: CanSelectCardCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. canNoSelect: () => false,
  166. selectCardCoroutine: SelectCardCoroutine,
  167. afterSelectCardCoroutine: null,
  168. message: "Select 1 card to place on bottom of digivolution cards.",
  169. maxCount: maxCount,
  170. canEndNotMax: false,
  171. isShowOpponent: true,
  172. mode: SelectCardEffect.Mode.Custom,
  173. root: SelectCardEffect.Root.Trash,
  174. customRootCardList: null,
  175. canLookReverseCard: true,
  176. selectPlayer: card.Owner,
  177. cardEffect: activateClass);
  178. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  179. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  180. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  181. }
  182. if (selectedCards.Count >= 1)
  183. {
  184. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  185. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  186. }
  187. }
  188. }
  189. }
  190. #endregion
  191. return cardEffects;
  192. }
  193. }
  194. }