package net.sourceforge.pain.data.type;
import net.sourceforge.pain.data.*;
import net.sourceforge.pain.db.*;
/**
Any object with this type is a _Life_Form.
Even non-physical ones :)
*/
public final class LifeForm extends Role {
public static final int MAX_LIFE_POINTS = 1 + LAST_BASE_FIELD_INDEX;
public static final int LIFE_POINTS = 2 + LAST_BASE_FIELD_INDEX;
public static final int RACE = 3 + LAST_BASE_FIELD_INDEX;
public static final int SEX = 4 + LAST_BASE_FIELD_INDEX;
public static final int NFIELDS = 5 + LAST_BASE_FIELD_INDEX;
/**
* only 3 values allowed for sex. If you wnat to have more mystical ones you should name it by different name
* in different role.
*/
public static final int SEX_UNDEFINED = 0;
public static final int SEX_MALE = 1;
public static final int SEX_FEMALE = 2;
public final static Class superroles[] = new Class[]{Interactive.class};
public LifeForm(PainDB db) {
super(db);
}
public LifeForm() {
}
public Class[] getSuperroles() {
return superroles;
}
public DbClassSchema provideSchema() {
byte types[] = new byte[NFIELDS];
String names[] = new String[NFIELDS];
fillSuperSchema(types, names);
types[MAX_LIFE_POINTS] = DbType.INT;
names[MAX_LIFE_POINTS] = "max_life_points";
types[LIFE_POINTS] = DbType.INT;
names[LIFE_POINTS] = "life_points";
types[RACE] = DbType.REFERENCE;
names[RACE] = "race";
types[SEX] = DbType.INT;
names[SEX] = "sex";
return new DbClassSchema(types, names);
}
public void setLifePoints(int value) {
setInt(LIFE_POINTS, value);
}
public void setMaxLifePoints(int value) {
setInt(MAX_LIFE_POINTS, value);
}
public int getLifePoints() {
return getInt(LIFE_POINTS);
}
public int getMaxLifePoints() {
return getInt(MAX_LIFE_POINTS);
}
public Interactive asInteractive() {
return (Interactive) getRole(Interactive.class);
}
public Race getRace() {
return (Race) getReference(RACE);
}
public void setRace(Race race) {
setReference(RACE, race);
}
public int getSex() {
return getInt(SEX);
}
public void setSex(int sex) {
setInt(SEX, sex);
}
public boolean isMale() {
return getSex() == SEX_MALE;
}
public boolean isFemale() {
return getSex() == SEX_FEMALE;
}
}