P_052.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. public class P_052 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Opponent's Digimon with no Digivolution cards can't attack", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] If you have a Tamer in play, up to 3 of your opponent's Digimon with no digivolution cards can't attack until the end of your opponent's next turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.HasNoDigivolutionCards)
  28. {
  29. if (permanent.CanSelectBySkill(activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectPermanentCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: CanEndSelectCondition,
  66. maxCount: maxCount,
  67. canNoSelect: false,
  68. canEndNotMax: true,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select Digimon that will get effects.", "The opponent is selecting Digimon that will get effects.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. bool CanEndSelectCondition(List<Permanent> permanents)
  76. {
  77. if (CardEffectCommons.HasNoElement(permanents))
  78. {
  79. return false;
  80. }
  81. return true;
  82. }
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. Permanent selectedPermanent = permanent;
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  87. targetPermanent: selectedPermanent,
  88. defenderCondition: null,
  89. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  90. activateClass: activateClass,
  91. effectName: "Can't Attack"));
  92. }
  93. }
  94. }
  95. }
  96. if (timing == EffectTiming.OnAllyAttack)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("Return 1 Digimon with no Digivolution cards to hand", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  101. activateClass.SetHashString("Bounce_P_052");
  102. cardEffects.Add(activateClass);
  103. string EffectDiscription()
  104. {
  105. return "[When Attacking][Once Per Turn] Return 1 of your opponent's Digimon with no digivolution cards to its owner's hand.";
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  110. {
  111. if (permanent.HasNoDigivolutionCards)
  112. {
  113. if (permanent.CanSelectBySkill(activateClass))
  114. {
  115. return true;
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. return true;
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: null,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Bounce,
  150. cardEffect: activateClass);
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. }
  153. }
  154. }
  155. return cardEffects;
  156. }
  157. }