EX2_043.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX2
  6. {
  7. public class EX2_043 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Players trash hand cards", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] All players trash cards in their hand until they have 5 cards left.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleArea(card))
  29. {
  30. if (GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer.Count((player) => player.HandCards.Count > 5) >= 1)
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  38. {
  39. if (isExistOnField(card))
  40. {
  41. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  42. {
  43. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  44. {
  45. if (player.HandCards.Count > 5)
  46. {
  47. int discardCount = player.HandCards.Count - 5;
  48. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  49. selectHandEffect.SetUp(
  50. selectPlayer: player,
  51. canTargetCondition: (cardSource) => true,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: discardCount,
  55. canNoSelect: false,
  56. canEndNotMax: false,
  57. isShowOpponent: true,
  58. selectCardCoroutine: null,
  59. afterSelectCardCoroutine: null,
  60. mode: SelectHandEffect.Mode.Discard,
  61. cardEffect: activateClass);
  62. yield return StartCoroutine(selectHandEffect.Activate());
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. if (timing == EffectTiming.OnDiscardHand)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Unsuspend your Digimon", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  74. activateClass.SetHashString("Unsuspend_EX2_043");
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[Your Turn][Once Per Turn] When one of your effects trashes a card in your hand, you may unsuspend 1 of your Digimon.";
  79. }
  80. bool CanSelectPermanentCondition(Permanent permanent)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.IsSuspended)
  85. {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.IsExistOnBattleArea(card))
  94. {
  95. if (CardEffectCommons.IsOwnerTurn(card))
  96. {
  97. bool SkillCondition(ICardEffect cardEffect)
  98. {
  99. if (cardEffect != null)
  100. {
  101. if (cardEffect.EffectSourceCard != null)
  102. {
  103. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  104. {
  105. return true;
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, SkillCondition, cardSource => cardSource.Owner == card.Owner))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  131. {
  132. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  133. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  134. selectPermanentEffect.SetUp(
  135. selectPlayer: card.Owner,
  136. canTargetCondition: CanSelectPermanentCondition,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. maxCount: maxCount,
  140. canNoSelect: false,
  141. canEndNotMax: false,
  142. selectPermanentCoroutine: null,
  143. afterSelectPermanentCoroutine: null,
  144. mode: SelectPermanentEffect.Mode.UnTap,
  145. cardEffect: activateClass);
  146. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  147. }
  148. }
  149. return cardEffects;
  150. }
  151. }
  152. }