BT18_056.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.BT18
  8. {
  9. public class BT18_056 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternate Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5 &&
  20. targetPermanent.TopCard.EqualsTraits("Royal Base");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  24. card: card, condition: null));
  25. }
  26. #endregion
  27. #region Piercing/Reboot
  28. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  29. {
  30. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  31. }
  32. if (timing == EffectTiming.None)
  33. {
  34. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region On Play/When Digivolving Shared
  38. bool IsOpponenetsDigimon(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  41. }
  42. #endregion
  43. #region On Play
  44. if (timing == EffectTiming.OnEnterFieldAnyone)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Suspend 1 for each face up security, Then opponents Digimon can't unsuspend", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[On Play] For each of your face up security cards, suspend 1 of your opponent's Digimon. Then, none of their Digimon can unsuspend until the end of their turn.";
  53. }
  54. bool PermanentCondition(Permanent permanent)
  55. {
  56. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  57. {
  58. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. int maxCount = Mathf.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count, card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: IsOpponenetsDigimon,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: null,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Tap,
  88. cardEffect: activateClass);
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  91. permanentCondition: PermanentCondition,
  92. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  93. activateClass: activateClass,
  94. isOnlyActivePhase: false,
  95. effectName: "Your Digimon can't unsuspend"));
  96. }
  97. }
  98. #endregion
  99. #region When Digivolving
  100. if (timing == EffectTiming.OnEnterFieldAnyone)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect("Suspend 1 for each face up security, Then opponents Digimon can't unsuspend", CanUseCondition, card);
  104. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  105. cardEffects.Add(activateClass);
  106. string EffectDiscription()
  107. {
  108. return "[When Digivolving] For each of your face up security cards, suspend 1 of your opponent's Digimon. Then, none of their Digimon can unsuspend until the end of their turn.";
  109. }
  110. bool PermanentCondition(Permanent permanent)
  111. {
  112. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  113. {
  114. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  128. }
  129. IEnumerator ActivateCoroutine(Hashtable hashtable)
  130. {
  131. int maxCount = Mathf.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count, card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped));
  132. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: IsOpponenetsDigimon,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: maxCount,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Tap,
  144. cardEffect: activateClass);
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  147. permanentCondition: PermanentCondition,
  148. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  149. activateClass: activateClass,
  150. isOnlyActivePhase: false,
  151. effectName: "Your Digimon can't unsuspend"));
  152. }
  153. }
  154. #endregion
  155. #region All Turns
  156. if (timing == EffectTiming.OnDestroyedAnyone)
  157. {
  158. ActivateClass activateClass = new ActivateClass();
  159. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  160. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  161. activateClass.SetHashString("BT18_056_Unsuspend");
  162. cardEffects.Add(activateClass);
  163. string EffectDescription()
  164. {
  165. return "[All Turns] [Once Per Turn] When other Digimon are deleted in battle, this Digimon may unsuspend.";
  166. }
  167. bool PermanentCondition(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) &&
  170. permanent.IsDigimon &&
  171. permanent != card.PermanentOfThisCard();
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.IsExistOnBattleArea(card) &&
  176. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass) &&
  177. CardEffectCommons.IsByBattle(hashtable);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleArea(card) &&
  182. CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()) &&
  183. CardEffectCommons.GetHashtablesFromHashtable(hashtable) is { Count: >= 1 };
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable hashtable)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(
  188. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  189. }
  190. }
  191. #endregion
  192. return cardEffects;
  193. }
  194. }
  195. }