BT24_045.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // Ogremon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_045 : 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_045";
  53. }
  54. string SharedEffectName()
  55. {
  56. return "Trash a card to stun an opponent's digimon.";
  57. }
  58. string SharedEffectDescription(string tag)
  59. {
  60. return $"[{tag}] [Once Per Turn] By trashing 1 card in your hand, suspend 1 of your opponent's Digimon. It can't unsuspend in their next Unsuspend Phase.";
  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.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  76. }
  77. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  78. {
  79. if (card.Owner.HandCards.Count >= 1)
  80. {
  81. bool discarded = false;
  82. int discardCount = 1;
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: (cardSource) => true,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: discardCount,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. selectCardCoroutine: null,
  94. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  95. mode: SelectHandEffect.Mode.Discard,
  96. cardEffect: activateClass);
  97. selectHandEffect.SetUpCustomMessage("Select 1 Card to trash.", "The opponent is selecting 1 card to trash from their hand.");
  98. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  99. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  100. {
  101. if (cardSources.Count >= 1)
  102. {
  103. discarded = true;
  104. yield return null;
  105. }
  106. }
  107. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  108. {
  109. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  110. selectPermanentEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectPermanentCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: 1,
  116. canNoSelect: false,
  117. canEndNotMax: false,
  118. selectPermanentCoroutine: null,
  119. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  120. mode: SelectPermanentEffect.Mode.Tap,
  121. cardEffect: activateClass);
  122. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  123. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  124. {
  125. foreach (Permanent selectedPermanent in permanents)
  126. {
  127. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  128. {
  129. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendNextActivePhase(
  130. targetPermanent: selectedPermanent,
  131. activateClass: activateClass
  132. ));
  133. }
  134. }
  135. yield return null;
  136. }
  137. }
  138. }
  139. }
  140. #endregion
  141. #region On Play
  142. if (timing == EffectTiming.OnEnterFieldAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  146. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("On Play"));
  147. activateClass.SetHashString(SharedHash());
  148. cardEffects.Add(activateClass);
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  152. }
  153. }
  154. #endregion
  155. #region When Attacking
  156. if (timing == EffectTiming.OnAllyAttack)
  157. {
  158. ActivateClass activateClass = new ActivateClass();
  159. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  160. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  161. activateClass.SetHashString(SharedHash());
  162. cardEffects.Add(activateClass);
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  166. }
  167. }
  168. #endregion
  169. #region ESS
  170. if (timing == EffectTiming.OnDiscardHand)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("When your hand is trashed from, digivolve", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  175. activateClass.SetIsInheritedEffect(true);
  176. activateClass.SetHashString("BT24_045_YT_ESS");
  177. cardEffects.Add(activateClass);
  178. string EffectDescription()
  179. {
  180. 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.";
  181. }
  182. bool CanSelectCardCondition(CardSource cardSource)
  183. {
  184. return cardSource.IsDigimon &&
  185. (cardSource.EqualsCardName("Titamon") || cardSource.EqualsTraits("Titan")) &&
  186. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame,
  187. false,
  188. activateClass);
  189. }
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  193. && CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, cardSource => cardSource.Owner == card.Owner)
  194. && CardEffectCommons.IsOwnerTurn(card);
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  199. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)
  200. && (card.PermanentOfThisCard().TopCard.EqualsTraits("Demon")
  201. || card.PermanentOfThisCard().TopCard.EqualsTraits("Titan"));
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  204. {
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  206. targetPermanent: card.PermanentOfThisCard(),
  207. cardCondition: CanSelectCardCondition,
  208. payCost: true,
  209. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  210. fixedCostTuple: null,
  211. ignoreDigivolutionRequirementFixedCost: -1,
  212. isHand: false,
  213. activateClass: activateClass,
  214. successProcess: null));
  215. }
  216. }
  217. #endregion
  218. return cardEffects;
  219. }
  220. }
  221. }