ST23_01.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Kekkomon
  5. namespace DCGO.CardEffects.ST23
  6. {
  7. public class ST23_01 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Inherit
  13. if (timing == EffectTiming.OnAllyAttack)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Digivolve into [Glowing Dawn] for 2 less", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  18. activateClass.SetIsInheritedEffect(true);
  19. activateClass.SetHashString("ST23_01_WA");
  20. cardEffects.Add(activateClass);
  21. string EffectDescription() => "[When Attacking] [Once Per Turn] By trashing the bottom face-down card from under any of your Tamers, this Digimon may digivolve into a [Glowing Dawn] trait Digimon card in the hand with the cost reduced by 2.";
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  25. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  30. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition);
  31. }
  32. bool CanSelectCardCondition(CardSource cardSource)
  33. {
  34. return cardSource.EqualsTraits("Glowing Dawn");
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  39. && permanent.HasFaceDownDigivolutionCards;
  40. }
  41. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  42. {
  43. return cardSource.IsFlipped
  44. && !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. Permanent selectedPermanent = null;
  49. if (CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) > 1)
  50. {
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectPermanentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 tamer to trash a face down card from.", "The opponent is selecting 1 tamer to trash a face down card from.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. selectedPermanent = permanent;
  69. yield return null;
  70. }
  71. }
  72. else selectedPermanent = card.Owner.GetBattleAreaPermanents().FirstOrDefault(CanSelectPermanentCondition);
  73. List<CardSource> selectedCards = new List<CardSource>();
  74. CardSource trashTargetCard = selectedPermanent.DigivolutionCards.Filter(CanSelectTrashSourceCardCondition)[^1];
  75. selectedCards.Add(trashTargetCard);
  76. yield return ContinuousController.instance.StartCoroutine(
  77. new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  78. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  81. targetPermanent: card.PermanentOfThisCard(),
  82. cardCondition: CanSelectCardCondition,
  83. payCost: true,
  84. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  85. fixedCostTuple: null,
  86. ignoreDigivolutionRequirementFixedCost: -1,
  87. isHand: true,
  88. activateClass: activateClass,
  89. successProcess: null));
  90. }
  91. }
  92. }
  93. #endregion
  94. return cardEffects;
  95. }
  96. }
  97. }