Reboot.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections;
  3. public partial class CardEffectFactory
  4. {
  5. #region Static effect of [Reboot] on oneself
  6. public static RebootClass RebootSelfStaticEffect(bool isInheritedEffect, CardSource card, Func<bool> condition, bool isLinkedEffect = false)
  7. {
  8. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  9. bool CanUseCondition()
  10. {
  11. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  12. {
  13. if (condition == null || condition())
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. return RebootStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: isInheritedEffect, card: card, condition: CanUseCondition, isLinkedEffect: isLinkedEffect);
  21. }
  22. #endregion
  23. #region Static effect of [Reboot]
  24. public static RebootClass RebootStaticEffect(Func<Permanent, bool> permanentCondition, bool isInheritedEffect, CardSource card, Func<bool> condition, bool isLinkedEffect = false)
  25. {
  26. string effectName = "Reboot";
  27. RebootClass rebootClass = new RebootClass();
  28. rebootClass.SetUpICardEffect(effectName, CanUseCondition, card);
  29. rebootClass.SetUpRebootClass(PermanentCondition: PermanentCondition);
  30. if (isInheritedEffect)
  31. {
  32. rebootClass.SetIsInheritedEffect(true);
  33. }
  34. if (isLinkedEffect)
  35. {
  36. rebootClass.SetIsLinkedEffect(true);
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return condition == null || condition();
  41. }
  42. bool PermanentCondition(Permanent permanent)
  43. {
  44. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  45. {
  46. if (permanentCondition == null || permanentCondition(permanent))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. return rebootClass;
  54. }
  55. #endregion
  56. }