com.realtime.crossfire.jxclient.stats
Class Stats

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

public class Stats
extends java.lang.Object

This is the representation of all the statistics of a player, like its speed or its experience.

Constants named C_STAT_xxx are client-sided; constants named CS_STAT_xxx are stats as sent by the server.


Field Summary
private  java.lang.String activeSkill
          The active skill name.
private  CrossfireStatsListener crossfireStatsListener
          The CrossfireStatsListener attached to the server connection for detecting stat changes.
private  long exp
          The total experience.
private  ExperienceTable experienceTable
          The ExperienceTable instance to use.
private  long expNextLevel
          The experience needed to reach the next level.
private  GuiStateListener guiStateListener
          The GuiStateListener for detecting established or dropped connections.
private  java.lang.String range
          The current value of the range stat.
private  boolean simpleWeaponSpeed
          Whether the CrossfireStatsListener.CS_STAT_WEAP_SP value contains the weapon speed directly.
private  SkillSet skillSet
          The SkillSet instance to use.
private  int[] stats
          The current stat values.
private  java.util.Collection<StatsListener> statsListeners
          The listeners to inform of stat changes.
private  java.lang.String title
          The current value of the title stat.
 
Constructor Summary
Stats(CrossfireServerConnection crossfireServerConnection, ExperienceTable experienceTable, SkillSet skillSet, GuiStateManager guiStateManager)
          Creates a new instance.
 
Method Summary
 void addCrossfireStatsListener(StatsListener statsListener)
          Adds a StatsListener to be notified about stat changes.
private  void calculateExperienceToNextLevel()
          Calculates experience needed to reach the next level.
 java.lang.String getActiveSkill()
          Returns the active skill name.
 long getExperience()
          Returns the amount of global experience.
 long getExperienceNextLevel()
          Returns the experience needed to reach the next level.
 double getFloatStat(int statNo)
          Returns the numerical value of the given statistic.
 java.lang.String getRange()
          Returns the current content of the range stat.
 int getStat(int statNo)
          Returns the numerical value of the given statistic.
 java.lang.String getTitle()
          Returns the current title.
 double getWeaponSpeed()
          Returns the weapon speed stat.
 void removeCrossfireStatsListener(StatsListener statsListener)
          Removes a StatsListener to be notified about stat changes.
private  void reset()
          Forgets about all stats.
 void setActiveSkill(java.lang.String activeSkill)
          Sets the active skill name.
private  void setExperience(long exp)
          Sets the amount of global experience.
private  void setRange(java.lang.String range)
          Sets the current value for the Range - this is basically the currently active skill for the player.
private  void setSimpleWeaponSpeed(boolean simpleWeaponSpeed)
          Sets whether the CrossfireStatsListener.CS_STAT_WEAP_SP value contains the weapon speed directly.
 void setStat(int statNo, int value)
          Sets the given statistic numerical value.
private  void setTitle(java.lang.String title)
          Sets the current Title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeSkill

@NotNull
private java.lang.String activeSkill
The active skill name.


crossfireStatsListener

@NotNull
private final CrossfireStatsListener crossfireStatsListener
The CrossfireStatsListener attached to the server connection for detecting stat changes.


exp

private long exp
The total experience.


experienceTable

@NotNull
private final ExperienceTable experienceTable
The ExperienceTable instance to use.


expNextLevel

private long expNextLevel
The experience needed to reach the next level.


guiStateListener

@NotNull
private final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.


range

@NotNull
private java.lang.String range
The current value of the range stat.


simpleWeaponSpeed

private boolean simpleWeaponSpeed
Whether the CrossfireStatsListener.CS_STAT_WEAP_SP value contains the weapon speed directly.


skillSet

@NotNull
private final SkillSet skillSet
The SkillSet instance to use.


stats

@NotNull
private final int[] stats
The current stat values.


statsListeners

@NotNull
private final java.util.Collection<StatsListener> statsListeners
The listeners to inform of stat changes.


title

@NotNull
private java.lang.String title
The current value of the title stat.

Constructor Detail

Stats

public Stats(@NotNull
             CrossfireServerConnection crossfireServerConnection,
             @NotNull
             ExperienceTable experienceTable,
             @NotNull
             SkillSet skillSet,
             @NotNull
             GuiStateManager guiStateManager)
Creates a new instance.

Parameters:
crossfireServerConnection - the connection to monitor
experienceTable - the experience table instance to use
skillSet - the skill set instance to use
guiStateManager - the gui state manager to watch
Method Detail

addCrossfireStatsListener

public void addCrossfireStatsListener(@NotNull
                                      StatsListener statsListener)
Adds a StatsListener to be notified about stat changes.

Parameters:
statsListener - the listener to add

calculateExperienceToNextLevel

private void calculateExperienceToNextLevel()
Calculates experience needed to reach the next level.


getActiveSkill

@NotNull
public java.lang.String getActiveSkill()
Returns the active skill name.

Returns:
the active skill name

getExperience

public long getExperience()
Returns the amount of global experience.

Returns:
Amount of global experience.

getExperienceNextLevel

public long getExperienceNextLevel()
Returns the experience needed to reach the next level.

Returns:
the experience needed

getFloatStat

public double getFloatStat(int statNo)
Returns the numerical value of the given statistic.

Parameters:
statNo - the stat identifier. See the CS_STAT constants
Returns:
the statistic value

getRange

@NotNull
public java.lang.String getRange()
Returns the current content of the range stat. This is basically the current active skill for the player.

Returns:
a String representation of the range

getStat

public int getStat(int statNo)
Returns the numerical value of the given statistic.

Parameters:
statNo - the stat identifier. See the CS_STAT constants
Returns:
the statistic value (or "score")

getTitle

@NotNull
public java.lang.String getTitle()
Returns the current title.

Returns:
a String representation of the title

getWeaponSpeed

public double getWeaponSpeed()
Returns the weapon speed stat.

Returns:
the weapon speed stat

removeCrossfireStatsListener

public void removeCrossfireStatsListener(@NotNull
                                         StatsListener statsListener)
Removes a StatsListener to be notified about stat changes.

Parameters:
statsListener - the listener to remove

reset

private void reset()
Forgets about all stats.


setActiveSkill

public void setActiveSkill(@NotNull
                           java.lang.String activeSkill)
Sets the active skill name.

Parameters:
activeSkill - the active skill name

setExperience

private void setExperience(long exp)
Sets the amount of global experience.

Parameters:
exp - The new amount of global experience.

setRange

private void setRange(@NotNull
                      java.lang.String range)
Sets the current value for the Range - this is basically the currently active skill for the player.

Parameters:
range - the new content of range

setSimpleWeaponSpeed

private void setSimpleWeaponSpeed(boolean simpleWeaponSpeed)
Sets whether the CrossfireStatsListener.CS_STAT_WEAP_SP value contains the weapon speed directly.

Parameters:
simpleWeaponSpeed - whether CS_STAT_WEAP_SP is the weapon speed value

setStat

public void setStat(int statNo,
                    int value)
Sets the given statistic numerical value.

Parameters:
statNo - the stat identifier. See the CS_STAT constants
value - the value to assign to the chosen statistic

setTitle

private void setTitle(@NotNull
                      java.lang.String title)
Sets the current Title.

Parameters:
title - the new Title content