LM_041.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Regalecusmon
  5. namespace DCGO.CardEffects.LM
  6. {
  7. public class LM_041 : 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
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.IsLevel5)
  18. {
  19. if (targetPermanent.TopCard.EqualsTraits("DS"))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("1 [DS] digimon unsuspends", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[On Play] 1 of your Digimon with the [DS] trait unsuspends.";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  47. {
  48. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanSelectPermanentCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  58. {
  59. if (permanent.TopCard.EqualsTraits("DS"))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: maxCount,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: null,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.UnTap,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will be returned to unsuspend", "The opponent is selecting 1 Digimon that will be returned to unsuspend");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. }
  85. }
  86. #endregion
  87. #region When Digivolving
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("1 [DS] digimon unsuspends", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[When Digivolving] 1 of your Digimon with the [DS] trait unsuspends.";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  101. {
  102. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  112. {
  113. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanSelectPermanentCondition(Permanent permanent)
  121. {
  122. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  123. {
  124. if (permanent.TopCard.EqualsTraits("DS"))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  134. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: CanSelectPermanentCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: maxCount,
  141. canNoSelect: false,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: null,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.UnTap,
  146. cardEffect: activateClass);
  147. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will be returned to unsuspend", "The opponent is selecting 1 Digimon that will be returned to unsuspend");
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. }
  150. }
  151. #endregion
  152. #region When Digivolving OPT
  153. if (timing == EffectTiming.OnEnterFieldAnyone)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Add top sec to hand", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  158. activateClass.SetHashString("WD/WA_LM_041");
  159. cardEffects.Add(activateClass);
  160. string EffectDiscription()
  161. {
  162. return "[When Digivolving] [Once Per Turn] If you have 1 or more memory, your opponent adds their top security card to the hand. Then, if you have 1 or less, until your opponent's turn ends, 1 of their Digimon or Tamers can't be suspended.";
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  167. {
  168. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  178. {
  179. return true;
  180. }
  181. return false;
  182. }
  183. bool CanSelectPermanentCondition(Permanent permanent)
  184. {
  185. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  186. {
  187. if (permanent.IsDigimon || permanent.IsTamer)
  188. {
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. if (card.Owner.MemoryForPlayer >= 1 && card.Owner.Enemy.CanReduceSecurity() && card.Owner.Enemy.SecurityCards.Count >= 1)
  197. {
  198. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  199. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  200. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  201. player: card.Owner.Enemy,
  202. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  203. activateClass).ReduceSecurity());
  204. }
  205. if (card.Owner.MemoryForPlayer <= 1 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  206. {
  207. Permanent selectedPermanent = null;
  208. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  209. selectPermanentEffect.SetUp(
  210. selectPlayer: card.Owner,
  211. canTargetCondition: CanSelectPermanentCondition,
  212. canTargetCondition_ByPreSelecetedList: null,
  213. canEndSelectCondition: null,
  214. maxCount: 1,
  215. canNoSelect: false,
  216. canEndNotMax: false,
  217. selectPermanentCoroutine: SelectPermanentCoroutine,
  218. afterSelectPermanentCoroutine: null,
  219. mode: SelectPermanentEffect.Mode.Custom,
  220. cardEffect: activateClass);
  221. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer to stun", "The opponent is selecting 1 Digimon or tamer to stun");
  222. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  223. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  224. {
  225. selectedPermanent = permanent;
  226. yield return null;
  227. }
  228. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspendPlayerEffect(
  229. permanentCondition: (permanent) => permanent == selectedPermanent,
  230. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  231. activateClass: activateClass,
  232. isOnlyActivePhase: false,
  233. effectName: "Can't Suspend"
  234. ));
  235. }
  236. }
  237. }
  238. #endregion
  239. #region When Attacking OPT
  240. if (timing == EffectTiming.OnAllyAttack)
  241. {
  242. ActivateClass activateClass = new ActivateClass();
  243. activateClass.SetUpICardEffect("Add top sec to hand", CanUseCondition, card);
  244. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  245. activateClass.SetHashString("WD/WA_LM_041");
  246. cardEffects.Add(activateClass);
  247. string EffectDiscription()
  248. {
  249. return "[When Attacking] [Once Per Turn] If you have 1 or more memory, your opponent adds their top security card to the hand. Then, if you have 1 or less, until your opponent's turn ends, 1 of their Digimon or Tamers can't be suspended.";
  250. }
  251. bool CanUseCondition(Hashtable hashtable)
  252. {
  253. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  254. {
  255. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  256. {
  257. return true;
  258. }
  259. }
  260. return false;
  261. }
  262. bool CanActivateCondition(Hashtable hashtable)
  263. {
  264. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  265. {
  266. return true;
  267. }
  268. return false;
  269. }
  270. bool CanSelectPermanentCondition(Permanent permanent)
  271. {
  272. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  273. {
  274. if (permanent.IsDigimon || permanent.IsTamer)
  275. {
  276. return true;
  277. }
  278. }
  279. return false;
  280. }
  281. IEnumerator ActivateCoroutine(Hashtable hashtable)
  282. {
  283. if (card.Owner.MemoryForPlayer >= 1 && card.Owner.Enemy.CanReduceSecurity() && card.Owner.Enemy.SecurityCards.Count >= 1)
  284. {
  285. CardSource topCard = card.Owner.Enemy.SecurityCards[0];
  286. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  287. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  288. player: card.Owner.Enemy,
  289. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  290. activateClass).ReduceSecurity());
  291. }
  292. if (card.Owner.MemoryForPlayer <= 1 && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  293. {
  294. Permanent selectedPermanent = null;
  295. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  296. selectPermanentEffect.SetUp(
  297. selectPlayer: card.Owner,
  298. canTargetCondition: CanSelectPermanentCondition,
  299. canTargetCondition_ByPreSelecetedList: null,
  300. canEndSelectCondition: null,
  301. maxCount: 1,
  302. canNoSelect: false,
  303. canEndNotMax: false,
  304. selectPermanentCoroutine: SelectPermanentCoroutine,
  305. afterSelectPermanentCoroutine: null,
  306. mode: SelectPermanentEffect.Mode.Custom,
  307. cardEffect: activateClass);
  308. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or Tamer to stun", "The opponent is selecting 1 Digimon or tamer to stun");
  309. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  310. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  311. {
  312. selectedPermanent = permanent;
  313. yield return null;
  314. }
  315. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspendPlayerEffect(
  316. permanentCondition: (permanent) => permanent == selectedPermanent,
  317. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  318. activateClass: activateClass,
  319. isOnlyActivePhase: false,
  320. effectName: "Can't Suspend"
  321. ));
  322. }
  323. }
  324. }
  325. #endregion
  326. return cardEffects;
  327. }
  328. }
  329. }