BT24_040.cs 15 KB

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