BT17_040.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_040 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolve Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Pulsemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region When Digivolving
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Suspend 1 Digimon and give opponent's Digimon Sec-1 if there's a Tamer in the Digivolution cards", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[When Digivolving] Suspend 1 of your opponent's Digimon. If [Leon Alexander] is in this Digimon's digivolution cards, all of your opponent's Digimon gain <Security A. -1> until the end of their turn.";
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. selectPermanentEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: CanSelectPermanentCondition,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: maxCount,
  57. canNoSelect: false,
  58. canEndNotMax: false,
  59. selectPermanentCoroutine: null,
  60. afterSelectPermanentCoroutine: null,
  61. mode: SelectPermanentEffect.Mode.Tap,
  62. cardEffect: activateClass);
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. }
  65. if (card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("Leon Alexander")) || card.PermanentOfThisCard().DigivolutionCards.Some(cardSource => cardSource.CardNames.Contains("LeonAlexander")))
  66. {
  67. bool PermanentCondition(Permanent permanent)
  68. {
  69. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  70. }
  71. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttackPlayerEffect(
  72. permanentCondition: PermanentCondition,
  73. changeValue: -1,
  74. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  75. activateClass: activateClass));
  76. }
  77. }
  78. }
  79. #endregion
  80. #region End of Your Turn
  81. if (timing == EffectTiming.OnEndTurn)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect("Give -6000 DP and/or Recovery +1. Then 1 of your Digimon may attack", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  86. activateClass.SetHashString("EndofTurn_BT17_040");
  87. cardEffects.Add(activateClass);
  88. string EffectDiscription()
  89. {
  90. return "[End of Your Turn] [Once Per Turn] If you have 3 or more security cards, 1 of your opponent's Digimon gets -6000 DP for the turn. If you have 3 or fewer security cards, <Recovery +1 (Deck)>. Then, 1 of your Digimon may attack an opponent's Digimon.";
  91. }
  92. bool CanSelectPermanentCondition(Permanent permanent)
  93. {
  94. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  95. }
  96. bool CanSelectPermanentCondition1(Permanent permanent)
  97. {
  98. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  99. {
  100. if (permanent.CanAttack(activateClass))
  101. {
  102. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((enemyDigimon) => permanent.CanAttackTargetDigimon(enemyDigimon, activateClass)) >= 1)
  103. {
  104. return true;
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. if(CardEffectCommons.IsOwnerTurn(card))
  113. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  114. return false;
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  119. }
  120. IEnumerator ActivateCoroutine(Hashtable hashtable)
  121. {
  122. List<Permanent> selectedPermanents = new List<Permanent>();
  123. if (card.Owner.SecurityCards.Count >= 3)
  124. {
  125. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  126. {
  127. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. selectPermanentEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: CanSelectPermanentCondition,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: false,
  136. canEndNotMax: false,
  137. selectPermanentCoroutine: SelectPermanentCoroutine,
  138. afterSelectPermanentCoroutine: null,
  139. mode: SelectPermanentEffect.Mode.Custom,
  140. cardEffect: activateClass);
  141. selectPermanentEffect.SetUpCustomMessage(
  142. "Select 1 Digimon that will get DP -6000.",
  143. "The opponent is selecting 1 Digimon that will get DP -6000.");
  144. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  145. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  148. targetPermanent: permanent,
  149. changeValue: -6000,
  150. effectDuration: EffectDuration.UntilEachTurnEnd,
  151. activateClass: activateClass));
  152. }
  153. }
  154. }
  155. if (card.Owner.SecurityCards.Count <= 3)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(new IRecovery(
  158. card.Owner,
  159. 1,
  160. activateClass).Recovery());
  161. }
  162. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  163. {
  164. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  165. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectPermanentCondition1,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: null,
  175. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  181. {
  182. selectedPermanents = permanents;
  183. yield return null;
  184. }
  185. foreach (Permanent permanent in selectedPermanents)
  186. {
  187. Permanent selectedPermanent = permanent;
  188. if (selectedPermanent != null)
  189. {
  190. if (selectedPermanent.CanAttack(activateClass))
  191. {
  192. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  193. selectAttackEffect.SetUp(
  194. attacker: selectedPermanent,
  195. canAttackPlayerCondition: () => false,
  196. defenderCondition: (permanent) => true,
  197. cardEffect: activateClass);
  198. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. #endregion
  206. #region Inherit
  207. if (timing == EffectTiming.OnLoseSecurity)
  208. {
  209. ActivateClass activateClass = new ActivateClass();
  210. activateClass.SetUpICardEffect("DP -8000 if this Digimon has Fenriloogamon in its name", CanUseCondition, card);
  211. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  212. activateClass.SetIsInheritedEffect(true);
  213. cardEffects.Add(activateClass);
  214. string EffectDiscription()
  215. {
  216. return "[All Turns][Once Per Turn] When a card is removed from your security stack, if this Digimon has [Fenriloogamon] in its name, 1 of your opponent's Digimon gets -8000 DP for the turn.";
  217. }
  218. bool CanSelectPermanentCondition(Permanent permanent)
  219. {
  220. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  221. }
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. if (CardEffectCommons.IsExistOnBattleArea(card))
  225. {
  226. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner))
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. bool CanActivateCondition(Hashtable hashtable)
  234. {
  235. if (CardEffectCommons.IsExistOnBattleArea(card))
  236. {
  237. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  238. {
  239. if (card.Owner.LibraryCards.Count >= 1)
  240. {
  241. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Fenriloogamon"))
  242. {
  243. return true;
  244. }
  245. }
  246. }
  247. }
  248. return false;
  249. }
  250. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  251. {
  252. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  253. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  254. selectPermanentEffect.SetUp(
  255. selectPlayer: card.Owner,
  256. canTargetCondition: CanSelectPermanentCondition,
  257. canTargetCondition_ByPreSelecetedList: null,
  258. canEndSelectCondition: null,
  259. maxCount: maxCount,
  260. canNoSelect: false,
  261. canEndNotMax: false,
  262. selectPermanentCoroutine: SelectPermanentCoroutine,
  263. afterSelectPermanentCoroutine: null,
  264. mode: SelectPermanentEffect.Mode.Custom,
  265. cardEffect: activateClass);
  266. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -8000.", "The opponent is selecting 1 Digimon that will get DP -8000.");
  267. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  268. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  269. {
  270. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -8000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  271. }
  272. }
  273. }
  274. #endregion
  275. return cardEffects;
  276. }
  277. }
  278. }