BT20_101.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_101 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasPlayCost && targetPermanent.TopCard.GetCostItself >= 10 &&
  18. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel6 &&
  19. targetPermanent.TopCard.EqualsTraits("Vortex Warriors");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 1,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Blast Digivolve
  30. if (timing == EffectTiming.OnCounterTiming)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  33. }
  34. #endregion
  35. #region Piercing/Vortex/Blocker
  36. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  37. {
  38. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  39. }
  40. if (timing == EffectTiming.OnEndTurn)
  41. {
  42. cardEffects.Add(CardEffectFactory.VortexSelfEffect(isInheritedEffect: false, card: card, condition: null));
  43. }
  44. if (timing == EffectTiming.None)
  45. {
  46. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  47. }
  48. #endregion
  49. #region All Turns
  50. if (timing == EffectTiming.OnTappedAnyone)
  51. {
  52. ActivateClass activateClass = new ActivateClass();
  53. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  54. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  55. activateClass.SetHashString("Unsuspend_BT20-101");
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[All Turns] [Once Per Turn] When any Digimon suspend, this Digimon may unsuspend.";
  60. }
  61. bool PermanentCondition(Permanent permanent)
  62. {
  63. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  64. }
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  68. CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition) ;
  69. }
  70. bool CanActivateCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable hashtable)
  75. {
  76. yield return ContinuousController.instance.StartCoroutine(
  77. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  78. }
  79. }
  80. #endregion
  81. #region On Play
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Suspend 1 Digimon, Then return 1 to bottom of deck for every 2 suspended", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  87. cardEffects.Add(activateClass);
  88. string EffectDiscription()
  89. {
  90. return "[On Play] You may suspend 1 Digimon. Then, for every 2 suspended Digimon, you may return 1 of your opponent's suspended Digimon to the bottom of the deck.";
  91. }
  92. bool DigimonCondition(Permanent permanent)
  93. {
  94. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  95. }
  96. bool SuspendedDigimon(Permanent permanent)
  97. {
  98. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  99. permanent.IsSuspended;
  100. }
  101. bool OpponentsSuspendedDigimon(Permanent permanent)
  102. {
  103. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  104. permanent.IsSuspended;
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  113. }
  114. IEnumerator ActivateCoroutine(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.HasMatchConditionPermanent(DigimonCondition))
  117. {
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: DigimonCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: 1,
  125. canNoSelect: true,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: null,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Tap,
  130. cardEffect: activateClass);
  131. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  133. }
  134. if (CardEffectCommons.MatchConditionPermanentCount(SuspendedDigimon) >= 2)
  135. {
  136. int maxCount = Math.Min(CardEffectCommons.MatchConditionPermanentCount(OpponentsSuspendedDigimon), Mathf.FloorToInt(CardEffectCommons.MatchConditionPermanentCount(SuspendedDigimon) / 2));
  137. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  138. selectPermanentEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: OpponentsSuspendedDigimon,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: maxCount,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: null,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  149. cardEffect: activateClass);
  150. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon to bottom deck.", $"The opponent is selecting {maxCount} Digimon to bottom deck.");
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. }
  153. }
  154. }
  155. #endregion
  156. #region When Digivolving
  157. if (timing == EffectTiming.OnEnterFieldAnyone)
  158. {
  159. ActivateClass activateClass = new ActivateClass();
  160. activateClass.SetUpICardEffect("Suspend 1 Digimon, Then return 1 to bottom of deck for every 2 suspended", CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  162. cardEffects.Add(activateClass);
  163. string EffectDiscription()
  164. {
  165. return "[When Digivolving] You may suspend 1 Digimon. Then, for every 2 suspended Digimon, you may return 1 of your opponent's suspended Digimon to the bottom of the deck.";
  166. }
  167. bool DigimonCondition(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  170. }
  171. bool SuspendedDigimon(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent) &&
  174. permanent.IsSuspended;
  175. }
  176. bool OpponentsSuspendedDigimon(Permanent permanent)
  177. {
  178. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  179. permanent.IsSuspended;
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  184. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  185. }
  186. bool CanActivateCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.HasMatchConditionPermanent(DigimonCondition))
  193. {
  194. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  195. selectPermanentEffect.SetUp(
  196. selectPlayer: card.Owner,
  197. canTargetCondition: DigimonCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: 1,
  201. canNoSelect: true,
  202. canEndNotMax: false,
  203. selectPermanentCoroutine: null,
  204. afterSelectPermanentCoroutine: null,
  205. mode: SelectPermanentEffect.Mode.Tap,
  206. cardEffect: activateClass);
  207. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. }
  210. if (CardEffectCommons.MatchConditionPermanentCount(SuspendedDigimon) >= 2)
  211. {
  212. int maxCount = Math.Min(CardEffectCommons.MatchConditionPermanentCount(OpponentsSuspendedDigimon), Mathf.FloorToInt(CardEffectCommons.MatchConditionPermanentCount(SuspendedDigimon)/2));
  213. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  214. selectPermanentEffect.SetUp(
  215. selectPlayer: card.Owner,
  216. canTargetCondition: OpponentsSuspendedDigimon,
  217. canTargetCondition_ByPreSelecetedList: null,
  218. canEndSelectCondition: null,
  219. maxCount: maxCount,
  220. canNoSelect: true,
  221. canEndNotMax: false,
  222. selectPermanentCoroutine: null,
  223. afterSelectPermanentCoroutine: null,
  224. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  225. cardEffect: activateClass);
  226. selectPermanentEffect.SetUpCustomMessage($"Select {maxCount} Digimon to bottom deck.", $"The opponent is selecting {maxCount} Digimon to bottom deck.");
  227. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  228. }
  229. }
  230. }
  231. #endregion
  232. return cardEffects;
  233. }
  234. }
  235. }