Class Experience


  • public class Experience
    extends java.lang.Object
    A utility class used for calculating experience related values.

    Skill levels calculated and handled by this class are within (inclusive) the range 1-126 rather than 1-99 to account for virtual levels obtained when reaching the 200M experience limit.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_COMBAT_LEVEL
      The maximum possible combat level.
      static int MAX_REAL_LEVEL
      Maximum effective skill level at 13,034,431 experience.
      static int MAX_SKILL_XP  
      static int MAX_VIRT_LEVEL
      The maximum virtual skill level for any skill (200M experience).
    • Constructor Summary

      Constructors 
      Constructor Description
      Experience()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int getCombatLevel​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculates a regular combat level.
      static double getCombatLevelPrecise​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculates a non-virtual high-precision combat level without integer rounding.
      static int getLevelForXp​(int xp)
      Gets the skill level for the passed total experience.
      static int getNextCombatLevelHpDef​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculate number of hitpoints/defence levels required to increase combat level.
      static int getNextCombatLevelMagic​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculate number of magic levels required to increase combat level.
      static int getNextCombatLevelMelee​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculate number of attack/strength levels required to increase combat level.
      static int getNextCombatLevelPrayer​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculate number of prayer levels required to increase combat level.
      static int getNextCombatLevelRange​(int attackLevel, int strengthLevel, int defenceLevel, int hitpointsLevel, int magicLevel, int rangeLevel, int prayerLevel)
      Calculate number of ranged levels required to increase combat level.
      static int getXpForLevel​(int level)
      Gets the total experience required to obtain the passed skill level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_REAL_LEVEL

        public static final int MAX_REAL_LEVEL
        Maximum effective skill level at 13,034,431 experience.
        See Also:
        Constant Field Values
      • MAX_VIRT_LEVEL

        public static final int MAX_VIRT_LEVEL
        The maximum virtual skill level for any skill (200M experience).
        See Also:
        Constant Field Values
      • MAX_COMBAT_LEVEL

        public static final int MAX_COMBAT_LEVEL
        The maximum possible combat level.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Experience

        public Experience()
    • Method Detail

      • getXpForLevel

        public static int getXpForLevel​(int level)
        Gets the total experience required to obtain the passed skill level.
        Parameters:
        level - the skill level
        Returns:
        the required experience for the level
        Throws:
        java.lang.IllegalArgumentException - if skill level is invalid
      • getLevelForXp

        public static int getLevelForXp​(int xp)
        Gets the skill level for the passed total experience.
        Parameters:
        xp - the passed experience (non-negative)
        Returns:
        the skill level
      • getCombatLevelPrecise

        public static double getCombatLevelPrecise​(int attackLevel,
                                                   int strengthLevel,
                                                   int defenceLevel,
                                                   int hitpointsLevel,
                                                   int magicLevel,
                                                   int rangeLevel,
                                                   int prayerLevel)
        Calculates a non-virtual high-precision combat level without integer rounding.

        Combat levels range between 1.15 and ~126.1.

        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the non-virtual combat level
      • getCombatLevel

        public static int getCombatLevel​(int attackLevel,
                                         int strengthLevel,
                                         int defenceLevel,
                                         int hitpointsLevel,
                                         int magicLevel,
                                         int rangeLevel,
                                         int prayerLevel)
        Calculates a regular combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the combat level, rounded down
      • getNextCombatLevelMelee

        public static int getNextCombatLevelMelee​(int attackLevel,
                                                  int strengthLevel,
                                                  int defenceLevel,
                                                  int hitpointsLevel,
                                                  int magicLevel,
                                                  int rangeLevel,
                                                  int prayerLevel)
        Calculate number of attack/strength levels required to increase combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the number of levels required
      • getNextCombatLevelHpDef

        public static int getNextCombatLevelHpDef​(int attackLevel,
                                                  int strengthLevel,
                                                  int defenceLevel,
                                                  int hitpointsLevel,
                                                  int magicLevel,
                                                  int rangeLevel,
                                                  int prayerLevel)
        Calculate number of hitpoints/defence levels required to increase combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the number of levels required
      • getNextCombatLevelMagic

        public static int getNextCombatLevelMagic​(int attackLevel,
                                                  int strengthLevel,
                                                  int defenceLevel,
                                                  int hitpointsLevel,
                                                  int magicLevel,
                                                  int rangeLevel,
                                                  int prayerLevel)
        Calculate number of magic levels required to increase combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the number of levels required
      • getNextCombatLevelRange

        public static int getNextCombatLevelRange​(int attackLevel,
                                                  int strengthLevel,
                                                  int defenceLevel,
                                                  int hitpointsLevel,
                                                  int magicLevel,
                                                  int rangeLevel,
                                                  int prayerLevel)
        Calculate number of ranged levels required to increase combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the number of levels required
      • getNextCombatLevelPrayer

        public static int getNextCombatLevelPrayer​(int attackLevel,
                                                   int strengthLevel,
                                                   int defenceLevel,
                                                   int hitpointsLevel,
                                                   int magicLevel,
                                                   int rangeLevel,
                                                   int prayerLevel)
        Calculate number of prayer levels required to increase combat level.
        Parameters:
        attackLevel - the attack level
        strengthLevel - the strength level
        defenceLevel - the defence level
        hitpointsLevel - the hitpoints level
        magicLevel - the magic level
        rangeLevel - the range level
        prayerLevel - the prayer level
        Returns:
        the number of levels required