LambdaStats.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.skills.funcs;
  16. import com.l2jserver.gameserver.skills.Env;
  17. /**
  18. * @author mkizub
  19. */
  20. public final class LambdaStats extends Lambda
  21. {
  22. public enum StatsType
  23. {
  24. PLAYER_LEVEL,
  25. CUBIC_LEVEL,
  26. TARGET_LEVEL,
  27. PLAYER_MAX_HP,
  28. PLAYER_MAX_MP
  29. }
  30. private final StatsType _stat;
  31. public LambdaStats(StatsType stat)
  32. {
  33. _stat = stat;
  34. }
  35. @Override
  36. public double calc(Env env) {
  37. switch (_stat)
  38. {
  39. case PLAYER_LEVEL:
  40. if (env.player == null)
  41. return 1;
  42. return env.player.getLevel();
  43. case CUBIC_LEVEL:
  44. if(env.cubic == null)
  45. return 1;
  46. return env.cubic.getOwner().getLevel();
  47. case TARGET_LEVEL:
  48. if (env.target == null)
  49. return 1;
  50. return env.target.getLevel();
  51. case PLAYER_MAX_HP:
  52. if (env.player == null)
  53. return 1;
  54. return env.player.getMaxHp();
  55. case PLAYER_MAX_MP:
  56. if (env.player == null)
  57. return 1;
  58. return env.player.getMaxMp();
  59. }
  60. return 0;
  61. }
  62. }