BT23_025.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. // MarineAngemon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_025 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Hand - Main
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Give 3 Digimon Sec-1", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  35. activateClass.SetIsDigimonEffect(true);
  36. cardEffects.Add(activateClass);
  37. string EffectDescription()
  38. {
  39. return "[Hand] [Main] If you have a Digimon or Tamer with the [CS] trait, by paying 5 cost, give 3 of your opponent's Digimon <Security A. -1> until their turn ends. Then, place this card as the top security card.";
  40. }
  41. bool IsCSDigimonOrTamer(Permanent permanent)
  42. {
  43. bool isCSDigimon = CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  44. permanent.TopCard.HasCSTraits;
  45. bool isCSTamer = CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  46. permanent.TopCard.IsTamer &&
  47. permanent.TopCard.HasCSTraits;
  48. return isCSDigimon || isCSTamer;
  49. }
  50. bool IsOpponentDigimon(Permanent permanent)
  51. {
  52. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  53. {
  54. return true;
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. // Can use from your hand, if you have a CS digimon or tamer
  61. return CardEffectCommons.IsExistOnHand(card)
  62. && CardEffectCommons.IsOwnerTurn(card)
  63. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSDigimonOrTamer)
  64. && card.Owner.MaxMemoryCost >= 5;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSDigimonOrTamer))
  69. {
  70. // First, select 3 opponent's digimon on the field
  71. int maxCount = Math.Min(3, CardEffectCommons.MatchConditionPermanentCount(IsOpponentDigimon));
  72. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  73. selectPermanentEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: IsOpponentDigimon,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: maxCount,
  79. canNoSelect: false,
  80. canEndNotMax: false,
  81. selectPermanentCoroutine: SelectPermanentCoroutine,
  82. afterSelectPermanentCoroutine: null,
  83. mode: SelectPermanentEffect.Mode.Custom,
  84. cardEffect: activateClass);
  85. selectPermanentEffect.SetUpCustomMessage("Select 3 Digimon that will get Security Attack -1.", "The opponent is selecting 3 Digimon that will get Security Attack -1.");
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  88. {
  89. // To the permanents selected, apply the Sec-1.
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -1, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  91. yield return null;
  92. }
  93. // Either way, pay the 5 cost, then place this card as the top security card.
  94. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-5, activateClass));
  95. if (card.Owner.CanAddSecurity(activateClass))
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, true, false));
  98. }
  99. else
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(card));
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region On Play/When Digivolving Shared
  108. bool IsLowestLevelOpponentDigimon(Permanent permanent)
  109. {
  110. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  111. {
  112. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. #endregion
  120. #region On Play
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  126. cardEffects.Add(activateClass);
  127. string EffectDescription()
  128. {
  129. return
  130. "[On Play] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  135. }
  136. bool CanActivateCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  150. {
  151. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLowestLevelOpponentDigimon));
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: IsLowestLevelOpponentDigimon,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: false,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: null,
  162. afterSelectPermanentCoroutine: null,
  163. mode: SelectPermanentEffect.Mode.Bounce,
  164. cardEffect: activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. }
  167. }
  168. }
  169. #endregion
  170. #region When Digivolving
  171. if (timing == EffectTiming.OnEnterFieldAnyone)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("Return 1 of your opponent's Digimon to hand", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  176. cardEffects.Add(activateClass);
  177. string EffectDescription()
  178. {
  179. return
  180. "[When Digivolving] Return 1 of your opponent's Digimon with the lowest level to the hand.";
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleArea(card) &&
  185. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  186. }
  187. bool CanActivateCondition(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.IsExistOnBattleArea(card))
  190. {
  191. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  192. {
  193. return true;
  194. }
  195. }
  196. return false;
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. if (CardEffectCommons.HasMatchConditionPermanent(IsLowestLevelOpponentDigimon))
  201. {
  202. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLowestLevelOpponentDigimon));
  203. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  204. selectPermanentEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: IsLowestLevelOpponentDigimon,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: maxCount,
  210. canNoSelect: false,
  211. canEndNotMax: false,
  212. selectPermanentCoroutine: null,
  213. afterSelectPermanentCoroutine: null,
  214. mode: SelectPermanentEffect.Mode.Bounce,
  215. cardEffect: activateClass);
  216. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  217. }
  218. }
  219. }
  220. #endregion
  221. #region Security Effect
  222. if (timing == EffectTiming.SecuritySkill)
  223. {
  224. cardEffects.Add(CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect(card: card, EffectDuration.UntilEachTurnEnd));
  225. }
  226. #endregion
  227. return cardEffects;
  228. }
  229. }
  230. }