BT24_026.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // Hyogamon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_026 : 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 Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 &&
  19. (targetPermanent.TopCard.EqualsTraits("Demon") || targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region When this card is trashed
  25. if (timing == EffectTiming.OnDiscardHand)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("If you have 5 or less cards, draw 1", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  30. cardEffects.Add(activateClass);
  31. string EffectDescription()
  32. {
  33. return "When this card is trashed from the hand, if you have 5 or fewer cards in hand, <Draw 1>.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnTrashSelfHand(hashtable, null, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnTrash(card) && card.Owner.HandCards.Count <= 5;
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  44. {
  45. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  46. }
  47. }
  48. #endregion
  49. #region Shared OP/WA
  50. string SharedHash()
  51. {
  52. return "OP_WA_BT24_026";
  53. }
  54. string SharedEffectName()
  55. {
  56. return "Trash a card to give one of your digimon Jamming and Blocker.";
  57. }
  58. string SharedEffectDescription(string tag)
  59. {
  60. return $"[{tag}] [Once Per Turn] By trashing 1 card in your hand, 1 of your digimon with the [Demon], [Shaman] or [Titan] trait gains <Jamming> and <Blocker> until your opponent's turn ends.";
  61. }
  62. bool SharedCanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (card.Owner.HandCards.Count >= 1)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanSelectPermanentCondition(Permanent permanent)
  74. {
  75. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  76. && (permanent.TopCard.EqualsTraits("Demon")
  77. || permanent.TopCard.EqualsTraits("Shaman")
  78. || permanent.TopCard.EqualsTraits("Titan"));
  79. }
  80. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  81. {
  82. if (card.Owner.HandCards.Count >= 1)
  83. {
  84. bool discarded = false;
  85. int discardCount = 1;
  86. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  87. selectHandEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: (cardSource) => true,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: discardCount,
  93. canNoSelect: true,
  94. canEndNotMax: false,
  95. isShowOpponent: true,
  96. selectCardCoroutine: null,
  97. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  98. mode: SelectHandEffect.Mode.Discard,
  99. cardEffect: activateClass);
  100. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  101. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  102. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  103. {
  104. if (cardSources.Count >= 1)
  105. {
  106. discarded = true;
  107. yield return null;
  108. }
  109. }
  110. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  111. {
  112. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  113. selectPermanentEffect.SetUp(
  114. selectPlayer: card.Owner,
  115. canTargetCondition: CanSelectPermanentCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. maxCount: 1,
  119. canNoSelect: false,
  120. canEndNotMax: false,
  121. selectPermanentCoroutine: SelectPermanentCoroutine,
  122. afterSelectPermanentCoroutine: null,
  123. mode: SelectPermanentEffect.Mode.Custom,
  124. cardEffect: activateClass);
  125. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain Jamming and Blocker.", "The opponent is selecting 1 Digimon that will gain Jamming and Blocker.");
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  128. {
  129. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainJamming(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  131. }
  132. }
  133. }
  134. }
  135. #endregion
  136. #region On Play
  137. if (timing == EffectTiming.OnEnterFieldAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  141. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("On Play"));
  142. activateClass.SetHashString(SharedHash());
  143. cardEffects.Add(activateClass);
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  147. }
  148. }
  149. #endregion
  150. #region When Attacking
  151. if (timing == EffectTiming.OnAllyAttack)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  155. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  156. activateClass.SetHashString(SharedHash());
  157. cardEffects.Add(activateClass);
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  161. }
  162. }
  163. #endregion
  164. #region ESS
  165. if (timing == EffectTiming.OnDiscardHand)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("When your hand is trashed from, digivolve", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  170. activateClass.SetIsInheritedEffect(true);
  171. activateClass.SetHashString("BT24_026_YT_ESS");
  172. cardEffects.Add(activateClass);
  173. string EffectDescription()
  174. {
  175. return "[Your Turn] [Once Per Turn] When your hand is trashed from, this [Demon] or [Titan] trait Digimon may digivolve into [Titamon] or a [Titan] trait Digimon card in the trash with the digivolution cost reduced by 1.";
  176. }
  177. bool CanSelectCardCondition(CardSource cardSource)
  178. {
  179. return cardSource.IsDigimon &&
  180. (cardSource.EqualsCardName("Titamon") || cardSource.EqualsTraits("Titan")) &&
  181. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame,
  182. false,
  183. activateClass);
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  188. && CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, cardSource => cardSource.Owner == card.Owner)
  189. && CardEffectCommons.IsOwnerTurn(card);
  190. }
  191. bool CanActivateCondition(Hashtable hashtable)
  192. {
  193. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  194. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)
  195. && (card.PermanentOfThisCard().TopCard.EqualsTraits("Demon")
  196. || card.PermanentOfThisCard().TopCard.EqualsTraits("Titan"));
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  201. targetPermanent: card.PermanentOfThisCard(),
  202. cardCondition: CanSelectCardCondition,
  203. payCost: true,
  204. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  205. fixedCostTuple: null,
  206. ignoreDigivolutionRequirementFixedCost: -1,
  207. isHand: false,
  208. activateClass: activateClass,
  209. successProcess: null));
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }