LM_003.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.LM
  4. {
  5. public class LM_003 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region When Attacking
  11. if (timing == EffectTiming.OnAllyAttack)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Can't be deleted by battle", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Attacking] By trashing 1 blue card in your hand, this Digimon can't be deleted in battle for the turn.";
  20. }
  21. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  22. {
  23. if (permanent == AttackingPermanent)
  24. {
  25. return true;
  26. }
  27. if (permanent == DefendingPermanent)
  28. {
  29. return true;
  30. }
  31. return false;
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. if (cardSource.HasCardColor(CardColor.Blue))
  36. {
  37. return true;
  38. }
  39. return false;
  40. }
  41. bool PermanentCondition(Permanent permanent)
  42. {
  43. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  44. {
  45. if(permanent.cardSources.Contains(card))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.HandCards.Count >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. bool discarded = false;
  70. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  71. selectHandEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. selectCardCoroutine: null,
  81. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  82. mode: SelectHandEffect.Mode.Discard,
  83. cardEffect: activateClass);
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  86. {
  87. if (cardSources.Count == 1)
  88. {
  89. discarded = true;
  90. yield return null;
  91. }
  92. }
  93. if (discarded)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedPlayerEffect(
  96. permanentCondition: PermanentCondition,
  97. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  98. effectDuration: EffectDuration.UntilEachTurnEnd,
  99. activateClass: activateClass,
  100. effectName: "Can't be deleted by battle"));
  101. }
  102. }
  103. }
  104. #endregion
  105. #region When Attacking
  106. if (timing == EffectTiming.OnAllyAttack)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Draw 1 card", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  111. activateClass.SetIsInheritedEffect(true);
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[When Attacking] If you have 7 or fewer cards in your hand, <Draw 1>.";
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  120. }
  121. bool CanActivateCondition(Hashtable hashtable)
  122. {
  123. if (CardEffectCommons.IsExistOnBattleArea(card))
  124. {
  125. if (card.Owner.HandCards.Count <= 7)
  126. {
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  135. }
  136. }
  137. #endregion
  138. return cardEffects;
  139. }
  140. }
  141. }