BT15_099.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_099 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] By trashing 1 Digimon card in your hand, delete 1 of your opponent's Digimon whose level is less than or equal to the trashed car's level.When a card with [Myotismon] in its text is trashed by this effect, <Draw 2>.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. return cardSource.IsDigimon;
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  29. }
  30. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  31. {
  32. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  33. {
  34. bool discarded = false;
  35. CardSource discardedCard = null;
  36. int discardCount = 1;
  37. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  38. selectHandEffect.SetUp(
  39. selectPlayer: card.Owner,
  40. canTargetCondition: CanSelectCardCondition,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. maxCount: discardCount,
  44. canNoSelect: true,
  45. canEndNotMax: false,
  46. isShowOpponent: true,
  47. selectCardCoroutine: null,
  48. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  49. mode: SelectHandEffect.Mode.Discard,
  50. cardEffect: activateClass);
  51. yield return StartCoroutine(selectHandEffect.Activate());
  52. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  53. {
  54. if (cardSources.Count == 1)
  55. {
  56. discarded = true;
  57. discardedCard = cardSources[0];
  58. yield return null;
  59. }
  60. }
  61. if (discarded)
  62. {
  63. bool CanSelectPermanentCondition(Permanent permanent)
  64. {
  65. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  66. {
  67. if (permanent.TopCard.HasLevel)
  68. {
  69. if (discardedCard.HasLevel)
  70. {
  71. if (permanent.Level <= discardedCard.Level)
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  81. {
  82. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  83. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: maxCount,
  90. canNoSelect: false,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: null,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Destroy,
  95. cardEffect: activateClass);
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. }
  98. if (discardedCard != null)
  99. {
  100. if (discardedCard.HasText("Myotismon"))
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. if (timing == EffectTiming.SecuritySkill)
  110. {
  111. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Trash 1 card from hand to delete 1 Digimon and Draw 2");
  112. }
  113. return cardEffects;
  114. }
  115. }
  116. }