BT20_062.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_062 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Retaliation
  11. if (timing == EffectTiming.OnDestroyedAnyone)
  12. {
  13. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  14. }
  15. #endregion
  16. #region On Deletion - ESS
  17. if (timing == EffectTiming.OnDestroyedAnyone)
  18. {
  19. ActivateClass activateClass = new ActivateClass();
  20. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 of your opponent's level 4 or lower Digimon",
  21. CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  23. activateClass.SetIsInheritedEffect(true);
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return
  28. "[On Deletion] By trashing 1 card in your hand, delete 1 of your opponent's level 4 or lower Digimon.";
  29. }
  30. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  31. {
  32. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  33. permanent.IsDigimon &&
  34. permanent.TopCard.HasLevel &&
  35. permanent.Level <= 4;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  44. card.Owner.HandCards.Count >= 1;
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. bool discarded = false;
  49. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  50. selectHandEffect.SetUp(
  51. canTargetCondition: _ => true,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. canNoSelect: true,
  55. selectCardCoroutine: null,
  56. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  57. maxCount: 1,
  58. canEndNotMax: false,
  59. isShowOpponent: true,
  60. mode: SelectHandEffect.Mode.Discard,
  61. selectPlayer: card.Owner,
  62. cardEffect: activateClass);
  63. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.",
  64. "The opponent is selecting 1 card to discard.");
  65. yield return StartCoroutine(selectHandEffect.Activate());
  66. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  67. {
  68. discarded = cardSources.Count > 0;
  69. yield return null;
  70. }
  71. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  72. {
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectOpponentPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: null,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Destroy,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  87. "The opponent is selecting 1 Digimon to delete.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. }
  90. }
  91. }
  92. #endregion
  93. return cardEffects;
  94. }
  95. }
  96. }