BT24_007.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Tsunomon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_007 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnDiscardHand)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 Level 4 or higher [Demon]/[Titan] Digimon trashed from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  18. activateClass.SetHashString("BT24_007_YT");
  19. activateClass.SetIsInheritedEffect(true);
  20. cardEffects.Add(activateClass);
  21. string EffectDescription()
  22. {
  23. return "[Your Turn] [Once Per Turn] When level 4 or higher Digimon cards with the [Demon] or [Titan] trait are trashed from your hand, you may play 1 of them with the play cost reduced by 2.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  28. && CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, CardCondition)
  29. && CardEffectCommons.IsOwnerTurn(card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  34. }
  35. bool CardCondition(CardSource cardSource)
  36. {
  37. return cardSource.IsDigimon
  38. && cardSource.HasLevel && cardSource.Level >= 4
  39. && (cardSource.EqualsTraits("Demon") || cardSource.EqualsTraits("Titan"))
  40. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself-2);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. List<CardSource> trashedCards = CardEffectCommons.GetDiscardedCardsFromHashtable(hashtable).Filter(CardCondition);
  45. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, trashCard=> trashedCards.Contains(trashCard)))
  46. {
  47. CardSource selectedCard = null;
  48. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  49. int maxCount = Math.Min(1, trashedCards.Count);
  50. selectCardEffect.SetUp(
  51. canTargetCondition: CardCondition,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. canNoSelect: () => true,
  55. selectCardCoroutine: SelectCardCoroutine,
  56. afterSelectCardCoroutine: null,
  57. message: "Select 1 digimon to play.",
  58. maxCount: maxCount,
  59. canEndNotMax: false,
  60. isShowOpponent: true,
  61. mode: SelectCardEffect.Mode.Custom,
  62. root: SelectCardEffect.Root.Custom,
  63. customRootCardList: trashedCards,
  64. canLookReverseCard: true,
  65. selectPlayer: card.Owner,
  66. cardEffect: activateClass);
  67. IEnumerator SelectCardCoroutine(CardSource cardSource)
  68. {
  69. selectedCard = cardSource;
  70. yield return null;
  71. }
  72. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon card to play.");
  73. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  74. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  75. cardSources: new List<CardSource>() { selectedCard },
  76. activateClass: activateClass,
  77. payCost: true,
  78. isTapped: false,
  79. root: SelectCardEffect.Root.Trash,
  80. activateETB: true,
  81. fixedCost: selectedCard.GetCostItself - 2));
  82. }
  83. }
  84. }
  85. return cardEffects;
  86. }
  87. }
  88. }