LambdaStats.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 net.sf.l2j.gameserver.skills.funcs;
  16. import net.sf.l2j.gameserver.skills.Env;
  17. /**
  18. * @author mkizub
  19. *
  20. * TODO To change the template for this generated type comment go to
  21. * Window - Preferences - Java - Code Style - Code Templates
  22. */
  23. public final class LambdaStats extends Lambda {
  24. public enum StatsType
  25. {
  26. PLAYER_LEVEL,
  27. TARGET_LEVEL,
  28. PLAYER_MAX_HP,
  29. PLAYER_MAX_MP
  30. }
  31. private final StatsType _stat;
  32. public LambdaStats(StatsType stat)
  33. {
  34. _stat = stat;
  35. }
  36. @Override
  37. public double calc(Env env) {
  38. switch (_stat)
  39. {
  40. case PLAYER_LEVEL:
  41. if (env.player == null)
  42. return 1;
  43. return env.player.getLevel();
  44. case TARGET_LEVEL:
  45. if (env.target == null)
  46. return 1;
  47. return env.target.getLevel();
  48. case PLAYER_MAX_HP:
  49. if (env.player == null)
  50. return 1;
  51. return env.player.getMaxHp();
  52. case PLAYER_MAX_MP:
  53. if (env.player == null)
  54. return 1;
  55. return env.player.getMaxMp();
  56. }
  57. return 0;
  58. }
  59. }