ConditionPlayerActiveSkillId.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2004-2014 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.conditions;
  20. import com.l2jserver.gameserver.model.skills.Skill;
  21. import com.l2jserver.gameserver.model.stats.Env;
  22. /**
  23. * The Class ConditionPlayerActiveSkillId.
  24. * @author DrHouse
  25. */
  26. public class ConditionPlayerActiveSkillId extends Condition
  27. {
  28. private final int _skillId;
  29. private final int _skillLevel;
  30. /**
  31. * Instantiates a new condition player active skill id.
  32. * @param skillId the skill id
  33. */
  34. public ConditionPlayerActiveSkillId(int skillId)
  35. {
  36. _skillId = skillId;
  37. _skillLevel = -1;
  38. }
  39. /**
  40. * Instantiates a new condition player active skill id.
  41. * @param skillId the skill id
  42. * @param skillLevel the skill level
  43. */
  44. public ConditionPlayerActiveSkillId(int skillId, int skillLevel)
  45. {
  46. _skillId = skillId;
  47. _skillLevel = skillLevel;
  48. }
  49. @Override
  50. public boolean testImpl(Env env)
  51. {
  52. for (Skill sk : env.getCharacter().getAllSkills())
  53. {
  54. if (sk != null)
  55. {
  56. if (sk.getId() == _skillId)
  57. {
  58. if ((_skillLevel == -1) || (_skillLevel <= sk.getLevel()))
  59. {
  60. return true;
  61. }
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. }