EX4_052.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX4
  4. {
  5. public class EX4_052 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OnDestroyedAnyone)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  15. activateClass.SetHashString("Draw2_EX4_052");
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Your Turn][Once Per Turn] When an opponent's Digimon is deleted, by trashing 1 card of the same level in your hand, <Draw 2>. (Draw 2 cards from your deck.)";
  20. }
  21. bool PermanentCondition(Permanent permanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. if (CardEffectCommons.IsExistOnBattleArea(card))
  28. {
  29. if (CardEffectCommons.IsOwnerTurn(card))
  30. {
  31. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  44. if (hashtables != null)
  45. {
  46. List<int> levels = hashtables
  47. .Map(hashtable1 => CardEffectCommons.GetPermanentFromHashtable(hashtable1))
  48. .Filter(permanent => permanent != null && permanent.LevelJustBeforeRemoveField > 0)
  49. .Map(permanent => permanent.LevelJustBeforeRemoveField);
  50. bool CanSelectCardCondition(CardSource cardSource)
  51. {
  52. return cardSource.HasLevel && levels.Contains(cardSource.Level);
  53. }
  54. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(_hashtable);
  65. if (hashtables != null)
  66. {
  67. List<int> levels = hashtables
  68. .Map(hashtable1 => CardEffectCommons.GetPermanentFromHashtable(hashtable1))
  69. .Filter(permanent => permanent != null && permanent.LevelJustBeforeRemoveField > 0)
  70. .Map(permanent => permanent.LevelJustBeforeRemoveField);
  71. bool CanSelectCardCondition(CardSource cardSource)
  72. {
  73. return cardSource.HasLevel && levels.Contains(cardSource.Level);
  74. }
  75. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  76. {
  77. bool discarded = false;
  78. int discardCount = 1;
  79. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  80. selectHandEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CanSelectCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: discardCount,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. selectCardCoroutine: null,
  90. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  91. mode: SelectHandEffect.Mode.Discard,
  92. cardEffect: activateClass);
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  95. {
  96. if (cardSources.Count >= 1)
  97. {
  98. discarded = true;
  99. yield return null;
  100. }
  101. }
  102. if (discarded)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  105. }
  106. }
  107. }
  108. }
  109. }
  110. return cardEffects;
  111. }
  112. }
  113. }