RuneHive-Game
Loading...
Searching...
No Matches
EquipmentRequirement.java
Go to the documentation of this file.
1package com.runehive.util.parser.old.defs;
2
3import com.runehive.net.packet.out.SendMessage;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.skill.Skill;
6import com.runehive.game.world.items.SkillRequirement;
7import com.runehive.util.Utility;
8
9/**
10 * Represents the requirements for equipping items.
11 *
12 * @author Seven
13 */
15
16 /**
17 * Creates a new {@link EquipmentRequirement}.
18 *
19 * @param level
20 * The level required
21 *
22 * @param skill
23 * The skill required.
24 */
25 public EquipmentRequirement(int level, int skill) {
26 super(level, skill);
27 }
28
29 /**
30 * Determines if a player can equip a specified item.
31 *
32 * @param player
33 * The player that is equipping the item.
34 *
35 * @param itemId
36 * The id of the item to check.
37 */
38 public static boolean canEquip(Player player, int itemId) {
40 if (req == null) return true;
41
42 for (final SkillRequirement r : req.getRequirements()) {
43 if (r == null) continue;
44
45 if (player.skills.getMaxLevel(r.getSkill()) < r.getLevel()) {
46 player.send(new SendMessage("You need " + Utility.getAOrAn(Skill.getName(r.getSkill())) + " " + Skill.getName(r.getSkill()) + " level of " + r.getLevel() + " to equip this item."));
47 return false;
48 }
49 }
50 return true;
51 }
52
53}
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static String getName(int skill)
Gets the name for a skill id.
Definition Skill.java:465
int getMaxLevel(int id)
Gets the highest possible level of a skill.
final int level
The level that is required.
SkillRequirement(int level, int skill)
Creates a new SkillRequirement.
final int skill
The skill that is required.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String getAOrAn(String nextWord)
A or an.
Definition Utility.java:116
static final Map< Integer, EquipmentDefinition > EQUIPMENT_DEFINITIONS
EquipmentRequirement(int level, int skill)
Creates a new EquipmentRequirement.
static boolean canEquip(Player player, int itemId)
Determines if a player can equip a specified item.