P_154.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.P
  4. {
  5. public class P_154 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region All Turns
  11. if (timing == EffectTiming.WhenRemoveField)
  12. {
  13. List<Permanent> removedPermanents = new List<Permanent>();
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Add as bottom source to prevent deletion", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[All Turns] When another of your Digimon with [Knightmon] in its text would leave the battle area by an opponent's effect, by placing this Digimon as its bottom digivolution card, it doesn't leave.";
  21. }
  22. bool IsKnightmon(Permanent permanent)
  23. {
  24. if(CardEffectCommons.IsOwnerPermanent(permanent, card))
  25. {
  26. if (permanent != card.PermanentOfThisCard())
  27. return permanent.TopCard.HasText("Knightmon");
  28. }
  29. return false;
  30. }
  31. bool CanSelectPermanentCondition(Permanent permanent)
  32. {
  33. return removedPermanents.Contains(permanent);
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  38. {
  39. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsKnightmon))
  40. {
  41. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(IsKnightmon);
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. if (permanent != null)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), permanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  76. if (CardEffectCommons.IsExistOnBattleArea(card))
  77. {
  78. if (permanent.DigivolutionCards.Contains(card))
  79. {
  80. permanent.willBeRemoveField = false;
  81. permanent.HideHandBounceEffect();
  82. permanent.HideDeckBounceEffect();
  83. permanent.HideWillRemoveFieldEffect();
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. #endregion
  91. #region Blocker - ESS
  92. if (timing == EffectTiming.None)
  93. {
  94. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  95. }
  96. #endregion
  97. return cardEffects;
  98. }
  99. }
  100. }