AD1_018.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // LordKnightmon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_018 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Reduce Play Cost
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition()
  17. {
  18. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, WouldPlayCondition);
  19. }
  20. bool WouldPlayCondition(Permanent permanent)
  21. {
  22. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent)
  23. && (permanent.TopCard.ContainsCardName("Knightmon") || permanent.TopCard.ContainsCardName("Lucemon"));
  24. }
  25. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  26. }
  27. #endregion
  28. #region Shared OP/WD
  29. string SharedEffectName() => "1 of your Digimon becomes immune to enemy Digimon effects until end of their turn";
  30. string SharedEffectDescription(string tag) => $"[{tag}] Until your opponent's turn ends, their Digimon's effects don't affect 1 of your Digimon.";
  31. bool SharedCanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  34. }
  35. bool SharedCanSelectPermanentCondition(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  38. }
  39. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  40. {
  41. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: SharedCanSelectPermanentCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: 1,
  48. canNoSelect: false,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get immunity.", "The opponent is selecting 1 Digimon that will get immunity.");
  55. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  56. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  57. {
  58. #region Give Digimon Effect Immunity
  59. permanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(permanent));
  60. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(permanent));
  61. #endregion
  62. }
  63. }
  64. #endregion
  65. #region On Play
  66. if (timing == EffectTiming.OnEnterFieldAnyone)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  70. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  71. cardEffects.Add(activateClass);
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  75. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  76. }
  77. }
  78. #endregion
  79. #region When Digivolving
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  84. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  85. cardEffects.Add(activateClass);
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  89. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  90. }
  91. }
  92. #endregion
  93. #region All Turns
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 enemy Digimon", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  99. activateClass.SetHashString("AD1_018_AT");
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. {
  103. return "[All Turns] [Once Per Turn] When any of your Digimon with [Knightmon] or [Lucemon] in their texts are played, <De-Digivolve 2> 1 of your opponent's Digimon.";
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  108. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, TriggerCondition);
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  113. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  114. }
  115. bool TriggerCondition(Permanent permanent)
  116. {
  117. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  118. && (permanent.TopCard.HasText("Knightmon") || permanent.TopCard.HasText("Lucemon"));
  119. }
  120. bool CanSelectPermanentCondition(Permanent permanent)
  121. {
  122. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  125. {
  126. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition: CanSelectPermanentCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. maxCount: 1,
  134. canNoSelect: false,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: null,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Degenerate,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetDegenerationCount(2);
  141. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  142. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  143. }
  144. }
  145. #endregion
  146. #region Security
  147. if (timing == EffectTiming.SecuritySkill)
  148. {
  149. ActivateClass activateClass = new ActivateClass();
  150. activateClass.SetUpICardEffect("<De-Digivolve 1> 1 enemy Digimon, delete 1 enemy Digimon with play cost of 3 or less", CanUseCondition, card);
  151. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  152. activateClass.SetIsSecurityEffect(true);
  153. activateClass.SetIsDigimonEffect(true);
  154. cardEffects.Add(activateClass);
  155. string EffectDescription()
  156. {
  157. return "[Security] <De-Digivolve 1> 1 of your opponent's Digimon. Then, delete 1 of your opponent's Digimon with a play cost of 3 or less.";
  158. }
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. return card.Owner.ExecutingCards.Contains(card);
  166. }
  167. bool CanSelectPermanentCondition(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  170. }
  171. bool CanSelectPermanentCondition1(Permanent permanent)
  172. {
  173. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  174. && permanent.TopCard.HasPlayCost
  175. && permanent.TopCard.GetCostItself <= 3;
  176. }
  177. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  178. {
  179. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  180. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: CanSelectPermanentCondition,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: maxCount,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: null,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Degenerate,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition1));
  196. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  197. selectPermanentEffect1.SetUp(
  198. selectPlayer: card.Owner,
  199. canTargetCondition: CanSelectPermanentCondition1,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. maxCount: maxCount1,
  203. canNoSelect: false,
  204. canEndNotMax: false,
  205. selectPermanentCoroutine: null,
  206. afterSelectPermanentCoroutine: null,
  207. mode: SelectPermanentEffect.Mode.Destroy,
  208. cardEffect: activateClass);
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }