Jump to content

Get the total lvl


Recommended Posts

Posted (edited)

Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... 

int totalLevel = 0;

for( Skill skill : Skill.values() ){
	totalLevel += getSkills().getStatic(skill);
}

log("My total level is " + totalLevel); 

 

Edited by jca
Posted (edited)
2 hours ago, jca said:

Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... 


int totalLevel = -1;

for( Skill skill : Skill.values() ){
	totalLevel += getSkills().getStatic(skill);
}

log("My total level is " + totalLevel); 

 

 

That's going to be off by 1, totalLevel should be initialised to 0

Alternative using streams:
 

int totalLevel = Arrays.stream(Skill.values())
                       .mapToInt(skill -> getSkills().getStatic(skill))
                       .sum();



 

Edited by Explv
  • Like 3
Posted (edited)
2 hours ago, liverare said:

*ahem* getSkills()::getStatic

*drops mic*

 

Now for the true s3 way to do it

private final static int MAX_TOTAL_LEVEL = 2277;

public int getTotalLevel(){

  int totalLevel = MAX_TOTAL_LEVEL;
  for(int i = 0; i < Skill.values().length; i++){
      totalLevel -= 99 - getSkills().getStatic(Skill.values()[i]);  
  }
  
  return totalLevel;
}

I'll see myself out, selling private scripts

Edited by Tom
  • Like 2
  • Boge 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...