BT17_047.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_047 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play/When Digivolving Shared
  12. bool IsOpponentsDigimon(Permanent permanent)
  13. {
  14. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  15. }
  16. #endregion
  17. #region On Play
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Suspend 1 Opponent's Digimon", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "[On Play] Suspend 1 of your opponent's Digimon.";
  27. }
  28. bool CanUseCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  35. {
  36. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon))
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable hashtable)
  44. {
  45. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  46. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  47. selectPermanentEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: IsOpponentsDigimon,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: maxCount,
  53. canNoSelect: false,
  54. canEndNotMax: false,
  55. selectPermanentCoroutine: null,
  56. afterSelectPermanentCoroutine: SelectPermanentCoroutine,
  57. mode: SelectPermanentEffect.Mode.Custom,
  58. cardEffect: activateClass);
  59. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  60. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  61. IEnumerator SelectPermanentCoroutine(List<Permanent> permanents)
  62. {
  63. if (permanents != null)
  64. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(permanents, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  65. }
  66. }
  67. }
  68. #endregion
  69. #region When Digivolving
  70. if (timing == EffectTiming.OnEnterFieldAnyone)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("Suspend 1 Opponent's Digimon", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[When Digivolving] Suspend 1 of your opponent's Digimon.";
  79. }
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  87. {
  88. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsDigimon))
  89. {
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: IsOpponentsDigimon,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: maxCount,
  105. canNoSelect: false,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: null,
  108. afterSelectPermanentCoroutine: SelectPermanentCoroutine,
  109. mode: SelectPermanentEffect.Mode.Custom,
  110. cardEffect: activateClass);
  111. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. IEnumerator SelectPermanentCoroutine(List<Permanent> permanents)
  114. {
  115. if (permanents != null)
  116. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(permanents, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  117. }
  118. }
  119. }
  120. #endregion
  121. #region All Turns - ESS
  122. if (timing == EffectTiming.OnDestroyedAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  127. activateClass.SetHashString("Unsuspend_BT17_047");
  128. activateClass.SetIsInheritedEffect(true);
  129. cardEffects.Add(activateClass);
  130. string EffectDiscription()
  131. {
  132. return "[All Turns] [Once Per Turn] When this Digimon deletes an opponent's Digimon in battle, you may unsuspend this Digimon.";
  133. }
  134. bool PermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  141. {
  142. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition))
  143. {
  144. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  145. bool WinnerRealCondition(Permanent permanent)
  146. {
  147. return true;
  148. }
  149. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  150. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, winnerRealCondition: WinnerRealCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  163. {
  164. Permanent selectedPermanent = card.PermanentOfThisCard();
  165. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  166. }
  167. }
  168. #endregion
  169. #region Security Effect
  170. if (timing == EffectTiming.SecuritySkill)
  171. {
  172. if(card.Owner.GetBattleAreaDigimons().Count == 0)
  173. cardEffects.Add(CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect(card: card));
  174. }
  175. #endregion
  176. return cardEffects;
  177. }
  178. }
  179. }