BT24_040.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. // Venusmon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_040 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Reduce Play Cost
  23. if (timing == EffectTiming.None)
  24. {
  25. bool Condition()
  26. {
  27. return card.Owner.SecurityCards.Count <= 3;
  28. }
  29. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  30. }
  31. #endregion
  32. #region On Play / When Digivolving Shared
  33. string SharedEffectName = "Trash 1 Digimon sources. 2 Digimon or Tamers can't Suspend or Activate When Digivolving";
  34. CardEffectFactory.ActivateClassesForSharedEffects(
  35. ref cardEffects, timing, card,
  36. SharedEffectName,
  37. SharedActivateCoroutine,
  38. SharedEffectDescription,
  39. optional: false,
  40. onPlay: true,
  41. whenDigivolving: true);
  42. string SharedEffectDescription(string tag) => $"[{tag}] Trash all digivolution cards of 1 of your opponent's Digimon. Then, until your opponent's turn ends, 2 of their Digimon or Tamers can't suspend or activate [When Digivolving] effects.";
  43. bool CanTrashDigivolutionCardsCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. bool CanFreezeCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  50. && (permanent.TopCard.IsDigimon
  51. || permanent.TopCard.IsTamer);
  52. }
  53. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  54. {
  55. if (CardEffectCommons.HasMatchConditionPermanent(CanTrashDigivolutionCardsCondition))
  56. {
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanTrashDigivolutionCardsCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: SelectPermanentCoroutine,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanent, trashCount: permanent.DigivolutionCards.Count, isFromTop: true, activateClass: activateClass));
  75. }
  76. }
  77. if (CardEffectCommons.HasMatchConditionPermanent(CanFreezeCondition))
  78. {
  79. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanFreezeCondition));
  80. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect1.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanFreezeCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine1,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect1.SetUpCustomMessage($"Select {maxCount} card(s) that cannot suspend or activate when digivolving.", $"The opponent is selecting {maxCount} card(s) that cannot suspend or activate when digivolving.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  95. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  96. {
  97. Permanent selectedPermanent = permanent;
  98. if (selectedPermanent != null)
  99. {
  100. #region Can't Suspend
  101. CanNotSuspendClass canNotSuspendClass = new CanNotSuspendClass();
  102. canNotSuspendClass.SetUpICardEffect("Can't Suspend", CanUseCondition1, card);
  103. canNotSuspendClass.SetUpCanNotSuspendClass(PermanentCondition: PermanentCondition);
  104. selectedPermanent.UntilOwnerTurnEndEffects.Add((_timing) => canNotSuspendClass);
  105. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  108. }
  109. bool CanUseCondition1(Hashtable hashtable)
  110. {
  111. return selectedPermanent.TopCard != null
  112. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  113. }
  114. bool PermanentCondition(Permanent permanent)
  115. {
  116. return permanent == selectedPermanent;
  117. }
  118. #endregion
  119. #region Can't Activate When Digivolving
  120. DisableEffectClass invalidationClass = new DisableEffectClass();
  121. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseConditionDebuff, card);
  122. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  123. selectedPermanent.UntilOwnerTurnEndEffects.Add(_ => invalidationClass);
  124. bool CanUseConditionDebuff(Hashtable hashtableDebuff)
  125. {
  126. return true;
  127. }
  128. bool InvalidateCondition(ICardEffect cardEffect)
  129. {
  130. return selectedPermanent.TopCard != null
  131. && cardEffect != null
  132. && cardEffect.EffectSourceCard != null
  133. && isExistOnField(cardEffect.EffectSourceCard)
  134. && cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent
  135. && cardEffect.IsWhenDigivolving
  136. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass);
  137. }
  138. #endregion
  139. }
  140. }
  141. }
  142. }
  143. #endregion
  144. #region All Turns
  145. if (timing == EffectTiming.WhenRemoveField)
  146. {
  147. List<Permanent> removedPermanents = new List<Permanent>();
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("By placing a sourceless Digimon to Security, your [TS] digimon won't leave the field", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  151. activateClass.SetHashString("BT24_040_AT");
  152. cardEffects.Add(activateClass);
  153. string EffectDescription()
  154. {
  155. return "[All Turns] [Once Per Turn] When any of your [TS] trait Digimon would leave the battle area other than by your effects, by placing 1 other Digimon with no digivolution cards as the bottom security card, they don't leave.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleArea(card)
  160. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
  161. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleArea(card)
  166. && card.Owner.CanAddSecurity(activateClass))
  167. {
  168. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(PermanentCondition);
  169. return CardEffectCommons.HasMatchConditionPermanent(CanPlaceToSecurityCondition);
  170. }
  171. return false;
  172. }
  173. bool PermanentCondition(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  176. && permanent.TopCard.HasTSTraits;
  177. }
  178. bool CanPlaceToSecurityCondition(Permanent permanent)
  179. {
  180. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  181. {
  182. foreach (Permanent removed in removedPermanents)
  183. {
  184. if (removed != permanent)
  185. return permanent.DigivolutionCards.Count == 0;
  186. }
  187. }
  188. return false;
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.HasMatchConditionPermanent(CanPlaceToSecurityCondition))
  193. {
  194. Permanent selectedPermanent = null;
  195. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanPlaceToSecurityCondition));
  196. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  197. selectPermanentEffect.SetUp(
  198. selectPlayer: card.Owner,
  199. canTargetCondition: CanPlaceToSecurityCondition,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. maxCount: maxCount,
  203. canNoSelect: false,
  204. canEndNotMax: false,
  205. selectPermanentCoroutine: SelectPermanentCoroutine,
  206. afterSelectPermanentCoroutine: null,
  207. mode: SelectPermanentEffect.Mode.Custom,
  208. cardEffect: activateClass);
  209. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security.", "The opponent is selecting 1 Digimon to place in security.");
  210. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  211. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  212. {
  213. selectedPermanent = permanent;
  214. yield return null;
  215. }
  216. if (selectedPermanent != null)
  217. {
  218. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  219. {
  220. #region hashtable
  221. Hashtable _hashtable = new Hashtable()
  222. {
  223. {"CardEffect", activateClass}
  224. };
  225. #endregion
  226. CardSource topCard = selectedPermanent.TopCard;
  227. yield return ContinuousController.instance.StartCoroutine(
  228. CardEffectCommons.PlacePermanentInSecurityAndProcessAccordingToResult(
  229. targetPermanent: selectedPermanent,
  230. activateClass: activateClass,
  231. toTop: false,
  232. SuccessProcess));
  233. IEnumerator SuccessProcess(CardSource cardSource)
  234. {
  235. foreach (Permanent permanent in removedPermanents)
  236. {
  237. permanent.willBeRemoveField = false;
  238. permanent.HideDeleteEffect();
  239. permanent.HideHandBounceEffect();
  240. permanent.HideDeckBounceEffect();
  241. permanent.HideWillRemoveFieldEffect();
  242. }
  243. yield return null;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. #endregion
  251. return cardEffects;
  252. }
  253. }
  254. }