Crossfire JXClient, Trunk  R20561
StatsParser.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.stats;
23 
24 import java.util.HashMap;
25 import java.util.Map;
26 import org.jetbrains.annotations.NotNull;
27 
32 public class StatsParser {
33 
38  @NotNull
39  private static final Map<String, Integer> STAT_TABLE = new HashMap<>();
40 
41  static {
42  STAT_TABLE.put("AC", Stats.CS_STAT_AC);
43  STAT_TABLE.put("ARM", Stats.CS_STAT_ARMOUR);
44  STAT_TABLE.put("CHA", Stats.CS_STAT_CHA);
45  STAT_TABLE.put("CHA_APPLIED", Stats.CS_STAT_APPLIED_CHA);
46  STAT_TABLE.put("CHA_BASE", Stats.CS_STAT_BASE_CHA);
47  STAT_TABLE.put("CHA_RACE", Stats.CS_STAT_RACE_CHA);
48  STAT_TABLE.put("CON", Stats.CS_STAT_CON);
49  STAT_TABLE.put("CON_APPLIED", Stats.CS_STAT_APPLIED_CON);
50  STAT_TABLE.put("CON_BASE", Stats.CS_STAT_BASE_CON);
51  STAT_TABLE.put("CON_RACE", Stats.CS_STAT_RACE_CON);
52  STAT_TABLE.put("DAM", Stats.CS_STAT_DAM);
53  STAT_TABLE.put("DEX", Stats.CS_STAT_DEX);
54  STAT_TABLE.put("DEX_APPLIED", Stats.CS_STAT_APPLIED_DEX);
55  STAT_TABLE.put("DEX_BASE", Stats.CS_STAT_BASE_DEX);
56  STAT_TABLE.put("DEX_RACE", Stats.CS_STAT_RACE_DEX);
57  STAT_TABLE.put("EXP", Stats.CS_STAT_EXP64);
58  STAT_TABLE.put("EXP_NEXT_LEVEL", Stats.C_STAT_EXP_NEXT_LEVEL);
59  STAT_TABLE.put("FOOD", Stats.CS_STAT_FOOD);
60  STAT_TABLE.put("GOLEM_HP", Stats.CS_STAT_GOLEM_HP);
61  STAT_TABLE.put("GRACE", Stats.CS_STAT_GRACE);
62  STAT_TABLE.put("HP", Stats.CS_STAT_HP);
63  STAT_TABLE.put("INT", Stats.CS_STAT_INT);
64  STAT_TABLE.put("INT_APPLIED", Stats.CS_STAT_APPLIED_INT);
65  STAT_TABLE.put("INT_BASE", Stats.CS_STAT_BASE_INT);
66  STAT_TABLE.put("INT_RACE", Stats.CS_STAT_RACE_INT);
67  STAT_TABLE.put("LEVEL", Stats.CS_STAT_LEVEL);
68  STAT_TABLE.put("LOWFOOD", Stats.C_STAT_LOWFOOD);
69  STAT_TABLE.put("POISONED", Stats.C_STAT_POISONED);
70  STAT_TABLE.put("POW", Stats.CS_STAT_POW);
71  STAT_TABLE.put("POW_APPLIED", Stats.CS_STAT_APPLIED_POW);
72  STAT_TABLE.put("POW_BASE", Stats.CS_STAT_BASE_POW);
73  STAT_TABLE.put("POW_RACE", Stats.CS_STAT_RACE_POW);
74  STAT_TABLE.put("RANGE", Stats.CS_STAT_RANGE);
75  STAT_TABLE.put("RES_ACID", Stats.CS_STAT_RES_ACID);
76  STAT_TABLE.put("RES_BLIND", Stats.CS_STAT_RES_BLIND);
77  STAT_TABLE.put("RES_COLD", Stats.CS_STAT_RES_COLD);
78  STAT_TABLE.put("RES_CONF", Stats.CS_STAT_RES_CONF);
79  STAT_TABLE.put("RES_DEATH", Stats.CS_STAT_RES_DEATH);
80  STAT_TABLE.put("RES_DEPLETE", Stats.CS_STAT_RES_DEPLETE);
81  STAT_TABLE.put("RES_DRAIN", Stats.CS_STAT_RES_DRAIN);
82  STAT_TABLE.put("RES_ELEC", Stats.CS_STAT_RES_ELEC);
83  STAT_TABLE.put("RES_FEAR", Stats.CS_STAT_RES_FEAR);
84  STAT_TABLE.put("RES_FIRE", Stats.CS_STAT_RES_FIRE);
85  STAT_TABLE.put("RES_GHOSTHIT", Stats.CS_STAT_RES_GHOSTHIT);
86  STAT_TABLE.put("RES_HOLYWORD", Stats.CS_STAT_RES_HOLYWORD);
87  STAT_TABLE.put("RES_MAG", Stats.CS_STAT_RES_MAG);
88  STAT_TABLE.put("RES_PARA", Stats.CS_STAT_RES_PARA);
89  STAT_TABLE.put("RES_PHYS", Stats.CS_STAT_RES_PHYS);
90  STAT_TABLE.put("RES_POISON", Stats.CS_STAT_RES_POISON);
91  STAT_TABLE.put("RES_SLOW", Stats.CS_STAT_RES_SLOW);
92  STAT_TABLE.put("RES_TURN_UNDEAD", Stats.CS_STAT_RES_TURN_UNDEAD);
93  STAT_TABLE.put("SP", Stats.CS_STAT_SP);
94  STAT_TABLE.put("SPEED", Stats.CS_STAT_SPEED);
95  STAT_TABLE.put("STR", Stats.CS_STAT_STR);
96  STAT_TABLE.put("STR_APPLIED", Stats.CS_STAT_APPLIED_STR);
97  STAT_TABLE.put("STR_BASE", Stats.CS_STAT_BASE_STR);
98  STAT_TABLE.put("STR_RACE", Stats.CS_STAT_RACE_STR);
99  STAT_TABLE.put("TITLE", Stats.CS_STAT_TITLE);
100  STAT_TABLE.put("WC", Stats.CS_STAT_WC);
101  STAT_TABLE.put("WEIGHT", Stats.C_STAT_WEIGHT);
102  STAT_TABLE.put("WEIGHT_LIMIT", Stats.CS_STAT_WEIGHT_LIM);
103  STAT_TABLE.put("WIS", Stats.CS_STAT_WIS);
104  STAT_TABLE.put("WIS_APPLIED", Stats.CS_STAT_APPLIED_WIS);
105  STAT_TABLE.put("WIS_BASE", Stats.CS_STAT_BASE_WIS);
106  STAT_TABLE.put("WIS_RACE", Stats.CS_STAT_RACE_WIS);
107  STAT_TABLE.put("WEAPON_SPEED", Stats.CS_STAT_WEAP_SP);
108  }
109 
113  private StatsParser() {
114  }
115 
122  public static int parseStat(@NotNull final String name) {
123  if (!STAT_TABLE.containsKey(name)) {
124  throw new IllegalArgumentException("undefined stat '"+name+"'");
125  }
126 
127  return STAT_TABLE.get(name);
128  }
129 
130 }
static final int CS_STAT_GOLEM_HP
The golem&#39;s hitpoints, 0 if no golem.
Definition: Stats.java:319
static final int CS_STAT_RES_BLIND
Resistance to blindness.
Definition: Stats.java:424
StatsParser()
Private constructor to prevent instantiation.
static final int CS_STAT_RACE_CHA
The race&#39;s maximum charisma primary stat.
Definition: Stats.java:239
static final int CS_STAT_DEX
The Dexterity Primary stat.
Definition: Stats.java:83
static final int CS_STAT_TITLE
The Title stat.
Definition: Stats.java:159
static final int CS_STAT_RANGE
The Range stat - this is what is currently readied by the player to fire.
Definition: Stats.java:154
static final int CS_STAT_APPLIED_CON
The constitution primary stat changes due to gear or skills.
Definition: Stats.java:304
static final int CS_STAT_BASE_POW
The power primary stat without boosts or depletions.
Definition: Stats.java:279
static final int CS_STAT_POW
The Power Primary stat.
Definition: Stats.java:164
static final int CS_STAT_APPLIED_INT
The integer primary stat changes due to gear or skills.
Definition: Stats.java:289
static final int C_STAT_LOWFOOD
The Low Food indicator.
Definition: Stats.java:143
static final int CS_STAT_RES_TURN_UNDEAD
Resistance to turn undead.
Definition: Stats.java:399
static final int CS_STAT_HP
The Hit Points stat.
Definition: Stats.java:48
static final int CS_STAT_LEVEL
The Global Level stat.
Definition: Stats.java:108
static final int CS_STAT_RACE_WIS
The race&#39;s maximum wisdom primary stat.
Definition: Stats.java:224
Utility class to parse stat names.
static final int CS_STAT_DAM
The Damage stat.
Definition: Stats.java:123
static final int CS_STAT_STR
The Strength Primary stat.
Definition: Stats.java:68
static final int CS_STAT_AC
The Armor Class stat.
Definition: Stats.java:118
static final int CS_STAT_RES_FIRE
Resistance to fire.
Definition: Stats.java:349
static final int CS_STAT_FOOD
The Food stat.
Definition: Stats.java:138
static final int CS_STAT_WIS
The Wisdom Primary stat.
Definition: Stats.java:78
static final int CS_STAT_BASE_INT
The integer primary stat without boosts or depletions.
Definition: Stats.java:254
static final int CS_STAT_SP
The Spell Points stat.
Definition: Stats.java:58
static final int CS_STAT_RACE_CON
The race&#39;s maximum constitution primary stat.
Definition: Stats.java:234
static final int CS_STAT_WEIGHT_LIM
The Weight Limit stat.
Definition: Stats.java:184
static final int CS_STAT_APPLIED_STR
The strength primary stat changes due to gear or skills.
Definition: Stats.java:284
static final int CS_STAT_BASE_STR
The strength primary stat without boosts or depletions.
Definition: Stats.java:249
static final int CS_STAT_RES_DRAIN
Resistance to drain life.
Definition: Stats.java:374
static final int CS_STAT_RES_PHYS
Resistance to physical attacks.
Definition: Stats.java:339
static final int CS_STAT_CON
The Constitution Primary stat.
Definition: Stats.java:88
static final int CS_STAT_RACE_STR
The race&#39;s maximum strength primary stat.
Definition: Stats.java:214
static final int CS_STAT_RES_PARA
Resistance to paralysis.
Definition: Stats.java:394
static final int CS_STAT_RES_DEPLETE
Resistance to depletion.
Definition: Stats.java:409
static final int CS_STAT_RES_ELEC
Resistance to electricity.
Definition: Stats.java:354
static final int CS_STAT_RES_MAG
Resistance to magical attacks.
Definition: Stats.java:344
static final int CS_STAT_APPLIED_DEX
The dexterity primary stat changes due to gear or skills.
Definition: Stats.java:299
static final int CS_STAT_RES_COLD
Resistance to cold.
Definition: Stats.java:359
static final int CS_STAT_RES_GHOSTHIT
Resistance to ghost hit.
Definition: Stats.java:379
static final int C_STAT_EXP_NEXT_LEVEL
The global experience needed to reach next level stat.
Definition: Stats.java:103
static final int CS_STAT_RES_FEAR
Resistance to fear.
Definition: Stats.java:404
static final Map< String, Integer > STAT_TABLE
Maps stat names to stat index values.
static final int CS_STAT_RACE_INT
The race&#39;s maximum intelligence primary stat.
Definition: Stats.java:219
static final int CS_STAT_RES_CONF
Resistance to confusion.
Definition: Stats.java:364
static final int CS_STAT_RES_DEATH
Resistance to death.
Definition: Stats.java:414
static final int CS_STAT_RACE_DEX
The race&#39;s maximum dexterity primary stat.
Definition: Stats.java:229
static final int CS_STAT_BASE_CON
The constitution primary stat without boosts or depletions.
Definition: Stats.java:269
static final int CS_STAT_CHA
The Charisma Primary stat.
Definition: Stats.java:93
static final int CS_STAT_EXP64
The Global Experience (64bit encoding) stat.
Definition: Stats.java:194
static final int CS_STAT_APPLIED_CHA
The charisma primary stat changes due to gear or skills.
Definition: Stats.java:309
static final int CS_STAT_WC
The Weapon Class stat.
Definition: Stats.java:113
static final int C_STAT_POISONED
The "is poisoned" indicator.
Definition: Stats.java:440
static final int CS_STAT_BASE_WIS
The wisdom primary stat without boosts or depletions.
Definition: Stats.java:259
static final int C_STAT_WEIGHT
The character&#39;s weight.
Definition: Stats.java:189
static final int CS_STAT_BASE_DEX
The dexterity primary stat without boosts or depletions.
Definition: Stats.java:264
static final int CS_STAT_RACE_POW
The race&#39;s maximum power primary stat.
Definition: Stats.java:244
static final int CS_STAT_RES_SLOW
Resistance to slowness.
Definition: Stats.java:389
static final int CS_STAT_INT
The Intelligence Primary stat.
Definition: Stats.java:73
This is the representation of all the statistics of a player, like its speed or its experience...
Definition: Stats.java:43
static final int CS_STAT_WEAP_SP
The Weapon Speed stat.
Definition: Stats.java:148
static final int CS_STAT_APPLIED_POW
The power primary stat changes due to gear or skills.
Definition: Stats.java:314
static final int CS_STAT_RES_POISON
Resistance to poison.
Definition: Stats.java:384
static final int CS_STAT_RES_HOLYWORD
Resistance to holy word.
Definition: Stats.java:419
static final int CS_STAT_RES_ACID
Resistance to acid.
Definition: Stats.java:369
static final int CS_STAT_SPEED
The Speed stat.
Definition: Stats.java:133
static final int CS_STAT_GRACE
The Grace stat.
Definition: Stats.java:169
static final int CS_STAT_BASE_CHA
The charisma primary stat without boosts or depletions.
Definition: Stats.java:274
static int parseStat(@NotNull final String name)
Converts a stat name into a stat index.
static final int CS_STAT_APPLIED_WIS
The wisdom primary stat changes due to gear or skills.
Definition: Stats.java:294
static final int CS_STAT_ARMOUR
The Armour stat.
Definition: Stats.java:128