BT25_024.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Lekismon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_024 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Shared OP/WD
  23. string SharedEffectName = "<Draw 1>";
  24. CardEffectFactory.ActivateClassesForSharedEffects
  25. (ref cardEffects, timing, card,
  26. SharedEffectName,
  27. SharedActivateCoroutine,
  28. SharedEffectDescription,
  29. optional: false,
  30. onPlay: true,
  31. whenDigivolving: true);
  32. string SharedEffectDescription(string tag)
  33. {
  34. return $"[{tag}] <Draw 1>";
  35. }
  36. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  37. {
  38. yield return ContinuousController.instance.StartCoroutine(new DrawClass(
  39. player: card.Owner,
  40. drawCount: 1,
  41. cardEffect: activateClass).Draw()
  42. );
  43. }
  44. #endregion
  45. #region Your Turn
  46. if (timing == EffectTiming.OnEnterFieldAnyone)
  47. {
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect("Digivolve into [Crescemon] in trash for 1 less", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  51. activateClass.SetIsSkippable(true);
  52. cardEffects.Add(activateClass);
  53. string EffectDescription() => "[Your Turn] When your Digimon are played or digivolve, if any of them are red, this Digimon may digivolve into [Crescemon] in the trash with the cost reduced by 1.";
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleArea(card)
  57. && CardEffectCommons.IsOwnerTurn(card)
  58. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  59. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleArea(card)
  64. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)
  65. && HasValidColor(hashtable);
  66. }
  67. bool HasValidColor(Hashtable hashtable)
  68. {
  69. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  70. return hashtables.Map(CardEffectCommons.GetPermanentFromHashtable).Any(HasCorrectColorPermanent);
  71. }
  72. bool HasCorrectColorPermanent(Permanent permanent)
  73. {
  74. return PermanentCondition(permanent)
  75. && permanent.TopCard.CardColors.Contains(CardColor.Red);
  76. }
  77. bool PermanentCondition(Permanent permanent)
  78. {
  79. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  80. }
  81. bool CanSelectCardCondition(CardSource cardSource)
  82. {
  83. return cardSource.EqualsCardName("Crescemon");
  84. }
  85. IEnumerator ActivateCoroutine(Hashtable hashtable)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  88. targetPermanent: card.PermanentOfThisCard(),
  89. cardCondition: CanSelectCardCondition,
  90. payCost: true,
  91. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  92. fixedCostTuple: null,
  93. ignoreDigivolutionRequirementFixedCost: -1,
  94. isHand: false,
  95. activateClass: activateClass,
  96. successProcess: null));
  97. }
  98. }
  99. #endregion
  100. #region Inherited Effect - Jamming
  101. if (timing == EffectTiming.None)
  102. {
  103. cardEffects.Add(CardEffectFactory.JammingSelfStaticEffect(
  104. isInheritedEffect: true,
  105. card: card,
  106. condition: null));
  107. }
  108. #endregion
  109. return cardEffects;
  110. }
  111. }
  112. }