BT24_013.cs 11 KB

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