Thread: [PI] Better Way To Handle XP Rates?

Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1 [PI] Better Way To Handle XP Rates? 
    Registered Member
    Join Date
    Sep 2013
    Posts
    882
    Thanks given
    43
    Thanks received
    57
    Rep Power
    58
    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;
    	}
    Reply With Quote  
     

  2. #2  
    Best Hybrid Alive
    Almagesrnubs's Avatar
    Join Date
    Nov 2009
    Posts
    884
    Thanks given
    443
    Thanks received
    261
    Rep Power
    114
    Good job on this buddy.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Karma_K's Avatar
    Join Date
    Nov 2012
    Posts
    4,287
    Thanks given
    152
    Thanks received
    610
    Rep Power
    108
    Quote Originally Posted by Almagesrnubs View Post
    Good job on this buddy.
    Would this be better vs pis original way with an integer declared for each skill?
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Nov 2011
    Posts
    276
    Thanks given
    60
    Thanks received
    5
    Rep Power
    22
    Quote Originally Posted by Karma_K View Post
    Would this be better vs pis original way with an integer declared for each skill?
    if there is an integer declared for each skill then i believe this would be better, but i'm not 100% sure
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Dec 2012
    Posts
    12
    Thanks given
    1
    Thanks received
    2
    Rep Power
    38
    It's a good idea but it'd be pretty pointless. PI being as shite as it already is, defining the exp rates this way would just complicate such a menial task, and if anything, would impact the performance due to the extra method calls on each exp gain (though probably unnoticable). Not saying it doesn't look neater than just a fat block of integer definitions though, good job anyway.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Sep 2013
    Posts
    882
    Thanks given
    43
    Thanks received
    57
    Rep Power
    58
    Quote Originally Posted by AwaitingValhalla View Post
    It's a good idea but it'd be pretty pointless. PI being as shite as it already is, defining the exp rates this way would just complicate such a menial task, and if anything, would impact the performance due to the extra method calls on each exp gain (though probably unnoticable). Not saying it doesn't look neater than just a fat block of integer definitions though, good job anyway.
    thats what i thought aswell, hence why i asked
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Spoiler for wasn't thinking:
    Sure, you can store it like this, though it shouldn't make a big difference, and quiet frankly happens to be a waste of your time. I mean if you wanted to organize it, you could use a HashMap<Integer, Integer> or a list List<Integer>

    E.G.

    Code:
    LinkedList<Integer> xpRates = new LinkedList<Integer>(Arrays.asList(new int[]{rate1, rate2, rate3....}));
    And since skills go from 0-20something, you can just use it like

    xpRates.get(i);


    NVM, you could just as effectively use an array or a map
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Nov 2013
    Posts
    28
    Thanks given
    7
    Thanks received
    2
    Rep Power
    11
    By no means better, more memory consumption.
    Brilliance. In every carbon based atom, molecule, and living being.
    Reply With Quote  
     

  9. #9  
    Donator

    Arithium's Avatar
    Join Date
    May 2010
    Age
    28
    Posts
    4,758
    Thanks given
    199
    Thanks received
    1,256
    Rep Power
    1114
    Instead of declaring a skill Id just use xpRates.ordinal()
    Reply With Quote  
     

  10. #10  
    Theory Wins?
    Greyfield's Avatar
    Join Date
    Nov 2008
    Age
    29
    Posts
    1,585
    Thanks given
    61
    Thanks received
    265
    Rep Power
    310
    What's the point of giving a skill their own base experience rate? Just have one global base rate and modify it accordingly in the actual skill. And as someone already said, if you're going to use the enumeration like this, you should use the ordinal() method. But for something like this you'd be better off just using an array, which either way you use is still completely pointless in my own opinion. However, everyone is subject to their own opinion and if others find this useful than so be it.



    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Better way to handle quest and there stages
    By Purple Helix in forum Snippets
    Replies: 8
    Last Post: 08-29-2013, 09:50 PM
  2. [667/***] Better way to handle staff
    By asteria-X in forum Tutorials
    Replies: 24
    Last Post: 07-19-2012, 03:18 AM
  3. 562 Better way to handle overloads
    By Makar in forum Snippets
    Replies: 17
    Last Post: 11-01-2011, 10:16 PM
  4. [PI or others] Better way of handling commands
    By wakadoodle in forum Snippets
    Replies: 2
    Last Post: 07-26-2011, 09:41 PM
  5. PI Range much better way to calc hits?
    By Spooky in forum Help
    Replies: 1
    Last Post: 08-01-2010, 05:24 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •