P_162.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_162 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.EqualsTraits("DS");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 2,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null)
  24. );
  25. }
  26. #endregion
  27. #region On Play/When Digivolving Shared
  28. bool CanSelectPermanentCondition(Permanent permanent)
  29. {
  30. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  31. {
  32. if (permanent.TopCard.EqualsTraits("DS"))
  33. {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  42. {
  43. return CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  44. }
  45. return false;
  46. }
  47. #endregion
  48. #region On Play
  49. if (timing == EffectTiming.OnEnterFieldAnyone)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect("Opponent's effects can't reduce a DS digimon's DP or de-digivolve it", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  54. cardEffects.Add(activateClass);
  55. string EffectDescription()
  56. {
  57. return "[On Play] Until the end of your opponent's turn, their effects can't reduce the DP of 1 of your [DS] trait Digimon or affect it with <De-Digivolve> effects.";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable hashtable)
  64. {
  65. Permanent selectedPermanent = null;
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectPermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effects.", "The opponent is selecting 1 Digimon that will gain effects.");
  81. yield return StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. selectedPermanent = permanent;
  85. yield return null;
  86. }
  87. if (selectedPermanent != null)
  88. {
  89. // DP reduction protection
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
  91. targetPermanent: selectedPermanent,
  92. cardEffectCondition: CardEffectCondition,
  93. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  94. activateClass: activateClass,
  95. effectName: "Can't have DP reduced by opponent's effects"));
  96. bool CardEffectCondition(ICardEffect cardEffect)
  97. {
  98. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  99. }
  100. // De-digivolve protection
  101. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  102. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseCondition1, selectedPermanent.TopCard);
  103. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentCondition);
  104. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  105. bool CanUseCondition1(Hashtable hashtable1)
  106. {
  107. return selectedPermanent.TopCard != null;
  108. }
  109. bool PermanentCondition(Permanent permanent)
  110. {
  111. return permanent == selectedPermanent;
  112. }
  113. }
  114. }
  115. }
  116. #endregion
  117. #region When Digivolving
  118. if (timing == EffectTiming.OnEnterFieldAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("Opponent's effects can't reduce a DS digimon's DP or de-digivolve it", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  123. cardEffects.Add(activateClass);
  124. string EffectDescription()
  125. {
  126. return "[When Digivolving] Until the end of your opponent's turn, their effects can't reduce the DP of 1 of your [DS] trait Digimon or affect it with <De-Digivolve> effects.";
  127. }
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. Permanent selectedPermanent = null;
  135. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. selectPermanentEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectPermanentCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: maxCount,
  143. canNoSelect: false,
  144. canEndNotMax: false,
  145. selectPermanentCoroutine: SelectPermanentCoroutine,
  146. afterSelectPermanentCoroutine: null,
  147. mode: SelectPermanentEffect.Mode.Custom,
  148. cardEffect: activateClass);
  149. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effects.", "The opponent is selecting 1 Digimon that will gain effects.");
  150. yield return StartCoroutine(selectPermanentEffect.Activate());
  151. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  152. {
  153. selectedPermanent = permanent;
  154. yield return null;
  155. }
  156. if (selectedPermanent != null)
  157. {
  158. // DP reduction protection
  159. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainImmuneFromDPMinus(
  160. targetPermanent: selectedPermanent,
  161. cardEffectCondition: CardEffectCondition,
  162. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  163. activateClass: activateClass,
  164. effectName: "Can't have DP reduced by opponent's effects"));
  165. bool CardEffectCondition(ICardEffect cardEffect)
  166. {
  167. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  168. }
  169. // De-digivolve protection
  170. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  171. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseCondition1, selectedPermanent.TopCard);
  172. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentCondition);
  173. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  174. bool CanUseCondition1(Hashtable hashtable1)
  175. {
  176. return selectedPermanent.TopCard != null;
  177. }
  178. bool PermanentCondition(Permanent permanent)
  179. {
  180. return permanent == selectedPermanent;
  181. }
  182. }
  183. }
  184. }
  185. #endregion
  186. #region Blocker - ESS
  187. if (timing == EffectTiming.None)
  188. {
  189. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  190. isInheritedEffect: true,
  191. card: card,
  192. condition: null));
  193. }
  194. #endregion
  195. return cardEffects;
  196. }
  197. }
  198. }