CanNotSuspend.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections;
  3. public partial class CardEffectCommons
  4. {
  5. #region Target 1 Digimon can't suspend until opponent's turn end
  6. public static IEnumerator GainCantSuspendUntilOpponentTurnEnd(Permanent targetPermanent, ICardEffect activateClass)
  7. {
  8. if (targetPermanent == null) yield break;
  9. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  10. if (activateClass == null) yield break;
  11. if (activateClass.EffectSourceCard == null) yield break;
  12. CardSource card = activateClass.EffectSourceCard;
  13. static bool CanUseCondition() => true;
  14. string effectName = "Can't suspend until the end of this card's owner's turn";
  15. yield return ContinuousController.instance.StartCoroutine(GainCanNotSuspend(
  16. targetPermanent: targetPermanent,
  17. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  18. activateClass: activateClass,
  19. condition: CanUseCondition,
  20. effectName: effectName
  21. ));
  22. }
  23. #endregion
  24. #region Target 1 Digimon can't suspend
  25. public static IEnumerator GainCanNotSuspend(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass, Func<bool> condition, string effectName)
  26. {
  27. if (targetPermanent == null) yield break;
  28. if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
  29. if (activateClass == null) yield break;
  30. if (activateClass.EffectSourceCard == null) yield break;
  31. CardSource card = activateClass.EffectSourceCard;
  32. bool PermanentCondition(Permanent permanent) => permanent == targetPermanent;
  33. bool CanUseCondition()
  34. {
  35. if (IsPermanentExistsOnBattleArea(targetPermanent))
  36. {
  37. if (condition == null || condition())
  38. {
  39. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  40. {
  41. return true;
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. CanNotSuspendClass canNotSuspendClass = CardEffectFactory.CantSuspendStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition, effectName: effectName);
  48. AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: canNotSuspendClass, timing: EffectTiming.None);
  49. if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(targetPermanent));
  52. }
  53. }
  54. #endregion
  55. }