For my program I have a large number of Public static int, it's mainly a readability thing so I can do something like SkillsArray[Archery] = 25
to see at a glance that the "archery skill" has a value/level/rank of 25 instead of trying to figure out what SkillsArray[7] = 25
is supposed to mean.
It's basically naming the unique Id to be used in a relational database structure but if I want to print those names I nave to build a function that takes a int argument that reads a huge if/else tree to spit out a string with the name "Archery" or "cooking" or whatever.
I'd like to replace all those functions with something simple like
String printStaticName() {
return this.getClass().getName();
}
which can read the primitive attached to it and get its name but Eclipse tells me I can't do those kind of operations on a primitive type. Ideas?
A example of how I currently use the system i have.
//races
public static final int Chosen = 0;
public static final int Native = 1;
public static final int High_Elf = 2;
public static final int Wood_Elf = 3;
public static final int Gremlin = 4;
public static final int Goblin = 5;
public static final int Hobgoblin = 6;
....
String getRaceNameString(int r){
String temp = "No Race Set";
if (r == Chosen){temp = "Chosen";};
if (r == Native){temp = "Native";};
if (r == High_Elf){temp = "High Elf";};
if (r == Wood_Elf){temp = "Wood Elf";};
if (r == Gremlin){temp = "Gremlin";};
if (r == Goblin){temp = "Goblin";};
if (r == Hobgoblin){temp = "Hobgoblin";};
return temp;
}//close getRaceNameString
int getRaceIDFromString(String r){
int result = 0;
if (r == "Chosen"){result = Chosen;};
if (r == "Native"){result = Native;};
if (r == "High Elf"){result = High_Elf;};
if (r == "Wood Elf"){result = Wood_Elf;};
if (r == "Gremlin"){result = Gremlin;};
if (r == "Goblin"){result = Goblin;};
if (r == "Hobgoblin"){result = Hobgoblin;};
return result;
}//close getraceIDFromString()
class Race extends WoSCharacter {
private int raceID = Chosen;
private double purity = 1;
private String active_headshot = "headshot.jpg";
private String active_fullbody = "TemplateforPortrait.png";
private String Description;
private double minHeight;
private double maxHeight;
private int AttributeMods[] = new int[9];
private double lifespan;
private boolean isModRace = false;
void setRace(int RName, long pure, int gender){
purity = pure;
raceID = RName;
switch (raceID){
//region case
case Chosen:
AttributeMods[STR] = 5;
AttributeMods[DEX] = 5;
AttributeMods[CON] = 5;
AttributeMods[CHA] = 5;
AttributeMods[PER] = 5;
AttributeMods[WIL] = 5;
AttributeMods[INT] = 5;
AttributeMods[INS] = 5;
AttributeMods[WIS] = 5;
active_headshot = "headshot.jpg";
Description = "The race of man are the sole survivors of the Mage Wars that took destroyed magic and everything but the animal races and humanity. Now they are facing their own extinction as the Black Plague washes over the world, crossing continents and destroying entire family lines. Some of mankind have developed an immunity, being christened 'the chosen' but this this comes at cost as they are further divorced from the just now returning powers of magic.";
minHeight = 150;
maxHeight = 170;
lifespan = 50;
if (gender == MALE){
active_headshot = "male_headshot.jpg";
active_fullbody = "TemplateforPortrait.png";
minHeight = 162;
maxHeight = 190;
lifespan = 49;
}else if (gender == FEMALE){
active_headshot = "Fem_headshot.jpg";
active_fullbody = "Fantasy_Landscape_01.jpg";
minHeight = 150;
maxHeight = 170;
lifespan = 43;
}//gender headshot switch
break;
//endregion case
case Native:
AttributeMods[STR] = 5;
AttributeMods[DEX] = 5;
AttributeMods[CON] = 5;
AttributeMods[CHA] = 5;
AttributeMods[PER] = 5;
AttributeMods[WIL] = 5;
AttributeMods[INT] = 5;
AttributeMods[INS] = 5;
AttributeMods[WIS] = 5;
active_headshot = "headshot.jpg";
Description = "The race of man are the sole survivors of the Mage Wars that took destroyed magic and everything but the animal races and humanity. Now they are facing their own extinction as the Black Plague washes over the world, crossing continents and destroying entire family lines. Some of mankind have developed an immunity, being christened 'the chosen' but this this comes at cost as they are further divorced from the just now returning powers of magic.";
minHeight = 150;
maxHeight = 170;
lifespan = 49;
if (gender == MALE){
active_headshot = "male_headshot.jpg";
active_fullbody = "TemplateforPortrait.png";
minHeight = 162;
maxHeight = 190;
lifespan = 49;
}else if (gender == FEMALE){
active_headshot = "Fem_headshot.jpg";
active_fullbody = "TemplateforPortrait.png";
minHeight = 150;
maxHeight = 170;
lifespan = 43;
}//gender headshot switch
break;
}
}