public class Stats
extends java.lang.Object
Constants named C_STAT_xxx
are client-sided; * constants named
CS_STAT_xxx
are stats as sent by the server.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
activeSkill
The active skill name.
|
static int |
C_STAT_EXP_NEXT_LEVEL
The global experience needed to reach next level stat.
|
static int |
C_STAT_LOWFOOD
The Low Food indicator.
|
static int |
C_STAT_POISONED
The "is poisoned" indicator.
|
static int |
C_STAT_WEIGHT
The character's weight.
|
static 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.
|
static int |
CS_STAT_AC
The Armor Class stat.
|
static int |
CS_STAT_APPLIED_CHA
The charisma primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_CON
The constitution primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_DEX
The dexterity primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_INT
The integer primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_POW
The power primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_STR
The strength primary stat changes due to gear or skills.
|
static int |
CS_STAT_APPLIED_WIS
The wisdom primary stat changes due to gear or skills.
|
static int |
CS_STAT_ARMOUR
The Armour stat.
|
static int |
CS_STAT_BASE_CHA
The charisma primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_CON
The constitution primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_DEX
The dexterity primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_INT
The integer primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_POW
The power primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_STR
The strength primary stat without boosts or depletions.
|
static int |
CS_STAT_BASE_WIS
The wisdom primary stat without boosts or depletions.
|
static int |
CS_STAT_CHA
The Charisma Primary stat.
|
static int |
CS_STAT_CON
The Constitution Primary stat.
|
static int |
CS_STAT_DAM
The Damage stat.
|
static int |
CS_STAT_DEX
The Dexterity Primary stat.
|
static int |
CS_STAT_EXP
The Global Experience (32bit encoding) stat.
|
static int |
CS_STAT_EXP64
The Global Experience (64bit encoding) stat.
|
static int |
CS_STAT_FLAGS
The various flags used in stats.
|
static int |
CS_STAT_FOOD
The Food stat.
|
static int |
CS_STAT_GOLEM_HP
The golem's hitpoints, 0 if no golem.
|
static int |
CS_STAT_GOLEM_MAXHP
The golem's maximum hitpoints, 0 if no golem.
|
static int |
CS_STAT_GRACE
The Grace stat.
|
static int |
CS_STAT_HP
The Hit Points stat.
|
static int |
CS_STAT_INT
The Intelligence Primary stat.
|
static int |
CS_STAT_LEVEL
The Global Level stat.
|
static int |
CS_STAT_MAXGRACE
The Maximum Grace stat.
|
static int |
CS_STAT_MAXHP
The Maximum Hit Points stat.
|
static int |
CS_STAT_MAXSP
The Maximum Spell Points stat.
|
static int |
CS_STAT_POW
The Power Primary stat.
|
static int |
CS_STAT_RACE_CHA
The race's maximum charisma primary stat.
|
static int |
CS_STAT_RACE_CON
The race's maximum constitution primary stat.
|
static int |
CS_STAT_RACE_DEX
The race's maximum dexterity primary stat.
|
static int |
CS_STAT_RACE_INT
The race's maximum intelligence primary stat.
|
static int |
CS_STAT_RACE_POW
The race's maximum power primary stat.
|
static int |
CS_STAT_RACE_STR
The race's maximum strength primary stat.
|
static int |
CS_STAT_RACE_WIS
The race's maximum wisdom primary stat.
|
static int |
CS_STAT_RANGE
The Range stat - this is what is currently readied by the player to
fire.
|
static int |
CS_STAT_RES_ACID
Resistance to acid.
|
static int |
CS_STAT_RES_BLIND
Resistance to blindness.
|
static int |
CS_STAT_RES_COLD
Resistance to cold.
|
static int |
CS_STAT_RES_CONF
Resistance to confusion.
|
static int |
CS_STAT_RES_DEATH
Resistance to death.
|
static int |
CS_STAT_RES_DEPLETE
Resistance to depletion.
|
static int |
CS_STAT_RES_DRAIN
Resistance to drain life.
|
static int |
CS_STAT_RES_ELEC
Resistance to electricity.
|
static int |
CS_STAT_RES_FEAR
Resistance to fear.
|
static int |
CS_STAT_RES_FIRE
Resistance to fire.
|
static int |
CS_STAT_RES_GHOSTHIT
Resistance to ghost hit.
|
static int |
CS_STAT_RES_HOLYWORD
Resistance to holy word.
|
static int |
CS_STAT_RES_MAG
Resistance to magical attacks.
|
static int |
CS_STAT_RES_PARA
Resistance to paralysis.
|
static int |
CS_STAT_RES_PHYS
Resistance to physical attacks.
|
static int |
CS_STAT_RES_POISON
Resistance to poison.
|
static int |
CS_STAT_RES_SLOW
Resistance to slowness.
|
static int |
CS_STAT_RES_TURN_UNDEAD
Resistance to turn undead.
|
static int |
CS_STAT_RESIST_END
End index of the resistances.
|
static int |
CS_STAT_RESIST_START
Beginning index of the resistances.
|
static int |
CS_STAT_SKILLINFO
CS_STAT_SKILLINFO is used as the starting index point.
|
static int |
CS_STAT_SP
The Spell Points stat.
|
static int |
CS_STAT_SPEED
The Speed stat.
|
static int |
CS_STAT_SPELL_ATTUNE
Attuned spell paths of a spell.
|
static int |
CS_STAT_SPELL_DENY
Denied spell paths of a spell.
|
static int |
CS_STAT_SPELL_REPEL
Repelled spell paths of a spell.
|
static int |
CS_STAT_STR
The Strength Primary stat.
|
static int |
CS_STAT_TITLE
The Title stat.
|
static int |
CS_STAT_WC
The Weapon Class stat.
|
static int |
CS_STAT_WEAP_SP
The Weapon Speed stat.
|
static int |
CS_STAT_WEIGHT_LIM
The Weight Limit stat.
|
static int |
CS_STAT_WIS
The Wisdom Primary stat.
|
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.
|
static int |
FLOAT_MULTI
Factor used to convert float to int values.
|
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private java.lang.String |
range
The current value of the range stat.
|
static int |
RESIST_TYPES
The total number of resistances.
|
private boolean |
simpleWeaponSpeed
Whether the
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 EventListenerList2<StatsListener> |
statsListeners
The listeners to inform of stat changes.
|
private java.lang.String |
title
The current value of the title stat.
|
private java.util.Collection<java.lang.String> |
unhandledStats
All unhandled stat values for which an error has been printed.
|
Constructor and Description |
---|
Stats(ExperienceTable experienceTable,
SkillSet skillSet,
GuiStateManager guiStateManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCrossfireStatsListener(StatsListener statsListener)
Adds a
StatsListener to be notified about stat changes. |
private void |
calculateExperienceToNextLevel()
Calculates the 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 |
reportUnhandledStat(int stat,
java.lang.String type)
Report an unhandled stat value.
|
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.
|
void |
setSimpleWeaponSpeed(boolean simpleWeaponSpeed)
Sets whether the
CS_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,
java.lang.String param)
Updates a stat value with a string value.
|
private void |
setTitle(java.lang.String title)
Sets the current Title.
|
@NotNull private java.lang.String activeSkill
public static final int C_STAT_EXP_NEXT_LEVEL
public static final int C_STAT_LOWFOOD
public static final int C_STAT_POISONED
public static final int C_STAT_WEIGHT
public static final int CS_NUM_SKILLS
public static final int CS_STAT_AC
public static final int CS_STAT_APPLIED_CHA
public static final int CS_STAT_APPLIED_CON
public static final int CS_STAT_APPLIED_DEX
public static final int CS_STAT_APPLIED_INT
public static final int CS_STAT_APPLIED_POW
public static final int CS_STAT_APPLIED_STR
public static final int CS_STAT_APPLIED_WIS
public static final int CS_STAT_ARMOUR
public static final int CS_STAT_BASE_CHA
public static final int CS_STAT_BASE_CON
public static final int CS_STAT_BASE_DEX
public static final int CS_STAT_BASE_INT
public static final int CS_STAT_BASE_POW
public static final int CS_STAT_BASE_STR
public static final int CS_STAT_BASE_WIS
public static final int CS_STAT_CHA
public static final int CS_STAT_CON
public static final int CS_STAT_DAM
public static final int CS_STAT_DEX
public static final int CS_STAT_EXP
public static final int CS_STAT_EXP64
public static final int CS_STAT_FLAGS
public static final int CS_STAT_FOOD
public static final int CS_STAT_GOLEM_HP
public static final int CS_STAT_GOLEM_MAXHP
public static final int CS_STAT_GRACE
public static final int CS_STAT_HP
public static final int CS_STAT_INT
public static final int CS_STAT_LEVEL
public static final int CS_STAT_MAXGRACE
public static final int CS_STAT_MAXHP
public static final int CS_STAT_MAXSP
public static final int CS_STAT_POW
public static final int CS_STAT_RACE_CHA
public static final int CS_STAT_RACE_CON
public static final int CS_STAT_RACE_DEX
public static final int CS_STAT_RACE_INT
public static final int CS_STAT_RACE_POW
public static final int CS_STAT_RACE_STR
public static final int CS_STAT_RACE_WIS
public static final int CS_STAT_RANGE
public static final int CS_STAT_RES_ACID
public static final int CS_STAT_RES_BLIND
public static final int CS_STAT_RES_COLD
public static final int CS_STAT_RES_CONF
public static final int CS_STAT_RES_DEATH
public static final int CS_STAT_RES_DEPLETE
public static final int CS_STAT_RES_DRAIN
public static final int CS_STAT_RES_ELEC
public static final int CS_STAT_RES_FEAR
public static final int CS_STAT_RES_FIRE
public static final int CS_STAT_RES_GHOSTHIT
public static final int CS_STAT_RES_HOLYWORD
public static final int CS_STAT_RES_MAG
public static final int CS_STAT_RES_PARA
public static final int CS_STAT_RES_PHYS
public static final int CS_STAT_RES_POISON
public static final int CS_STAT_RES_SLOW
public static final int CS_STAT_RES_TURN_UNDEAD
public static final int CS_STAT_RESIST_END
public static final int CS_STAT_RESIST_START
public static final int CS_STAT_SKILLINFO
public static final int CS_STAT_SP
public static final int CS_STAT_SPEED
public static final int CS_STAT_SPELL_ATTUNE
public static final int CS_STAT_SPELL_DENY
public static final int CS_STAT_SPELL_REPEL
public static final int CS_STAT_STR
public static final int CS_STAT_TITLE
public static final int CS_STAT_WC
public static final int CS_STAT_WEAP_SP
public static final int CS_STAT_WEIGHT_LIM
public static final int CS_STAT_WIS
private long exp
@NotNull private final ExperienceTable experienceTable
ExperienceTable
instance to use.private long expNextLevel
public static final int FLOAT_MULTI
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.@NotNull private java.lang.String range
public static final int RESIST_TYPES
private boolean simpleWeaponSpeed
CS_STAT_WEAP_SP
value contains the weapon speed
directly.@NotNull private final int[] stats
@NotNull private final EventListenerList2<StatsListener> statsListeners
@NotNull private java.lang.String title
@NotNull private final java.util.Collection<java.lang.String> unhandledStats
public Stats(@NotNull ExperienceTable experienceTable, @NotNull SkillSet skillSet, @NotNull GuiStateManager guiStateManager)
experienceTable
- the experience table instance to useskillSet
- the skill set instance to useguiStateManager
- the gui state manager to watchpublic void addCrossfireStatsListener(@NotNull StatsListener statsListener)
StatsListener
to be notified about stat changes.statsListener
- the listener to addprivate void calculateExperienceToNextLevel()
@NotNull public java.lang.String getActiveSkill()
public long getExperience()
public long getExperienceNextLevel()
public double getFloatStat(int statNo)
statNo
- the stat identifier; see the CS_STAT constants@NotNull public java.lang.String getRange()
public int getStat(int statNo)
statNo
- the stat identifier; see the CS_STAT constants@NotNull public java.lang.String getTitle()
public double getWeaponSpeed()
public void removeCrossfireStatsListener(@NotNull StatsListener statsListener)
StatsListener
to be notified about stat changes.statsListener
- the listener to removeprivate void reportUnhandledStat(int stat, @NotNull java.lang.String type)
stat
- the stat valuetype
- the stat typeprivate void reset()
public void setActiveSkill(@NotNull java.lang.String activeSkill)
activeSkill
- the active skill nameprivate void setExperience(long exp)
exp
- the new amount of global experienceprivate void setRange(@NotNull java.lang.String range)
range
- the new content of rangepublic void setSimpleWeaponSpeed(boolean simpleWeaponSpeed)
CS_STAT_WEAP_SP
value contains the weapon speed
directly.simpleWeaponSpeed
- whether CS_STAT_WEAP_SP
is the weapon
speed valuepublic void setStat(int statNo, int value)
statNo
- the stat identifier; see the CS_STAT constantsvalue
- the value to assign to the chosen statisticpublic void setStatInt2(int stat, short param)
stat
- the statparam
- the stat valuepublic void setStatInt4(int stat, int param)
stat
- the statparam
- the stat valuepublic void setStatInt8(int stat, long param)
stat
- the statparam
- the stat valuepublic void setStatSkill(int stat, int level, long experience)
stat
- the statlevel
- the stat valueexperience
- the stat valuepublic void setStatString(int stat, @NotNull java.lang.String param)
stat
- the statparam
- the stat valueprivate void setTitle(@NotNull java.lang.String title)
title
- the new Title content