Class Stats
- java.lang.Object
-
- com.realtime.crossfire.jxclient.stats.Stats
-
public class Stats extends java.lang.ObjectThis is the representation of all the statistics of a player, like its speed or its experience.Constants named
C_STAT_xxxare client-sided; * constants namedCS_STAT_xxxare stats as sent by the server.
-
-
Field Summary
Fields Modifier and Type Field Description static intC_STAT_EXP_NEXT_LEVELThe global experience needed to reach next level stat.static intC_STAT_LOWFOODThe Low Food indicator.static intC_STAT_POISONEDThe "is poisoned" indicator.static intC_STAT_WEIGHTThe character's weight.static intCS_NUM_SKILLSCS_NUM_SKILLS does not match how many skills there really are - instead, it is used as a range of values so that the client can have some idea how many skill categories there may be.static intCS_STAT_ACThe Armor Class stat.static intCS_STAT_APPLIED_CHAThe charisma primary stat changes due to gear or skills.static intCS_STAT_APPLIED_CONThe constitution primary stat changes due to gear or skills.static intCS_STAT_APPLIED_DEXThe dexterity primary stat changes due to gear or skills.static intCS_STAT_APPLIED_INTThe integer primary stat changes due to gear or skills.static intCS_STAT_APPLIED_POWThe power primary stat changes due to gear or skills.static intCS_STAT_APPLIED_STRThe strength primary stat changes due to gear or skills.static intCS_STAT_APPLIED_WISThe wisdom primary stat changes due to gear or skills.static intCS_STAT_ARMOURThe Armour stat.static intCS_STAT_BASE_CHAThe charisma primary stat without boosts or depletions.static intCS_STAT_BASE_CONThe constitution primary stat without boosts or depletions.static intCS_STAT_BASE_DEXThe dexterity primary stat without boosts or depletions.static intCS_STAT_BASE_INTThe integer primary stat without boosts or depletions.static intCS_STAT_BASE_POWThe power primary stat without boosts or depletions.static intCS_STAT_BASE_STRThe strength primary stat without boosts or depletions.static intCS_STAT_BASE_WISThe wisdom primary stat without boosts or depletions.static intCS_STAT_CHAThe Charisma Primary stat.static intCS_STAT_CONThe Constitution Primary stat.static intCS_STAT_DAMThe Damage stat.static intCS_STAT_DEXThe Dexterity Primary stat.static intCS_STAT_EXPThe Global Experience (32bit encoding) stat.static intCS_STAT_EXP64The Global Experience (64bit encoding) stat.static intCS_STAT_FLAGSThe various flags used in stats.static intCS_STAT_FOODThe Food stat.static intCS_STAT_GOLEM_HPThe golem's hitpoints, 0 if no golem.static intCS_STAT_GOLEM_MAXHPThe golem's maximum hitpoints, 0 if no golem.static intCS_STAT_GRACEThe Grace stat.static intCS_STAT_HPThe Hit Points stat.static intCS_STAT_INTThe Intelligence Primary stat.static intCS_STAT_LEVELThe Global Level stat.static intCS_STAT_MAXGRACEThe Maximum Grace stat.static intCS_STAT_MAXHPThe Maximum Hit Points stat.static intCS_STAT_MAXSPThe Maximum Spell Points stat.static intCS_STAT_POWThe Power Primary stat.static intCS_STAT_RACE_CHAThe race's maximum charisma primary stat.static intCS_STAT_RACE_CONThe race's maximum constitution primary stat.static intCS_STAT_RACE_DEXThe race's maximum dexterity primary stat.static intCS_STAT_RACE_INTThe race's maximum intelligence primary stat.static intCS_STAT_RACE_POWThe race's maximum power primary stat.static intCS_STAT_RACE_STRThe race's maximum strength primary stat.static intCS_STAT_RACE_WISThe race's maximum wisdom primary stat.static intCS_STAT_RANGEThe Range stat - this is what is currently readied by the player to fire.static intCS_STAT_RES_ACIDResistance to acid.static intCS_STAT_RES_BLINDResistance to blindness.static intCS_STAT_RES_COLDResistance to cold.static intCS_STAT_RES_CONFResistance to confusion.static intCS_STAT_RES_DEATHResistance to death.static intCS_STAT_RES_DEPLETEResistance to depletion.static intCS_STAT_RES_DRAINResistance to drain life.static intCS_STAT_RES_ELECResistance to electricity.static intCS_STAT_RES_FEARResistance to fear.static intCS_STAT_RES_FIREResistance to fire.static intCS_STAT_RES_GHOSTHITResistance to ghost hit.static intCS_STAT_RES_HOLYWORDResistance to holy word.static intCS_STAT_RES_MAGResistance to magical attacks.static intCS_STAT_RES_PARAResistance to paralysis.static intCS_STAT_RES_PHYSResistance to physical attacks.static intCS_STAT_RES_POISONResistance to poison.static intCS_STAT_RES_SLOWResistance to slowness.static intCS_STAT_RES_TURN_UNDEADResistance to turn undead.static intCS_STAT_RESIST_ENDEnd index of the resistances.static intCS_STAT_RESIST_STARTBeginning index of the resistances.static intCS_STAT_SKILLINFOCS_STAT_SKILLINFO is used as the starting index point.static intCS_STAT_SPThe Spell Points stat.static intCS_STAT_SPEEDThe Speed stat.static intCS_STAT_SPELL_ATTUNEAttuned spell paths of a spell.static intCS_STAT_SPELL_DENYDenied spell paths of a spell.static intCS_STAT_SPELL_REPELRepelled spell paths of a spell.static intCS_STAT_STRThe Strength Primary stat.static intCS_STAT_TITLEThe Title stat.static intCS_STAT_WCThe Weapon Class stat.static intCS_STAT_WEAP_SPThe Weapon Speed stat.static intCS_STAT_WEIGHT_LIMThe Weight Limit stat.static intCS_STAT_WISThe Wisdom Primary stat.static intFLOAT_MULTIFactor used to convert float to int values.static intRESIST_TYPESThe total number of resistances.
-
Constructor Summary
Constructors Constructor Description Stats(@NotNull ExperienceTable experienceTable, @NotNull SkillSet skillSet, @NotNull GuiStateManager guiStateManager)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCrossfireStatsListener(@NotNull StatsListener statsListener)Adds aStatsListenerto be notified about stat changes.@NotNull java.lang.StringgetActiveSkill()Returns the active skill name.longgetExperience()Returns the amount of global experience.longgetExperienceNextLevel()Returns the experience needed to reach the next level.doublegetFloatStat(int statNo)Returns the numerical value of the given statistic.@NotNull java.lang.StringgetRange()Returns the current content of the range stat.intgetStat(int statNo)Returns the numerical value of the given statistic.@NotNull java.lang.StringgetTitle()Returns the current title.doublegetWeaponSpeed()Returns the weapon speed stat.voidremoveCrossfireStatsListener(@NotNull StatsListener statsListener)Removes aStatsListenerto be notified about stat changes.voidsetActiveSkill(@NotNull java.lang.String activeSkill)Sets the active skill name.voidsetSimpleWeaponSpeed(boolean simpleWeaponSpeed)Sets whether theCS_STAT_WEAP_SPvalue contains the weapon speed directly.voidsetStat(int statNo, int value)Sets the given statistic numerical value.voidsetStatInt2(int stat, short param)Updates a stat value with a two-byte int value.voidsetStatInt4(int stat, int param)Updates a stat value with a four-byte int value.voidsetStatInt8(int stat, long param)Updates a stat value with an eight-byte int value.voidsetStatSkill(int stat, int level, long experience)Updates a stat value with a skill value.voidsetStatString(int stat, @NotNull java.lang.String param)Updates a stat value with a string value.
-
-
-
Field Detail
-
CS_STAT_HP
public static final int CS_STAT_HP
The Hit Points stat.- See Also:
- Constant Field Values
-
CS_STAT_MAXHP
public static final int CS_STAT_MAXHP
The Maximum Hit Points stat.- See Also:
- Constant Field Values
-
CS_STAT_SP
public static final int CS_STAT_SP
The Spell Points stat.- See Also:
- Constant Field Values
-
CS_STAT_MAXSP
public static final int CS_STAT_MAXSP
The Maximum Spell Points stat.- See Also:
- Constant Field Values
-
CS_STAT_STR
public static final int CS_STAT_STR
The Strength Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_INT
public static final int CS_STAT_INT
The Intelligence Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_WIS
public static final int CS_STAT_WIS
The Wisdom Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_DEX
public static final int CS_STAT_DEX
The Dexterity Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_CON
public static final int CS_STAT_CON
The Constitution Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_CHA
public static final int CS_STAT_CHA
The Charisma Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_EXP
public static final int CS_STAT_EXP
The Global Experience (32bit encoding) stat.- See Also:
- Constant Field Values
-
C_STAT_EXP_NEXT_LEVEL
public static final int C_STAT_EXP_NEXT_LEVEL
The global experience needed to reach next level stat.- See Also:
- Constant Field Values
-
CS_STAT_LEVEL
public static final int CS_STAT_LEVEL
The Global Level stat.- See Also:
- Constant Field Values
-
CS_STAT_WC
public static final int CS_STAT_WC
The Weapon Class stat.- See Also:
- Constant Field Values
-
CS_STAT_AC
public static final int CS_STAT_AC
The Armor Class stat.- See Also:
- Constant Field Values
-
CS_STAT_DAM
public static final int CS_STAT_DAM
The Damage stat.- See Also:
- Constant Field Values
-
CS_STAT_ARMOUR
public static final int CS_STAT_ARMOUR
The Armour stat.- See Also:
- Constant Field Values
-
CS_STAT_SPEED
public static final int CS_STAT_SPEED
The Speed stat.- See Also:
- Constant Field Values
-
CS_STAT_FOOD
public static final int CS_STAT_FOOD
The Food stat.- See Also:
- Constant Field Values
-
C_STAT_LOWFOOD
public static final int C_STAT_LOWFOOD
The Low Food indicator. It ranges from 0 (ok) to 1 (low food).- See Also:
- Constant Field Values
-
CS_STAT_WEAP_SP
public static final int CS_STAT_WEAP_SP
The Weapon Speed stat.- See Also:
- Constant Field Values
-
CS_STAT_RANGE
public static final int CS_STAT_RANGE
The Range stat - this is what is currently readied by the player to fire.- See Also:
- Constant Field Values
-
CS_STAT_TITLE
public static final int CS_STAT_TITLE
The Title stat.- See Also:
- Constant Field Values
-
CS_STAT_POW
public static final int CS_STAT_POW
The Power Primary stat.- See Also:
- Constant Field Values
-
CS_STAT_GRACE
public static final int CS_STAT_GRACE
The Grace stat.- See Also:
- Constant Field Values
-
CS_STAT_MAXGRACE
public static final int CS_STAT_MAXGRACE
The Maximum Grace stat.- See Also:
- Constant Field Values
-
CS_STAT_FLAGS
public static final int CS_STAT_FLAGS
The various flags used in stats.- See Also:
- Constant Field Values
-
CS_STAT_WEIGHT_LIM
public static final int CS_STAT_WEIGHT_LIM
The Weight Limit stat.- See Also:
- Constant Field Values
-
C_STAT_WEIGHT
public static final int C_STAT_WEIGHT
The character's weight.- See Also:
- Constant Field Values
-
CS_STAT_EXP64
public static final int CS_STAT_EXP64
The Global Experience (64bit encoding) stat.- See Also:
- Constant Field Values
-
CS_STAT_SPELL_ATTUNE
public static final int CS_STAT_SPELL_ATTUNE
Attuned spell paths of a spell.- See Also:
- Constant Field Values
-
CS_STAT_SPELL_REPEL
public static final int CS_STAT_SPELL_REPEL
Repelled spell paths of a spell.- See Also:
- Constant Field Values
-
CS_STAT_SPELL_DENY
public static final int CS_STAT_SPELL_DENY
Denied spell paths of a spell.- See Also:
- Constant Field Values
-
CS_STAT_RACE_STR
public static final int CS_STAT_RACE_STR
The race's maximum strength primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_INT
public static final int CS_STAT_RACE_INT
The race's maximum intelligence primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_WIS
public static final int CS_STAT_RACE_WIS
The race's maximum wisdom primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_DEX
public static final int CS_STAT_RACE_DEX
The race's maximum dexterity primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_CON
public static final int CS_STAT_RACE_CON
The race's maximum constitution primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_CHA
public static final int CS_STAT_RACE_CHA
The race's maximum charisma primary stat.- See Also:
- Constant Field Values
-
CS_STAT_RACE_POW
public static final int CS_STAT_RACE_POW
The race's maximum power primary stat.- See Also:
- Constant Field Values
-
CS_STAT_BASE_STR
public static final int CS_STAT_BASE_STR
The strength primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_INT
public static final int CS_STAT_BASE_INT
The integer primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_WIS
public static final int CS_STAT_BASE_WIS
The wisdom primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_DEX
public static final int CS_STAT_BASE_DEX
The dexterity primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_CON
public static final int CS_STAT_BASE_CON
The constitution primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_CHA
public static final int CS_STAT_BASE_CHA
The charisma primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_BASE_POW
public static final int CS_STAT_BASE_POW
The power primary stat without boosts or depletions.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_STR
public static final int CS_STAT_APPLIED_STR
The strength primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_INT
public static final int CS_STAT_APPLIED_INT
The integer primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_WIS
public static final int CS_STAT_APPLIED_WIS
The wisdom primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_DEX
public static final int CS_STAT_APPLIED_DEX
The dexterity primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_CON
public static final int CS_STAT_APPLIED_CON
The constitution primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_CHA
public static final int CS_STAT_APPLIED_CHA
The charisma primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_APPLIED_POW
public static final int CS_STAT_APPLIED_POW
The power primary stat changes due to gear or skills.- See Also:
- Constant Field Values
-
CS_STAT_GOLEM_HP
public static final int CS_STAT_GOLEM_HP
The golem's hitpoints, 0 if no golem.- See Also:
- Constant Field Values
-
CS_STAT_GOLEM_MAXHP
public static final int CS_STAT_GOLEM_MAXHP
The golem's maximum hitpoints, 0 if no golem.- See Also:
- Constant Field Values
-
CS_STAT_RESIST_START
public static final int CS_STAT_RESIST_START
Beginning index of the resistances.- See Also:
- Constant Field Values
-
CS_STAT_RESIST_END
public static final int CS_STAT_RESIST_END
End index of the resistances.- See Also:
- Constant Field Values
-
CS_STAT_RES_PHYS
public static final int CS_STAT_RES_PHYS
Resistance to physical attacks.- See Also:
- Constant Field Values
-
CS_STAT_RES_MAG
public static final int CS_STAT_RES_MAG
Resistance to magical attacks.- See Also:
- Constant Field Values
-
CS_STAT_RES_FIRE
public static final int CS_STAT_RES_FIRE
Resistance to fire.- See Also:
- Constant Field Values
-
CS_STAT_RES_ELEC
public static final int CS_STAT_RES_ELEC
Resistance to electricity.- See Also:
- Constant Field Values
-
CS_STAT_RES_COLD
public static final int CS_STAT_RES_COLD
Resistance to cold.- See Also:
- Constant Field Values
-
CS_STAT_RES_CONF
public static final int CS_STAT_RES_CONF
Resistance to confusion.- See Also:
- Constant Field Values
-
CS_STAT_RES_ACID
public static final int CS_STAT_RES_ACID
Resistance to acid.- See Also:
- Constant Field Values
-
CS_STAT_RES_DRAIN
public static final int CS_STAT_RES_DRAIN
Resistance to drain life.- See Also:
- Constant Field Values
-
CS_STAT_RES_GHOSTHIT
public static final int CS_STAT_RES_GHOSTHIT
Resistance to ghost hit.- See Also:
- Constant Field Values
-
CS_STAT_RES_POISON
public static final int CS_STAT_RES_POISON
Resistance to poison.- See Also:
- Constant Field Values
-
CS_STAT_RES_SLOW
public static final int CS_STAT_RES_SLOW
Resistance to slowness.- See Also:
- Constant Field Values
-
CS_STAT_RES_PARA
public static final int CS_STAT_RES_PARA
Resistance to paralysis.- See Also:
- Constant Field Values
-
CS_STAT_RES_TURN_UNDEAD
public static final int CS_STAT_RES_TURN_UNDEAD
Resistance to turn undead.- See Also:
- Constant Field Values
-
CS_STAT_RES_FEAR
public static final int CS_STAT_RES_FEAR
Resistance to fear.- See Also:
- Constant Field Values
-
CS_STAT_RES_DEPLETE
public static final int CS_STAT_RES_DEPLETE
Resistance to depletion.- See Also:
- Constant Field Values
-
CS_STAT_RES_DEATH
public static final int CS_STAT_RES_DEATH
Resistance to death.- See Also:
- Constant Field Values
-
CS_STAT_RES_HOLYWORD
public static final int CS_STAT_RES_HOLYWORD
Resistance to holy word.- See Also:
- Constant Field Values
-
CS_STAT_RES_BLIND
public static final int CS_STAT_RES_BLIND
Resistance to blindness.- See Also:
- Constant Field Values
-
FLOAT_MULTI
public static final int FLOAT_MULTI
Factor used to convert float to int values.- See Also:
- Constant Field Values
-
RESIST_TYPES
public static final int RESIST_TYPES
The total number of resistances.- See Also:
- Constant Field Values
-
C_STAT_POISONED
public static final int C_STAT_POISONED
The "is poisoned" indicator. It ranges from 0 (not poisoned) to 1 (poisoned).- See Also:
- Constant Field Values
-
CS_NUM_SKILLS
public static final int CS_NUM_SKILLS
CS_NUM_SKILLS does not match how many skills there really are - instead, it is used as a range of values so that the client can have some idea how many skill categories there may be.- See Also:
- Constant Field Values
-
CS_STAT_SKILLINFO
public static final int CS_STAT_SKILLINFO
CS_STAT_SKILLINFO is used as the starting index point. Skill number->name map is generated dynamically for the client, so a bunch of entries will be used here.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Stats
public Stats(@NotNull @NotNull ExperienceTable experienceTable, @NotNull @NotNull SkillSet skillSet, @NotNull @NotNull GuiStateManager guiStateManager)Creates a new instance.- Parameters:
experienceTable- the experience table instance to useskillSet- the skill set instance to useguiStateManager- the gui state manager to watch
-
-
Method Detail
-
setSimpleWeaponSpeed
public void setSimpleWeaponSpeed(boolean simpleWeaponSpeed)
Sets whether theCS_STAT_WEAP_SPvalue contains the weapon speed directly.- Parameters:
simpleWeaponSpeed- whetherCS_STAT_WEAP_SPis the weapon speed value
-
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")
-
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
-
setStat
public void setStat(int statNo, int value)Sets the given statistic numerical value.- Parameters:
statNo- the stat identifier; see the CS_STAT constantsvalue- the value to assign to the chosen statistic
-
getTitle
@NotNull public @NotNull java.lang.String getTitle()
Returns the current title.- Returns:
- a string representation of the title
-
getRange
@NotNull public @NotNull 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
-
getActiveSkill
@NotNull public @NotNull java.lang.String getActiveSkill()
Returns the active skill name.- Returns:
- the active skill name
-
setActiveSkill
public void setActiveSkill(@NotNull @NotNull java.lang.String activeSkill)Sets the active skill name.- Parameters:
activeSkill- the active skill name
-
getExperience
public long getExperience()
Returns the amount of global experience.- Returns:
- the amount of global experience
-
getExperienceNextLevel
public long getExperienceNextLevel()
Returns the experience needed to reach the next level.- Returns:
- the experience needed
-
addCrossfireStatsListener
public void addCrossfireStatsListener(@NotNull @NotNull StatsListener statsListener)Adds aStatsListenerto be notified about stat changes.- Parameters:
statsListener- the listener to add
-
removeCrossfireStatsListener
public void removeCrossfireStatsListener(@NotNull @NotNull StatsListener statsListener)Removes aStatsListenerto be notified about stat changes.- Parameters:
statsListener- the listener to remove
-
getWeaponSpeed
public double getWeaponSpeed()
Returns the weapon speed stat.- Returns:
- the weapon speed stat
-
setStatInt2
public void setStatInt2(int stat, short param)Updates a stat value with a two-byte int value.- Parameters:
stat- the statparam- the stat value
-
setStatInt4
public void setStatInt4(int stat, int param)Updates a stat value with a four-byte int value.- Parameters:
stat- the statparam- the stat value
-
setStatInt8
public void setStatInt8(int stat, long param)Updates a stat value with an eight-byte int value.- Parameters:
stat- the statparam- the stat value
-
setStatString
public void setStatString(int stat, @NotNull @NotNull java.lang.String param)Updates a stat value with a string value.- Parameters:
stat- the statparam- the stat value
-
setStatSkill
public void setStatSkill(int stat, int level, long experience)Updates a stat value with a skill value.- Parameters:
stat- the statlevel- the stat valueexperience- the stat value
-
-