Alright, I got bored and this idea popped out of no where to me, not sure if i can see that its better, but yeah. im posting this for criticism
Code:
/**
* Enumeration containing xp rates of each skill
*
*/
enum SkillExperienceRates {
ATTACK(0, 10),
DEFENCE(1, 10),
STRENGTH(2, 10),
HITPOINTS(3, 10),
RANGE(4, 10),
PRAYER(5, 10),
MAGIC(6, 10),
COOKING(7, 10),
WOODCUTTING(8, 100),
FLETCHING(9, 10),
FISHING(10, 10),
FIREMAKING(11, 10),
CRAFTING(12, 10),
SMITHING(13, 10),
MINING(14, 10),
HERBLORE(15, 10),
AGILITY(16, 10),
THIEVING(17, 10),
SLAYER(18, 10),
FARMING(19, 10),
RUNECRAFTING(20, 10);
private int skillId, xpRate;
private SkillExperienceRates(final int skillId, final int xpRate) {
this.skillId = skillId;
this.xpRate = xpRate;
}
}
/**
* Determines and sends the xp rate of a skill
* @param i
* the skill
* @return
* the xp rate of the skill
*/
public static int getSkillXPRate(int i) {
for(SkillExperienceRates xpRates : SkillExperienceRates.values()) {
if (xpRates.skillId == i) {
return xpRates.xpRate;
}
}
return 0;
}
called like this, woodcutting as an example
Code:
getSkillXPRate(player.playerWoodcutting)
with a two dimensional array
Code:
/**
* Array containing skill exp rates
*/
private static int[][] SKILL_EXPERIENCE_RATES = {
{ 0, 50 }, { 1, 50 },
{ 2, 50 }, { 3, 50 },
{ 4, 50 }, { 5, 50 },
{ 6, 50 }, { 7, 50 },
{ 8, 50 }, { 9, 50 },
{ 10, 50 }, { 11, 50 },
{ 12, 50 }, { 13, 50 },
{ 14, 50 }, { 15, 50 },
{ 16, 50 }, { 17, 50 },
{ 18, 50 }, { 19, 50 },
{ 20, 50 }
};
/**
* Grabs the skill id of the skill from the array
* @param i
* the skill
* @return
* the skill id of the skill
*/
private static int getSkillId(int i) {
return SKILL_EXPERIENCE_RATES[i][0];
}
/**
* Grabs the exp rate of the skill from the array
* @param i
* the skill
* @return
* the exp rate of the skill
*/
private static int getExpRate(int i) {
return SKILL_EXPERIENCE_RATES[i][1];
}
/**
* Determines and sends the xp rate of a skill
* @param i
* the skill
* @return
* the xp rate of the skill
*/
public static int getSkillXPRate(int i) {
if (getSkillId(i) == i) {
return getExpRate(i);
}
return 0;
}