EX1_059.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX1
  4. {
  5. public class EX1_059 : 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.OnAllyAttack)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("Trash 1 card from hand to get Security Attack +1", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[When Attacking] You may trash 1 card in your hand to have this Digimon gain <Security Attack +1> for the turn. (This Digimon checks 1 additional security card.)";
  19. }
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  23. }
  24. bool CanActivateCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleArea(card))
  27. {
  28. if (card.Owner.HandCards.Count >= 1)
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  36. {
  37. if (card.Owner.HandCards.Count >= 1)
  38. {
  39. bool discarded = false;
  40. int discardCount = 1;
  41. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  42. selectHandEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: (cardSource) => true,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: discardCount,
  48. canNoSelect: true,
  49. canEndNotMax: false,
  50. isShowOpponent: true,
  51. selectCardCoroutine: null,
  52. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  53. mode: SelectHandEffect.Mode.Discard,
  54. cardEffect: activateClass);
  55. yield return StartCoroutine(selectHandEffect.Activate());
  56. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  57. {
  58. if (cardSources.Count >= 1)
  59. {
  60. discarded = true;
  61. yield return null;
  62. }
  63. }
  64. if (discarded)
  65. {
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: card.PermanentOfThisCard(), changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  67. }
  68. }
  69. }
  70. }
  71. if (timing == EffectTiming.OnAllyAttack)
  72. {
  73. ActivateClass activateClass = new ActivateClass();
  74. activateClass.SetUpICardEffect("Trash 1 card from hand to get DP +2000", CanUseCondition, card);
  75. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  76. activateClass.SetIsInheritedEffect(true);
  77. cardEffects.Add(activateClass);
  78. string EffectDiscription()
  79. {
  80. return "[When Attacking] You may trash 1 card in your hand to have this Digimon get +2000 DP for the turn.";
  81. }
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  85. }
  86. bool CanActivateCondition(Hashtable hashtable)
  87. {
  88. if (CardEffectCommons.IsExistOnBattleArea(card))
  89. {
  90. if (card.Owner.HandCards.Count >= 1)
  91. {
  92. return true;
  93. }
  94. }
  95. return false;
  96. }
  97. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  98. {
  99. if (card.Owner.HandCards.Count >= 1)
  100. {
  101. bool discarded = false;
  102. int discardCount = 1;
  103. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  104. selectHandEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: (cardSource) => true,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: discardCount,
  110. canNoSelect: true,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. selectCardCoroutine: null,
  114. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  115. mode: SelectHandEffect.Mode.Discard,
  116. cardEffect: activateClass);
  117. yield return StartCoroutine(selectHandEffect.Activate());
  118. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  119. {
  120. if (cardSources.Count >= 1)
  121. {
  122. discarded = true;
  123. yield return null;
  124. }
  125. }
  126. if (discarded)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  129. }
  130. }
  131. }
  132. }
  133. return cardEffects;
  134. }
  135. }
  136. }