ConditionPlayerBaseStats.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.conditions;
  16. import net.sf.l2j.gameserver.model.L2Character;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. import net.sf.l2j.gameserver.skills.Env;
  19. /**
  20. * @author mkizub
  21. *
  22. * TODO To change the template for this generated type comment go to
  23. * Window - Preferences - Java - Code Style - Code Templates
  24. */
  25. public class ConditionPlayerBaseStats extends Condition {
  26. private final BaseStat _stat;
  27. private final int _value;
  28. public ConditionPlayerBaseStats(@SuppressWarnings("unused") L2Character player, BaseStat stat, int value)
  29. {
  30. super();
  31. _stat = stat;
  32. _value = value;
  33. }
  34. @Override
  35. public boolean testImpl(Env env) {
  36. if (!(env.player instanceof L2PcInstance))
  37. return false;
  38. L2PcInstance player = (L2PcInstance)env.player;
  39. switch (_stat)
  40. {
  41. case Int: return player.getINT() >= _value;
  42. case Str: return player.getSTR() >= _value;
  43. case Con: return player.getCON() >= _value;
  44. case Dex: return player.getDEX() >= _value;
  45. case Men: return player.getMEN() >= _value;
  46. case Wit: return player.getWIT() >= _value;
  47. }
  48. return false;
  49. }
  50. }
  51. enum BaseStat {
  52. Int,
  53. Str,
  54. Con,
  55. Dex,
  56. Men,
  57. Wit
  58. }