BT10_108.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.BT10
  9. {
  10. public class BT10_108 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. if (timing == EffectTiming.OnDiscardLibrary)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Return this card to hand", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "When this card is trashed from your deck, return it to your hand.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerWhenSelfDiscardLibrary(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.IsExistOnTrash(card))
  32. {
  33. return true;
  34. }
  35. return false;
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  38. {
  39. yield return new WaitForSeconds(0.5f);
  40. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(
  41. new List<CardSource>() { card },
  42. false,
  43. activateClass));
  44. }
  45. }
  46. if (timing == EffectTiming.OptionSkill)
  47. {
  48. int maxLevel()
  49. {
  50. int maxLevel = 6;
  51. if (card.Owner.TrashCards.Count >= 10)
  52. {
  53. maxLevel++;
  54. }
  55. return maxLevel;
  56. }
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  59. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  60. cardEffects.Add(activateClass);
  61. string EffectDiscription()
  62. {
  63. return "[Main] Delete 1 of your opponent's level 6 or lower Digimon. If there are 10 or more cards in your trash, add 1 to the level of the Digimon you can select with this effect.";
  64. }
  65. bool CanSelectPermanentCondition(Permanent permanent)
  66. {
  67. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  68. {
  69. if (permanent.Level <= maxLevel())
  70. {
  71. if (permanent.TopCard.HasLevel)
  72. {
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  84. {
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  86. {
  87. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: maxCount,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: null,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Destroy,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. }
  103. }
  104. }
  105. if (timing == EffectTiming.SecuritySkill)
  106. {
  107. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  108. card: card,
  109. cardEffects: ref cardEffects,
  110. effectName: $"Delete 1 level 6 or lower Digimon");
  111. }
  112. return cardEffects;
  113. }
  114. }
  115. }