com.realtime.crossfire.jxclient.stats
Class ExperienceTable

java.lang.Object
  extended by com.realtime.crossfire.jxclient.stats.ExperienceTable

public class ExperienceTable
extends java.lang.Object

Stores experience <-> level mappings.


Field Summary
private  CrossfireExpTableListener crossfireExpTableListener
          The CrossfireExpTableListener to receive updated experience tables.
private  java.util.Map<java.lang.Integer,java.lang.Long> info
          Maps level to experience needed to reach the level.
private  int maxLevel
          The maximum level value in info.
private  int minLevel
          The minimum level value in info.
 
Constructor Summary
ExperienceTable(CrossfireServerConnection crossfireServerConnection)
          Creates a new instance.
 
Method Summary
private  void add(int level, long exp)
          Add a new level->experience mapping.
private  void clear()
          Forget about all level-$> mappings.
private  long getExperience(int level)
          Return the experience needed for a given level.
 long getExperienceToNextLevel(int currentLevel, long currentExp)
          Return the experience needed to reach the next level.
 int getPercentsToNextLevel(int currentLevel, long currentExp)
          Return the experience fraction of the current level in percents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

crossfireExpTableListener

@NotNull
private final CrossfireExpTableListener crossfireExpTableListener
The CrossfireExpTableListener to receive updated experience tables.


info

@NotNull
private final java.util.Map<java.lang.Integer,java.lang.Long> info
Maps level to experience needed to reach the level.


maxLevel

private int maxLevel
The maximum level value in info.


minLevel

private int minLevel
The minimum level value in info.

Constructor Detail

ExperienceTable

public ExperienceTable(@NotNull
                       CrossfireServerConnection crossfireServerConnection)
Creates a new instance.

Parameters:
crossfireServerConnection - the connection to monitor
Method Detail

add

private void add(int level,
                 long exp)
Add a new level->experience mapping.

Parameters:
level - The level to update.
exp - The experience needed to reach level level.

clear

private void clear()
Forget about all level-$> mappings.


getExperience

private long getExperience(int level)
Return the experience needed for a given level.

Parameters:
level - The level to reach.
Returns:
The needed experience.

getExperienceToNextLevel

public long getExperienceToNextLevel(int currentLevel,
                                     long currentExp)
Return the experience needed to reach the next level.

Parameters:
currentLevel - The current level.
currentExp - The current experience.
Returns:
The experience to reach level currentLevel+1.

getPercentsToNextLevel

public int getPercentsToNextLevel(int currentLevel,
                                  long currentExp)
Return the experience fraction of the current level in percents. The value starts at 0% when a new level has been gained; the next level is at 100%.

Parameters:
currentLevel - The current level.
currentExp - The current experience.
Returns:
The experience fraction.