Class Stats
java.lang.Object
com.realtime.crossfire.jxclient.stats.Stats
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
FieldsModifier and TypeFieldDescriptionstatic final int
The "is blind" indicator.static final int
The "is confused" indicator.static final int
The name of the current skill.static final int
The "is diseased" indicator.static final int
The global experience needed to reach next level stat.static final int
The "is hostile" indicator.static final int
The Low Food indicator.static final int
The "is not perfect" indicator.static final int
The "is paralyzed" indicator.static final int
The "is poisoned" indicator.static final int
The "is starving" indicator.static final int
The "is stealthy" indicator.static final int
The character's weight.static final int
The "is DM" indicator.static final int
The "has xray vision" indicator.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a lind character.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a confused character.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character having a disease.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character that has hostile mode enabled.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character that needs to drink an improvement potion.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character that is paralyzed.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a poisoned character.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character that is stealthy.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character that is a DM.static final int
TheCS_STAT_CHARACTER_FLAGS
bit for a character having x-ray vision.static final int
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.static final int
The Armor Class stat.static final int
The charisma primary stat changes due to gear or skills.static final int
The constitution primary stat changes due to gear or skills.static final int
The dexterity primary stat changes due to gear or skills.static final int
The integer primary stat changes due to gear or skills.static final int
The power primary stat changes due to gear or skills.static final int
The strength primary stat changes due to gear or skills.static final int
The wisdom primary stat changes due to gear or skills.static final int
The Armour stat.static final int
The charisma primary stat without boosts or depletions.static final int
The constitution primary stat without boosts or depletions.static final int
The dexterity primary stat without boosts or depletions.static final int
The integer primary stat without boosts or depletions.static final int
The power primary stat without boosts or depletions.static final int
The strength primary stat without boosts or depletions.static final int
The wisdom primary stat without boosts or depletions.static final int
The Charisma Primary stat.static final int
Flags the character's current state.static final int
The Constitution Primary stat.static final int
The Damage stat.static final int
The Dexterity Primary stat.static final int
The Global Experience (32bit encoding) stat.static final int
The Global Experience (64bit encoding) stat.static final int
The various flags used in stats.static final int
The Food stat.static final int
The character's god orNO_GOD_NAME
if he has none.static final int
The golem's hitpoints, 0 if no golem.static final int
The golem's maximum hitpoints, 0 if no golem.static final int
The Grace stat.static final int
The Hit Points stat.static final int
The Intelligence Primary stat.static final int
The maximum item power the character can handle.static final int
The Global Level stat.static final int
The Maximum Grace stat.static final int
The Maximum Hit Points stat.static final int
The Maximum Spell Points stat.static final int
Indicates how much the character is overloaded: 0=not overloaded, 1=overloaded.static final int
The Power Primary stat.static final int
The race's maximum charisma primary stat.static final int
The race's maximum constitution primary stat.static final int
The race's maximum dexterity primary stat.static final int
The race's maximum intelligence primary stat.static final int
The race's maximum power primary stat.static final int
The race's maximum strength primary stat.static final int
The race's maximum wisdom primary stat.static final int
The Range stat - this is what is currently readied by the player to fire.static final int
Resistance to acid.static final int
Resistance to blindness.static final int
Resistance to cold.static final int
Resistance to confusion.static final int
Resistance to death.static final int
Resistance to depletion.static final int
Resistance to drain life.static final int
Resistance to electricity.static final int
Resistance to fear.static final int
Resistance to fire.static final int
Resistance to ghost hit.static final int
Resistance to holy word.static final int
Resistance to magical attacks.static final int
Resistance to paralysis.static final int
Resistance to physical attacks.static final int
Resistance to poison.static final int
Resistance to slowness.static final int
Resistance to turn undead.static final int
End index of the resistances.static final int
Beginning index of the resistances.static final int
CS_STAT_SKILLINFO is used as the starting index point.static final int
The Spell Points stat.static final int
The Speed stat.static final int
Attuned spell paths of a spell.static final int
Denied spell paths of a spell.static final int
Repelled spell paths of a spell.static final int
The Strength Primary stat.static final int
The Title stat.static final int
The Weapon Class stat.static final int
The Weapon Speed stat.static final int
The Weight Limit stat.static final int
The Wisdom Primary stat.static final int
Factor used to convert float to int values.static final @NotNull String
The value ofCS_STAT_GOD_NAME
orgodName
when the character has no god.static final int
The total number of resistances. -
Constructor Summary
ConstructorsConstructorDescriptionStats
(@NotNull ExperienceTable experienceTable, @NotNull SkillSet skillSet, @NotNull GuiStateManager guiStateManager) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCrossfireStatsListener
(@NotNull StatsListener statsListener) Adds aStatsListener
to be notified about stat changes.@NotNull String
Returns the active skill name.long
Returns the amount of global experience.long
Returns the experience needed to reach the next level.double
getFloatStat
(int statNo) Returns the numerical value of the given statistic.@NotNull String
getRange()
Returns the current content of the range stat.int
getStat
(int statNo) Returns the numerical value of the given statistic.@NotNull String
getTitle()
Returns the current title.double
Returns the weapon speed stat.void
removeCrossfireStatsListener
(@NotNull StatsListener statsListener) Removes aStatsListener
to be notified about stat changes.void
setActiveSkill
(@NotNull String activeSkill) Sets the active skill name.void
setSimpleWeaponSpeed
(boolean simpleWeaponSpeed) Sets whether theCS_STAT_WEAP_SP
value contains the weapon speed directly.void
setStat
(int statNo, int value) Sets the given statistic numerical value.void
setStatInt2
(int stat, short param) Updates a stat value with a two-byte int value.void
setStatInt4
(int stat, int param) Updates a stat value with a four-byte int value.void
setStatInt8
(int stat, long param) Updates a stat value with an eight-byte int value.void
setStatSkill
(int stat, int level, long experience) Updates a stat value with a skill value.void
setStatString
(int stat, @NotNull String param) Updates a stat value with a string value.
-
Field Details
-
CS_STAT_HP
public static final int CS_STAT_HPThe Hit Points stat.- See Also:
-
CS_STAT_MAXHP
public static final int CS_STAT_MAXHPThe Maximum Hit Points stat.- See Also:
-
CS_STAT_SP
public static final int CS_STAT_SPThe Spell Points stat.- See Also:
-
CS_STAT_MAXSP
public static final int CS_STAT_MAXSPThe Maximum Spell Points stat.- See Also:
-
CS_STAT_STR
public static final int CS_STAT_STRThe Strength Primary stat.- See Also:
-
CS_STAT_INT
public static final int CS_STAT_INTThe Intelligence Primary stat.- See Also:
-
CS_STAT_WIS
public static final int CS_STAT_WISThe Wisdom Primary stat.- See Also:
-
CS_STAT_DEX
public static final int CS_STAT_DEXThe Dexterity Primary stat.- See Also:
-
CS_STAT_CON
public static final int CS_STAT_CONThe Constitution Primary stat.- See Also:
-
CS_STAT_CHA
public static final int CS_STAT_CHAThe Charisma Primary stat.- See Also:
-
CS_STAT_EXP
public static final int CS_STAT_EXPThe Global Experience (32bit encoding) stat.- See Also:
-
C_STAT_EXP_NEXT_LEVEL
public static final int C_STAT_EXP_NEXT_LEVELThe global experience needed to reach next level stat.- See Also:
-
CS_STAT_LEVEL
public static final int CS_STAT_LEVELThe Global Level stat.- See Also:
-
CS_STAT_WC
public static final int CS_STAT_WCThe Weapon Class stat.- See Also:
-
CS_STAT_AC
public static final int CS_STAT_ACThe Armor Class stat.- See Also:
-
CS_STAT_DAM
public static final int CS_STAT_DAMThe Damage stat.- See Also:
-
CS_STAT_ARMOUR
public static final int CS_STAT_ARMOURThe Armour stat.- See Also:
-
CS_STAT_SPEED
public static final int CS_STAT_SPEEDThe Speed stat.- See Also:
-
CS_STAT_FOOD
public static final int CS_STAT_FOODThe Food stat.- See Also:
-
C_STAT_LOWFOOD
public static final int C_STAT_LOWFOODThe Low Food indicator. It ranges from 0 (ok) to 1 (low food).- See Also:
-
CS_STAT_WEAP_SP
public static final int CS_STAT_WEAP_SPThe Weapon Speed stat.- See Also:
-
CS_STAT_RANGE
public static final int CS_STAT_RANGEThe Range stat - this is what is currently readied by the player to fire.- See Also:
-
CS_STAT_TITLE
public static final int CS_STAT_TITLEThe Title stat.- See Also:
-
CS_STAT_POW
public static final int CS_STAT_POWThe Power Primary stat.- See Also:
-
CS_STAT_GRACE
public static final int CS_STAT_GRACEThe Grace stat.- See Also:
-
CS_STAT_MAXGRACE
public static final int CS_STAT_MAXGRACEThe Maximum Grace stat.- See Also:
-
CS_STAT_FLAGS
public static final int CS_STAT_FLAGSThe various flags used in stats.- See Also:
-
CS_STAT_WEIGHT_LIM
public static final int CS_STAT_WEIGHT_LIMThe Weight Limit stat.- See Also:
-
C_STAT_WEIGHT
public static final int C_STAT_WEIGHTThe character's weight.- See Also:
-
CS_STAT_EXP64
public static final int CS_STAT_EXP64The Global Experience (64bit encoding) stat.- See Also:
-
CS_STAT_SPELL_ATTUNE
public static final int CS_STAT_SPELL_ATTUNEAttuned spell paths of a spell.- See Also:
-
CS_STAT_SPELL_REPEL
public static final int CS_STAT_SPELL_REPELRepelled spell paths of a spell.- See Also:
-
CS_STAT_SPELL_DENY
public static final int CS_STAT_SPELL_DENYDenied spell paths of a spell.- See Also:
-
CS_STAT_RACE_STR
public static final int CS_STAT_RACE_STRThe race's maximum strength primary stat.- See Also:
-
CS_STAT_RACE_INT
public static final int CS_STAT_RACE_INTThe race's maximum intelligence primary stat.- See Also:
-
CS_STAT_RACE_WIS
public static final int CS_STAT_RACE_WISThe race's maximum wisdom primary stat.- See Also:
-
CS_STAT_RACE_DEX
public static final int CS_STAT_RACE_DEXThe race's maximum dexterity primary stat.- See Also:
-
CS_STAT_RACE_CON
public static final int CS_STAT_RACE_CONThe race's maximum constitution primary stat.- See Also:
-
CS_STAT_RACE_CHA
public static final int CS_STAT_RACE_CHAThe race's maximum charisma primary stat.- See Also:
-
CS_STAT_RACE_POW
public static final int CS_STAT_RACE_POWThe race's maximum power primary stat.- See Also:
-
CS_STAT_BASE_STR
public static final int CS_STAT_BASE_STRThe strength primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_INT
public static final int CS_STAT_BASE_INTThe integer primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_WIS
public static final int CS_STAT_BASE_WISThe wisdom primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_DEX
public static final int CS_STAT_BASE_DEXThe dexterity primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_CON
public static final int CS_STAT_BASE_CONThe constitution primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_CHA
public static final int CS_STAT_BASE_CHAThe charisma primary stat without boosts or depletions.- See Also:
-
CS_STAT_BASE_POW
public static final int CS_STAT_BASE_POWThe power primary stat without boosts or depletions.- See Also:
-
CS_STAT_APPLIED_STR
public static final int CS_STAT_APPLIED_STRThe strength primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_INT
public static final int CS_STAT_APPLIED_INTThe integer primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_WIS
public static final int CS_STAT_APPLIED_WISThe wisdom primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_DEX
public static final int CS_STAT_APPLIED_DEXThe dexterity primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_CON
public static final int CS_STAT_APPLIED_CONThe constitution primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_CHA
public static final int CS_STAT_APPLIED_CHAThe charisma primary stat changes due to gear or skills.- See Also:
-
CS_STAT_APPLIED_POW
public static final int CS_STAT_APPLIED_POWThe power primary stat changes due to gear or skills.- See Also:
-
CS_STAT_GOLEM_HP
public static final int CS_STAT_GOLEM_HPThe golem's hitpoints, 0 if no golem.- See Also:
-
CS_STAT_GOLEM_MAXHP
public static final int CS_STAT_GOLEM_MAXHPThe golem's maximum hitpoints, 0 if no golem.- See Also:
-
CS_STAT_CHARACTER_FLAGS
public static final int CS_STAT_CHARACTER_FLAGSFlags the character's current state.- See Also:
-
CS_STAT_GOD_NAME
public static final int CS_STAT_GOD_NAMEThe character's god orNO_GOD_NAME
if he has none.- See Also:
-
CS_STAT_OVERLOAD
public static final int CS_STAT_OVERLOADIndicates how much the character is overloaded: 0=not overloaded, 1=overloaded.- See Also:
-
CS_STAT_ITEM_POWER
public static final int CS_STAT_ITEM_POWERThe maximum item power the character can handle.- See Also:
-
CS_STAT_RESIST_START
public static final int CS_STAT_RESIST_STARTBeginning index of the resistances.- See Also:
-
CS_STAT_RESIST_END
public static final int CS_STAT_RESIST_ENDEnd index of the resistances.- See Also:
-
CS_STAT_RES_PHYS
public static final int CS_STAT_RES_PHYSResistance to physical attacks.- See Also:
-
CS_STAT_RES_MAG
public static final int CS_STAT_RES_MAGResistance to magical attacks.- See Also:
-
CS_STAT_RES_FIRE
public static final int CS_STAT_RES_FIREResistance to fire.- See Also:
-
CS_STAT_RES_ELEC
public static final int CS_STAT_RES_ELECResistance to electricity.- See Also:
-
CS_STAT_RES_COLD
public static final int CS_STAT_RES_COLDResistance to cold.- See Also:
-
CS_STAT_RES_CONF
public static final int CS_STAT_RES_CONFResistance to confusion.- See Also:
-
CS_STAT_RES_ACID
public static final int CS_STAT_RES_ACIDResistance to acid.- See Also:
-
CS_STAT_RES_DRAIN
public static final int CS_STAT_RES_DRAINResistance to drain life.- See Also:
-
CS_STAT_RES_GHOSTHIT
public static final int CS_STAT_RES_GHOSTHITResistance to ghost hit.- See Also:
-
CS_STAT_RES_POISON
public static final int CS_STAT_RES_POISONResistance to poison.- See Also:
-
CS_STAT_RES_SLOW
public static final int CS_STAT_RES_SLOWResistance to slowness.- See Also:
-
CS_STAT_RES_PARA
public static final int CS_STAT_RES_PARAResistance to paralysis.- See Also:
-
CS_STAT_RES_TURN_UNDEAD
public static final int CS_STAT_RES_TURN_UNDEADResistance to turn undead.- See Also:
-
CS_STAT_RES_FEAR
public static final int CS_STAT_RES_FEARResistance to fear.- See Also:
-
CS_STAT_RES_DEPLETE
public static final int CS_STAT_RES_DEPLETEResistance to depletion.- See Also:
-
CS_STAT_RES_DEATH
public static final int CS_STAT_RES_DEATHResistance to death.- See Also:
-
CS_STAT_RES_HOLYWORD
public static final int CS_STAT_RES_HOLYWORDResistance to holy word.- See Also:
-
CS_STAT_RES_BLIND
public static final int CS_STAT_RES_BLINDResistance to blindness.- See Also:
-
FLOAT_MULTI
public static final int FLOAT_MULTIFactor used to convert float to int values.- See Also:
-
RESIST_TYPES
public static final int RESIST_TYPESThe total number of resistances.- See Also:
-
C_STAT_POISONED
public static final int C_STAT_POISONEDThe "is poisoned" indicator. It ranges from 0 (not poisoned) to 1 (poisoned).- See Also:
-
C_STAT_STARVING
public static final int C_STAT_STARVINGThe "is starving" indicator. It ranges from 0 (not starving) to 1 (starving).- See Also:
-
CS_NUM_SKILLS
public static final int CS_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.- See Also:
-
C_STAT_CONFUSED
public static final int C_STAT_CONFUSEDThe "is confused" indicator. It ranges from 0 (not confused) to 1 (confused).- See Also:
-
C_STAT_BLIND
public static final int C_STAT_BLINDThe "is blind" indicator. It ranges from 0 (not blind) to 1 (blind).- See Also:
-
C_STAT_XRAY
public static final int C_STAT_XRAYThe "has xray vision" indicator. It ranges from 0 (no xray vision) to 1 (xray vision).- See Also:
-
C_STAT_DISEASED
public static final int C_STAT_DISEASEDThe "is diseased" indicator. It ranges from 0 (not diseased) to 1 (diseased).- See Also:
-
C_STAT_NOT_PERFECT
public static final int C_STAT_NOT_PERFECTThe "is not perfect" indicator. It ranges from 0 (perfect) to 1 (not perfect).- See Also:
-
C_STAT_HOSTILE
public static final int C_STAT_HOSTILEThe "is hostile" indicator. It ranges from 0 (not hostile) to 1 (hostile).- See Also:
-
C_STAT_STEALTHY
public static final int C_STAT_STEALTHYThe "is stealthy" indicator. It ranges from 0 (not stealthy) to 1 (is stealthy).- See Also:
-
C_STAT_PARALYZED
public static final int C_STAT_PARALYZEDThe "is paralyzed" indicator. It ranges from 0 (not paralyzed) to 1 (paralyzed).- See Also:
-
C_STAT_WIZARD
public static final int C_STAT_WIZARDThe "is DM" indicator. It ranges from 0 (no DM) to 1 (DM).- See Also:
-
C_STAT_CURRENT_SKILL
public static final int C_STAT_CURRENT_SKILLThe name of the current skill.- See Also:
-
CS_STAT_SKILLINFO
public static final int CS_STAT_SKILLINFOCS_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:
-
CF_CONFUSED
public static final int CF_CONFUSEDTheCS_STAT_CHARACTER_FLAGS
bit for a confused character.- See Also:
-
CF_POISONED
public static final int CF_POISONEDTheCS_STAT_CHARACTER_FLAGS
bit for a poisoned character.- See Also:
-
CF_BLIND
public static final int CF_BLINDTheCS_STAT_CHARACTER_FLAGS
bit for a lind character.- See Also:
-
CF_XRAY
public static final int CF_XRAYTheCS_STAT_CHARACTER_FLAGS
bit for a character having x-ray vision.- See Also:
-
CF_DISEASED
public static final int CF_DISEASEDTheCS_STAT_CHARACTER_FLAGS
bit for a character having a disease.- See Also:
-
CF_NOT_PERFECT
public static final int CF_NOT_PERFECTTheCS_STAT_CHARACTER_FLAGS
bit for a character that needs to drink an improvement potion.- See Also:
-
CF_HOSTILE
public static final int CF_HOSTILETheCS_STAT_CHARACTER_FLAGS
bit for a character that has hostile mode enabled.- See Also:
-
CF_STEALTHY
public static final int CF_STEALTHYTheCS_STAT_CHARACTER_FLAGS
bit for a character that is stealthy.- See Also:
-
CF_PARALYZED
public static final int CF_PARALYZEDTheCS_STAT_CHARACTER_FLAGS
bit for a character that is paralyzed.- See Also:
-
CF_WIZARD
public static final int CF_WIZARDTheCS_STAT_CHARACTER_FLAGS
bit for a character that is a DM.- See Also:
-
NO_GOD_NAME
The value ofCS_STAT_GOD_NAME
orgodName
when the character has no god.- See Also:
-
-
Constructor Details
-
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 Details
-
setSimpleWeaponSpeed
public void setSimpleWeaponSpeed(boolean simpleWeaponSpeed) Sets whether theCS_STAT_WEAP_SP
value contains the weapon speed directly.- Parameters:
simpleWeaponSpeed
- whetherCS_STAT_WEAP_SP
is 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
Returns the current title.- Returns:
- a string representation of the title
-
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
Returns the active skill name.- Returns:
- the active skill name
-
setActiveSkill
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
Adds aStatsListener
to be notified about stat changes.- Parameters:
statsListener
- the listener to add
-
removeCrossfireStatsListener
Removes aStatsListener
to 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
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
-