1package com.runehive.game.world.entity.skill;
3import com.runehive.content.event.EventDispatcher;
4import com.runehive.content.event.InteractionEvent;
5import com.runehive.content.event.InteractionEvent.InteractionType;
6import com.runehive.content.event.InteractionEventListener;
7import com.runehive.content.event.impl.*;
8import com.runehive.game.world.entity.mob.player.Player;
9import com.runehive.util.Stopwatch;
11import java.util.function.Function;
39 public static final int MAGIC = 6;
127 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107,
128 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740,
129 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
130 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014,
131 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466,
132 247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032,
133 668051, 737627, 814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,
134 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597792,
135 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614, 8771558,
136 9684577, 10692629, 11805606, 13034431
271 return this.level >=
level;
295 public void modifyLevel(Function<Integer, Integer>
function,
int lowerBounds,
int upperBounds) {
301 if (
level < lowerBounds) {
305 if (
level > upperBounds) {
369 public double modifyExperience(Function<Double, Double>
function,
int lowerBounds,
int upperBounds) {
433 int mid = (min + max) / 2;
439 return (
byte) (mid + 1);
470 public static Function<Integer, Integer>
add(
int amount) {
475 public static Function<Integer, Integer>
subtract(
int amount) {
480 public static Function<Integer, Integer>
multiply(
double amount) {
485 public static Function<Integer, Integer>
divide(
double amount) {
486 return level -> amount == 0 ? 0 : (int) (
level / amount);
void dispatch(InteractionType type, EventHandler eventHandler)
This class represents a character controlled by a player.
static final String[] SKILL_NAMES
An array of skill names.
static Function< Integer, Integer > add(int amount)
Creates a function that adds a number by an amount.
void removeExperience(double amount)
Removes experiences from this skill by the given amount.
void modifyLevel(Function< Integer, Integer > function, int lowerBounds, int upperBounds)
Modifies the current level with a given function.
static final int TOTAL_SKILL_LEVEL
The total skill amount.
static final int SLAYER
The slayer skill id.
boolean useItem(Player player, ItemOnItemInteractionEvent event)
static final int WOODCUTTING
The woodcutting skill id.
boolean itemContainerAction(Player player, ItemContainerInteractionEvent event)
boolean useItem(Player player, ItemOnObjectInteractionEvent event)
void multiplyLevel(double amount)
Multiplies the current level of this skill by a given amount.
static final int[] EXP_FOR_LEVEL
An array with the index being the skill level (from [0, 99]) and the value being the minimum experien...
final int skill
The skill id.
static String getName(int skill)
Gets the name for a skill id.
static final byte getLevelForExperience(double experience)
Gets the level for a given experience amount.
void divideExperience(double amount)
Divides the current experience of this skill by a given amount.
double experience
The current skill experience.
void modifyLevel(Function< Integer, Integer > function)
Modifies the current level with a given function.
void setMaxLevel(int maxLevel)
Sets the maximum level for this skill.
static final int PRAYER
The prayer skill id.
static final int RANGED
The ranged skill id.
void setExperience(double experience)
Sets the experience for this skill.
static final int CRAFTING
The crafting skill id.
static final int HERBLORE
The herblore skill id.
static final int SMITHING
The smithing skill id.
static final int FISHING
The fishing skill id.
static final int DEFENCE
The defence skill id.
static final int CONSTRUCTION
The construction skill id.
boolean clickItem(Player player, ItemInteractionEvent event)
static Function< Integer, Integer > divide(double amount)
Creates a function that divides a number by an amount.
boolean reqLevel(int level)
Determines if your level is greater than or equal to level.
double getExperience()
Gets the skill experience.
boolean onEvent(Player player, InteractionEvent interactionEvent)
static final int SKILL_COUNT
The amount of available skills.
int getLevel()
Gets the current skill level.
void setLevel(int level)
Sets the level for this skill.
void removeLevel(int amount)
Removes levels from this skill by the given amount.
static final int FLETCHING
The fletching skill id.
int level
The current level of the skill.
static final int FIREMAKING
The firemaking skill id.
static final int MAGIC
The magic skill id.
static final int[][] INTERFACE_DATA
Skill tab string data.
static final int ATTACK
The attack skill id.
static final int FARMING
The farming skill id.
static byte binarySearch(double experience, int min, int max)
Performs a binary search to quickly search for the level at the given experience.
static final int AGILITY
The agility skill id.
int getRoundedExperience()
Gets the floor experience.
static Function< Integer, Integer > subtract(int amount)
Creates a function that subtracts a number by an amount.
void multiplyExperience(double amount)
Multiplies the current experience of this skill by a given amount.
int maxLevel
The maximum level of the skill.
boolean clickNpc(Player player, NpcInteractionEvent event)
static final int THIEVING
The thieving skill id.
static final int HUNTER
The hunter skill id.
static final int STRENGTH
The strength skill id.
static final int COOKING
The cooking skill id.
static final int getExperienceForLevel(int level)
Gets the experience for a given level.
static final int MINING
The mining skill id.
transient final Stopwatch stopwatch
void addLevel(int amount)
Adds levels to this skill by the given amount.
double modifyExperience(Function< Double, Double > function, int lowerBounds, int upperBounds)
Modifies the current experience with a given function.
double modifyExperience(Function< Double, Double > function)
Modifies the current experience with a given function.
void setDoingSkill(boolean doingSkill)
double addExperience(double amount)
Adds experiences to this skill by the given amount.
static Function< Integer, Integer > multiply(double amount)
Creates a function that multiplies a number by an amount.
boolean clickObject(Player player, ObjectInteractionEvent event)
boolean clickButton(Player player, ClickButtonInteractionEvent event)
int getSkill()
Gets the skill id.
int getMaxLevel()
Gets the maximum skill level.
static final int HITPOINTS
The hitpoints skill id.
Skill(int skill, int level, double experience)
Constructs a new Skill.
static final int RUNECRAFTING
The runecrafting skill id.
void divideLevel(double amount)
Divides the current level of this skill by a given amount.
ITEM_CONTAINER_INTERACTION_EVENT