ST24_01.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Koromon
  5. namespace DCGO.CardEffects.ST24
  6. {
  7. public class ST24_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 [DATA SQUAD] for 2 less", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  18. activateClass.SetIsInheritedEffect(true);
  19. activateClass.SetHashString("ST24_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 [DATA SQUAD] 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("DATA SQUAD");
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  39. && permanent.IsTamer
  40. && permanent.HasFaceDownDigivolutionCards;
  41. }
  42. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  43. {
  44. return cardSource.IsFlipped
  45. && !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. Permanent selectedPermanent = null;
  50. if (CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) > 1)
  51. {
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: CanSelectPermanentCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: 1,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: SelectPermanentCoroutine,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. 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.");
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  68. {
  69. selectedPermanent = permanent;
  70. yield return null;
  71. }
  72. }
  73. else selectedPermanent = card.Owner.GetBattleAreaPermanents().FirstOrDefault();
  74. List<CardSource> selectedCards = new List<CardSource>();
  75. CardSource trashTargetCard = selectedPermanent.DigivolutionCards.Filter(CanSelectTrashSourceCardCondition)[^1];
  76. selectedCards.Add(trashTargetCard);
  77. yield return ContinuousController.instance.StartCoroutine(
  78. new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  79. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  82. targetPermanent: card.PermanentOfThisCard(),
  83. cardCondition: CanSelectCardCondition,
  84. payCost: true,
  85. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  86. fixedCostTuple: null,
  87. ignoreDigivolutionRequirementFixedCost: -1,
  88. isHand: true,
  89. activateClass: activateClass,
  90. successProcess: null));
  91. }
  92. }
  93. }
  94. #endregion
  95. return cardEffects;
  96. }
  97. }
  98. }