22 package com.realtime.crossfire.jxclient.stats;
30 import java.util.Collection;
31 import java.util.HashSet;
32 import org.jetbrains.annotations.NotNull;
484 private final int[]
stats =
new int[258];
525 @SuppressWarnings(
"FieldCanBeLocal")
529 public void start() {
534 public void metaserver() {
539 public void preConnecting(@NotNull
final String serverInfo) {
544 public void connecting(@NotNull
final String serverInfo) {
554 public void connected() {
559 public void connectFailed(@NotNull
final String reason) {
584 if (this.simpleWeaponSpeed == simpleWeaponSpeed) {
590 statsListener.simpleWeaponSpeedChanged(this.simpleWeaponSpeed);
599 statsListener.reset();
601 for (
int statNo = 0; statNo < stats.length; statNo++) {
616 return stats[statNo];
633 public void setStat(
final int statNo,
final int value) {
634 if (stats[statNo] == value) {
638 stats[statNo] = value;
640 statsListener.statChanged(statNo, stats[statNo]);
676 private void setTitle(@NotNull
final String title) {
677 if (this.title.equals(title)) {
683 statsListener.titleChanged(this.title);
692 private void setRange(@NotNull
final String range) {
693 if (this.range.equals(range)) {
699 statsListener.rangeChanged(this.range);
708 if (this.activeSkill.equals(activeSkill)) {
714 statsListener.activeSkillChanged(this.activeSkill);
731 if (this.exp == exp) {
737 statsListener.experienceChanged(this.exp);
756 if (expNextLevel == newExpNextLevel) {
760 expNextLevel = newExpNextLevel;
762 statsListener.experienceNextLevelChanged(expNextLevel);
771 statsListeners.
add(statsListener);
779 statsListeners.
remove(statsListener);
787 final double weaponSpeed =
getFloatStat(CS_STAT_WEAP_SP);
788 if (simpleWeaponSpeed) {
792 if (weaponSpeed < 0.001) {
849 if (stat == CS_STAT_LEVEL) {
859 if (CS_STAT_RESIST_START <= stat && stat < CS_STAT_RESIST_START+RESIST_TYPES) {
938 public void setStatSkill(
final int stat,
final int level,
final long experience) {
939 if (CS_STAT_SKILLINFO <= stat && stat < CS_STAT_SKILLINFO+CS_NUM_SKILLS) {
942 System.err.println(
"ignoring skill value for unknown skill "+stat);
944 sk.
set(level, experience);
957 if (unhandledStats.add(type+
"-"+stat)) {
958 System.err.println(
"Warning: unhandled stat "+stat+
" of type "+type);
static final int CS_STAT_GOLEM_HP
The golem's hitpoints, 0 if no golem.
static final int CS_STAT_RES_BLIND
Resistance to blindness.
static final int CS_STAT_RACE_CHA
The race's maximum charisma primary stat.
Interface for listeners interested gui state changes.
static final int CS_STAT_DEX
The Dexterity Primary stat.
static final int CS_STAT_SPELL_ATTUNE
Attuned spell paths of a spell.
Maintains the current GuiState.
static final int RESIST_TYPES
The total number of resistances.
static final int CS_STAT_TITLE
The Title stat.
static final int CS_STAT_SPELL_DENY
Denied spell paths of a spell.
static final int CS_STAT_RANGE
The Range stat - this is what is currently readied by the player to fire.
A list of event listeners.
String range
The current value of the range stat.
String activeSkill
The active skill name.
static final int CS_STAT_APPLIED_CON
The constitution primary stat changes due to gear or skills.
static final int CS_STAT_RESIST_START
Beginning index of the resistances.
long getExperienceToNextLevel(final int currentLevel, final long currentExp)
Returns the experience needed to reach the next level.
void removeCrossfireStatsListener(@NotNull final StatsListener statsListener)
Removes a StatsListener to be notified about stat changes.
final EventListenerList2< StatsListener > statsListeners
The listeners to inform of stat changes.
static final int CS_STAT_BASE_POW
The power primary stat without boosts or depletions.
void setStatInt2(final int stat, final short param)
Updates a stat value with a two-byte int value.
static final int CS_STAT_POW
The Power Primary stat.
void reportUnhandledStat(final int stat, @NotNull final String type)
Report an unhandled stat value.
static final int CS_STAT_APPLIED_INT
The integer primary stat changes due to gear or skills.
static final int C_STAT_LOWFOOD
The Low Food indicator.
void setActiveSkill(@NotNull final String activeSkill)
Sets the active skill name.
static final int CS_STAT_RES_TURN_UNDEAD
Resistance to turn undead.
long getExperience()
Returns the amount of global experience.
void reset()
Forgets about all stats.
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 val...
long expNextLevel
The experience needed to reach the next level.
Stats(@NotNull final ExperienceTable experienceTable, @NotNull final SkillSet skillSet, @NotNull final GuiStateManager guiStateManager)
Creates a new instance.
static final int CS_STAT_HP
The Hit Points stat.
static final int CS_STAT_LEVEL
The Global Level stat.
void setSimpleWeaponSpeed(final boolean simpleWeaponSpeed)
Sets whether the CS_STAT_WEAP_SP value contains the weapon speed directly.
static final int CS_STAT_MAXHP
The Maximum Hit Points stat.
static final int CS_STAT_RACE_WIS
The race's maximum wisdom primary stat.
final SkillSet skillSet
The SkillSet instance to use.
long getExperienceNextLevel()
Returns the experience needed to reach the next level.
static final int CS_STAT_DAM
The Damage stat.
static final int CS_STAT_STR
The Strength Primary stat.
void setExperience(final long exp)
Sets the amount of global experience.
static final int CS_STAT_AC
The Armor Class stat.
static final int CS_STAT_RES_FIRE
Resistance to fire.
static final int CS_STAT_FOOD
The Food stat.
static final int CS_STAT_WIS
The Wisdom Primary stat.
void setStatSkill(final int stat, final int level, final long experience)
Updates a stat value with a skill value.
static final int CS_STAT_BASE_INT
The integer primary stat without boosts or depletions.
void set(final int level, final long experience)
Updates the skill attributes.
static final int CS_STAT_SP
The Spell Points stat.
void addCrossfireStatsListener(@NotNull final StatsListener statsListener)
Adds a StatsListener to be notified about stat changes.
One skill of the character.
static final int CS_STAT_RACE_CON
The race's maximum constitution primary stat.
void setStatString(final int stat, @NotNull final String param)
Updates a stat value with a string value.
static final int CS_STAT_WEIGHT_LIM
The Weight Limit stat.
boolean simpleWeaponSpeed
Whether the CS_STAT_WEAP_SP value contains the weapon speed directly.
static final int CS_STAT_APPLIED_STR
The strength primary stat changes due to gear or skills.
static final int CS_STAT_BASE_STR
The strength primary stat without boosts or depletions.
static final int CS_STAT_GOLEM_MAXHP
The golem's maximum hitpoints, 0 if no golem.
static final int FLOAT_MULTI
Factor used to convert float to int values.
static final int CS_STAT_RES_DRAIN
Resistance to drain life.
long exp
The total experience.
double getWeaponSpeed()
Returns the weapon speed stat.
static final int CS_STAT_RES_PHYS
Resistance to physical attacks.
static final int CS_STAT_SKILLINFO
CS_STAT_SKILLINFO is used as the starting index point.
void setRange(@NotNull final String range)
Sets the current value for the Range - this is basically the currently active skill for the player...
static final int CS_STAT_CON
The Constitution Primary stat.
static final int CS_STAT_RACE_STR
The race's maximum strength primary stat.
static final int CS_STAT_RES_PARA
Resistance to paralysis.
static final int CS_STAT_RES_DEPLETE
Resistance to depletion.
static final int CS_STAT_RES_ELEC
Resistance to electricity.
static final int CS_STAT_RES_MAG
Resistance to magical attacks.
static final int CS_STAT_APPLIED_DEX
The dexterity primary stat changes due to gear or skills.
String getActiveSkill()
Returns the active skill name.
static final int CS_STAT_RES_COLD
Resistance to cold.
static final int CS_STAT_RES_GHOSTHIT
Resistance to ghost hit.
static final int C_STAT_EXP_NEXT_LEVEL
The global experience needed to reach next level stat.
String getRange()
Returns the current content of the range stat.
static final int CS_STAT_RES_FEAR
Resistance to fear.
void add(@NotNull final T listener)
Adds a listener.
static final int CS_STAT_RACE_INT
The race's maximum intelligence primary stat.
static final int CS_STAT_MAXGRACE
The Maximum Grace stat.
static final int CS_STAT_RES_CONF
Resistance to confusion.
static final int CS_STAT_RES_DEATH
Resistance to death.
Skill getSkill(final int id)
Returns the given skill as a Skill object.
Interface for listeners interested in changes of Stats instances.
double getFloatStat(final int statNo)
Returns the numerical value of the given statistic.
static final int CS_STAT_RACE_DEX
The race's maximum dexterity primary stat.
static final int CS_STAT_BASE_CON
The constitution primary stat without boosts or depletions.
static final int CS_STAT_CHA
The Charisma Primary stat.
final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.
void setTitle(@NotNull final String title)
Sets the current Title.
void calculateExperienceToNextLevel()
Calculates the experience needed to reach the next level.
static final int CS_STAT_EXP64
The Global Experience (64bit encoding) stat.
static final int CS_STAT_APPLIED_CHA
The charisma primary stat changes due to gear or skills.
static final int CS_STAT_SPELL_REPEL
Repelled spell paths of a spell.
static final int CS_STAT_WC
The Weapon Class stat.
static final int C_STAT_POISONED
The "is poisoned" indicator.
Stores experience <-> level mappings.
static final int CS_STAT_EXP
The Global Experience (32bit encoding) stat.
static final int CS_STAT_BASE_WIS
The wisdom primary stat without boosts or depletions.
static final int C_STAT_WEIGHT
The character's weight.
final Collection< String > unhandledStats
All unhandled stat values for which an error has been printed.
static final int CS_STAT_BASE_DEX
The dexterity primary stat without boosts or depletions.
static final int CS_STAT_RESIST_END
End index of the resistances.
void setStatInt4(final int stat, final int param)
Updates a stat value with a four-byte int value.
final ExperienceTable experienceTable
The ExperienceTable instance to use.
static final int CS_STAT_RACE_POW
The race's maximum power primary stat.
static final int CS_STAT_RES_SLOW
Resistance to slowness.
static final int CS_STAT_INT
The Intelligence Primary stat.
void setStat(final int statNo, final int value)
Sets the given statistic numerical value.
final int [] stats
The current stat values.
static final int CS_STAT_FLAGS
The various flags used in stats.
This is the representation of all the statistics of a player, like its speed or its experience...
static final int CS_STAT_WEAP_SP
The Weapon Speed stat.
Maintain the set of skills as sent by the server.
static final int CS_STAT_MAXSP
The Maximum Spell Points stat.
void remove(@NotNull final T listener)
Removes a listener.
static final int CS_STAT_APPLIED_POW
The power primary stat changes due to gear or skills.
static final int CS_STAT_RES_POISON
Resistance to poison.
Connection progress states of the Crossfire server connection.
static final int CS_STAT_RES_HOLYWORD
Resistance to holy word.
static final int CS_STAT_RES_ACID
Resistance to acid.
String getTitle()
Returns the current title.
static final int CS_STAT_SPEED
The Speed stat.
String title
The current value of the title stat.
void setStatInt8(final int stat, final long param)
Updates a stat value with an eight-byte int value.
static final int CS_STAT_GRACE
The Grace stat.
static final int CS_STAT_BASE_CHA
The charisma primary stat without boosts or depletions.
static final int CS_STAT_APPLIED_WIS
The wisdom primary stat changes due to gear or skills.
static final int CS_STAT_ARMOUR
The Armour stat.
int getStat(final int statNo)
Returns the numerical value of the given statistic.