BT23_058.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //Craniamon
  4. namespace DCGO.CardEffects.BT23
  5. {
  6. public class BT23_058 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel5 &&
  17. targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region Reboot
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Blocker
  31. if (timing == EffectTiming.None)
  32. {
  33. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region All Turns
  37. if (timing == EffectTiming.WhenRemoveField)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("Prevent Digimon from leaving play", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[All Turns] When any of your Digimon or Tamers would leave the battle area by your opponent's effects, by suspending this Digimon, 1 of those Digimon or Tamers doesn't leave.";
  46. }
  47. bool RemovedPermanent(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && (permanent.IsDigimon || permanent.IsTamer);
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleArea(card)
  54. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, RemovedPermanent)
  55. && CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card));
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleArea(card) &&
  60. CardEffectCommons.CanActivateSuspendCostEffect(card);
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  63. {
  64. Permanent selectedPermanent = card.PermanentOfThisCard();
  65. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent }, _hashtable).Tap());
  66. if (selectedPermanent.IsSuspended)
  67. {
  68. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable)
  69. .Filter(RemovedPermanent);
  70. bool CanSelectRemovedPermanent(Permanent permanent)
  71. {
  72. return protectedPermanents.Contains(permanent);
  73. }
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectRemovedPermanent,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: 1,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. permanent.willBeRemoveField = false;
  91. permanent.HideDeleteEffect();
  92. permanent.HideHandBounceEffect();
  93. permanent.HideDeckBounceEffect();
  94. yield return null;
  95. }
  96. }
  97. }
  98. }
  99. #endregion
  100. #region All Turns - OPT
  101. if (timing == EffectTiming.OnTappedAnyone)
  102. {
  103. ActivateClass activateClass = new ActivateClass();
  104. activateClass.SetUpICardEffect("Delete opponent's Digimon", CanUseCondition, card);
  105. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription1());
  106. activateClass.SetHashString("AT_BT23-058");
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription1()
  109. {
  110. return "[All Turns] [Once Per Turn] When this Digimon suspends, delete all of your opponent's Digimon with the lowest play cost.";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  115. {
  116. if (CardEffectCommons.CanTriggerWhenSelfPermanentSuspends(hashtable, card))
  117. {
  118. return true;
  119. }
  120. }
  121. return false;
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  128. {
  129. bool PermanentCondition(Permanent permanent)
  130. {
  131. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  132. && permanent.TopCard.HasPlayCost
  133. && CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  134. }
  135. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  136. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  137. }
  138. }
  139. #endregion
  140. return cardEffects;
  141. }
  142. }
  143. }