ConditionPlayerBaseStats.java 2.1 KB

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