BT20_035.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_035 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolve Cost
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. (targetPermanent.TopCard.HasText("Pulsemon") ||
  19. targetPermanent.TopCard.HasSeekersTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. #endregion
  26. #region Fortitude
  27. if (timing == EffectTiming.OnDestroyedAnyone)
  28. {
  29. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region When Digivolving
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Suspend 1 Digimon or Tamer", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  38. cardEffects.Add(activateClass);
  39. string EffectDescription()
  40. {
  41. return "[When Digivolving] Suspend 1 of your opponent's Digimon or Tamers. Then, 1 of their Digimon or Tamers can't unsuspend until the end of their turn.";
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) &&
  46. (permanent.IsDigimon || permanent.IsTamer);
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  51. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. SelectPermanentEffect selectPermanentToSuspend = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentToSuspend.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: 1,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: null,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Tap,
  73. cardEffect: activateClass);
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentToSuspend.Activate());
  75. SelectPermanentEffect selectPermanentToNotUnsuspend = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentToNotUnsuspend.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: CanSelectPermanentCondition,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: 1,
  82. canNoSelect: false,
  83. canEndNotMax: false,
  84. selectPermanentCoroutine: SelectPermanentCoroutine,
  85. afterSelectPermanentCoroutine: null,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentToNotUnsuspend.SetUpCustomMessage("Select 1 Digimon or Tamer that will be unable to unsuspend.", "The opponent is selecting 1 Digimon or Tamer that will be unable to unsuspend.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentToNotUnsuspend.Activate());
  90. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  91. {
  92. Permanent selectedPermanent = permanent;
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  94. targetPermanent: selectedPermanent,
  95. activateClass: activateClass
  96. ));
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region All Turns
  103. if (timing == EffectTiming.OnAddDigivolutionCards)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Activate [When Digivolving] effect, Then may attack", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  108. cardEffects.Add(activateClass);
  109. string EffectDiscription()
  110. {
  111. return "[All Turns] When Tamer cards are placed in this Digimon's digivolution cards, activate 1 of this Digimon's [When Digivolving] effects. Then, 1 of your Digimon may attack your opponent's Digimon.";
  112. }
  113. bool CanSelectPermanentCondition1(Permanent permanent)
  114. {
  115. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  116. {
  117. if (permanent.CanAttack(activateClass))
  118. {
  119. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((enemyDigimon) => permanent.CanAttackTargetDigimon(enemyDigimon, activateClass)) >= 1)
  120. {
  121. return true;
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  130. CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  131. hashtable: hashtable,
  132. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  133. cardEffectCondition: null,
  134. cardCondition: cardSource =>
  135. cardSource.IsTamer);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable hashtable)
  142. {
  143. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  144. .Clone()
  145. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  146. if (candidateEffects.Count >= 1)
  147. {
  148. ICardEffect selectedEffect = null;
  149. if (candidateEffects.Count == 1)
  150. {
  151. selectedEffect = candidateEffects[0];
  152. }
  153. else
  154. {
  155. List<SkillInfo> skillInfos = candidateEffects
  156. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  157. List<CardSource> cardSources = candidateEffects
  158. .Map(cardEffect => cardEffect.EffectSourceCard);
  159. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  160. selectCardEffect.SetUp(
  161. canTargetCondition: (cardSource) => true,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. canNoSelect: () => false,
  165. selectCardCoroutine: null,
  166. afterSelectCardCoroutine: null,
  167. message: "Select 1 effect to activate.",
  168. maxCount: 1,
  169. canEndNotMax: false,
  170. isShowOpponent: false,
  171. mode: SelectCardEffect.Mode.Custom,
  172. root: SelectCardEffect.Root.Custom,
  173. customRootCardList: cardSources,
  174. canLookReverseCard: true,
  175. selectPlayer: card.Owner,
  176. cardEffect: activateClass);
  177. selectCardEffect.SetNotShowCard();
  178. selectCardEffect.SetUpSkillInfos(skillInfos);
  179. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  180. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  181. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  182. {
  183. if (selectedIndexes.Count == 1)
  184. {
  185. selectedEffect = candidateEffects[selectedIndexes[0]];
  186. yield return null;
  187. }
  188. }
  189. }
  190. if (selectedEffect != null)
  191. {
  192. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  193. if (!selectedEffect.IsDisabled)
  194. {
  195. selectedEffect.SetIsDigimonEffect(true);
  196. yield return ContinuousController.instance.StartCoroutine(
  197. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  198. }
  199. }
  200. }
  201. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  202. {
  203. List<Permanent> selectedPermanents = new List<Permanent>();
  204. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: CanSelectPermanentCondition1,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: true,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: null,
  215. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  216. mode: SelectPermanentEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  219. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  220. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  221. {
  222. selectedPermanents = permanents;
  223. yield return null;
  224. }
  225. foreach (Permanent permanent in selectedPermanents)
  226. {
  227. Permanent selectedPermanent = permanent;
  228. if (selectedPermanent != null)
  229. {
  230. if (selectedPermanent.CanAttack(activateClass))
  231. {
  232. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  233. selectAttackEffect.SetUp(
  234. attacker: selectedPermanent,
  235. canAttackPlayerCondition: () => false,
  236. defenderCondition: (permanent) => true,
  237. cardEffect: activateClass);
  238. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region ESS
  247. if (timing == EffectTiming.OnLoseSecurity)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect("<Recovery +1(Deck)>", CanUseCondition, card);
  251. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  252. activateClass.SetHashString("Recover_BT20-035");
  253. activateClass.SetIsInheritedEffect(true);
  254. cardEffects.Add(activateClass);
  255. string EffectDiscription()
  256. {
  257. return "[All Turns] [Once Per Turn] When your security stack is removed from, if this Digimon has [Fenriloogamon] in its name, <Recovery +1(Deck)>.";
  258. }
  259. bool CanUseCondition(Hashtable hashtable)
  260. {
  261. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  262. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  267. card.PermanentOfThisCard().TopCard.ContainsCardName("Fenriloogamon");
  268. }
  269. IEnumerator ActivateCoroutine(Hashtable hashtable)
  270. {
  271. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  272. }
  273. }
  274. #endregion
  275. return cardEffects;
  276. }
  277. }
  278. }