ConditionPlayerBaseStats.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.model.conditions;
  16. import com.l2jserver.gameserver.model.actor.L2Character;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.model.stats.Env;
  19. /**
  20. * The Class ConditionPlayerBaseStats.
  21. * @author mkizub
  22. */
  23. public class ConditionPlayerBaseStats extends Condition
  24. {
  25. private final BaseStat _stat;
  26. private final int _value;
  27. /**
  28. * Instantiates a new condition player base stats.
  29. * @param player the player
  30. * @param stat the stat
  31. * @param value the value
  32. */
  33. public ConditionPlayerBaseStats(L2Character player, BaseStat stat, int value)
  34. {
  35. super();
  36. _stat = stat;
  37. _value = value;
  38. }
  39. /**
  40. * Test impl.
  41. * @param env the env
  42. * @return true, if successful
  43. * @see com.l2jserver.gameserver.model.conditions.Condition#testImpl(com.l2jserver.gameserver.model.stats.Env)
  44. */
  45. @Override
  46. public boolean testImpl(Env env)
  47. {
  48. if (env.getPlayer() == null)
  49. {
  50. return false;
  51. }
  52. final L2PcInstance player = env.getPlayer();
  53. switch (_stat)
  54. {
  55. case Int:
  56. return player.getINT() >= _value;
  57. case Str:
  58. return player.getSTR() >= _value;
  59. case Con:
  60. return player.getCON() >= _value;
  61. case Dex:
  62. return player.getDEX() >= _value;
  63. case Men:
  64. return player.getMEN() >= _value;
  65. case Wit:
  66. return player.getWIT() >= _value;
  67. }
  68. return false;
  69. }
  70. }
  71. enum BaseStat
  72. {
  73. Int,
  74. Str,
  75. Con,
  76. Dex,
  77. Men,
  78. Wit
  79. }