BT8_102.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 BT8_102 : 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.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] You may suspend 1 of your Digimon to suspend 1 of your opponent's Digimon or Tamers. Your opponent's cards suspended with this effect can't unsuspend until the end of their next turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanSelectPermanentCondition1(Permanent permanent)
  28. {
  29. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  30. {
  31. if (permanent.IsDigimon || permanent.IsTamer)
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. Permanent selectedPermanent = null;
  47. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  48. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  49. selectPermanentEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: CanSelectPermanentCondition,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: maxCount,
  55. canNoSelect: true,
  56. canEndNotMax: false,
  57. selectPermanentCoroutine: SelectPermanentCoroutine,
  58. afterSelectPermanentCoroutine: null,
  59. mode: SelectPermanentEffect.Mode.Custom,
  60. cardEffect: activateClass);
  61. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  62. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  63. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  64. {
  65. selectedPermanent = permanent;
  66. yield return null;
  67. }
  68. if (selectedPermanent != null)
  69. {
  70. if (selectedPermanent.TopCard != null)
  71. {
  72. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  73. {
  74. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  75. {
  76. Permanent tapPermanent = selectedPermanent;
  77. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { tapPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  78. if (tapPermanent.TopCard != null)
  79. {
  80. if (tapPermanent.IsSuspended)
  81. {
  82. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  83. {
  84. maxCount = 1;
  85. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) < maxCount)
  86. {
  87. maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1);
  88. }
  89. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents())
  90. {
  91. permanent.oldIsTapped_playCard = permanent.IsSuspended;
  92. }
  93. selectPermanentEffect.SetUp(
  94. selectPlayer: card.Owner,
  95. canTargetCondition: CanSelectPermanentCondition1,
  96. canTargetCondition_ByPreSelecetedList: null,
  97. canEndSelectCondition: null,
  98. maxCount: maxCount,
  99. canNoSelect: false,
  100. canEndNotMax: false,
  101. selectPermanentCoroutine: null,
  102. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  103. mode: SelectPermanentEffect.Mode.Tap,
  104. cardEffect: activateClass);
  105. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  106. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  107. {
  108. foreach (Permanent selectedPermanent in permanents)
  109. {
  110. if (selectedPermanent != null)
  111. {
  112. if (selectedPermanent.IsSuspended)
  113. {
  114. if (!selectedPermanent.oldIsTapped_playCard)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  117. targetPermanent: selectedPermanent,
  118. activateClass: activateClass
  119. ));
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. if (timing == EffectTiming.SecuritySkill)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect($"Suspend 1 Digimon or a Tamer", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  140. activateClass.SetIsSecurityEffect(true);
  141. cardEffects.Add(activateClass);
  142. string EffectDiscription()
  143. {
  144. return "[Security] Suspend 1 of your opponent's Digimon or Tamers.";
  145. }
  146. bool CanSelectPermanentCondition(Permanent permanent)
  147. {
  148. if (permanent != null)
  149. {
  150. if (permanent.TopCard != null)
  151. {
  152. if (permanent.IsDigimon || permanent.IsTamer)
  153. {
  154. if (permanent.TopCard.Owner == card.Owner.Enemy)
  155. {
  156. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  157. {
  158. return true;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  169. }
  170. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  171. {
  172. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  173. {
  174. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanSelectPermanentCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: maxCount,
  182. canNoSelect: false,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: null,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Tap,
  187. cardEffect: activateClass);
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. }
  190. }
  191. }
  192. return cardEffects;
  193. }
  194. }