package net.sourceforge.pain.data;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.db.*;
import java.util.*;
public final class World extends DbObject {
private static final int NAME = 0;
private static final int TIME = 1;
private static final int PROTOTYPES_REGISTRY = 2;
private static final int RACES = 3;
private static final int INDEXED_SPACES_REGISTRY = 4;
private static final int FIRST_ACTIVE_PLAYER = 5;
private static final int RESET_GROUPS = 6;
private static final int PLAYERS_QUIT_SPACE = 7;
private static final int DEFAULT_BIRTH_SPACE = 8;
private static final int PLAYERS_REGISTRY = 9;
private static final int GUI_TOOL_ADMINS = 10;
private static final int TIME_AFFECTS_QUEUE = 11;
private static final int NFIELDS = 12;
public World() {
}
public World(PainDB db) throws Exception {
super(db);
// all these values aggregated!
setReference(TIME, new WorldTime(db));
setReference(PROTOTYPES_REGISTRY, new PrototypesRegistry(db));
setReference(INDEXED_SPACES_REGISTRY, new IndexedSpacesRegistry(db));
setReference(RESET_GROUPS, new ResetGroupRegistry(db));
setReference(PLAYERS_REGISTRY, new PlayersRegistry(db));
setReference(TIME_AFFECTS_QUEUE, new TimedAffectsQueue(db));
final Space quitSpace = (Space) ObjectFactory.create(Space.class);
quitSpace.setCapacity(Integer.MAX_VALUE);
quitSpace.setDesc("quit space");
quitSpace.setName("quit space");
setReference(PLAYERS_QUIT_SPACE, quitSpace);
}
public DbClassSchema provideSchema() {
byte types[] = new byte[NFIELDS];
String names[] = new String[NFIELDS];
types[NAME] = DbType.STRING;
names[NAME] = "name";
types[TIME] = DbType.REFERENCE;
names[TIME] = "time";
types[PROTOTYPES_REGISTRY] = DbType.REFERENCE;
names[PROTOTYPES_REGISTRY] = "prototypes_registry";
types[INDEXED_SPACES_REGISTRY] = DbType.REFERENCE;
names[INDEXED_SPACES_REGISTRY] = "indexed_spaces";
types[RACES] = DbType.REFERENCE_SET;
names[RACES] = "races";
types[FIRST_ACTIVE_PLAYER] = DbType.REFERENCE;
names[FIRST_ACTIVE_PLAYER] = "first_active_player";
types[RESET_GROUPS] = DbType.REFERENCE;
names[RESET_GROUPS] = "resets_groups";
types[PLAYERS_QUIT_SPACE] = DbType.REFERENCE;
names[PLAYERS_QUIT_SPACE] = "quit_players_space";
types[DEFAULT_BIRTH_SPACE] = DbType.REFERENCE;
names[DEFAULT_BIRTH_SPACE] = "default_birth_space";
types[PLAYERS_REGISTRY] = DbType.REFERENCE;
names[PLAYERS_REGISTRY] = "players_registry";
types[GUI_TOOL_ADMINS] = DbType.REFERENCE_SET;
names[GUI_TOOL_ADMINS] = "guitool_admins";
types[TIME_AFFECTS_QUEUE] = DbType.REFERENCE;
names[TIME_AFFECTS_QUEUE] = "timed_affects_queue";
return new DbClassSchema(types, names);
}
public void setName(String name) {
setString(NAME, name);
}
public String getName() {
return getString(NAME);
}
public WorldTime getWorldTime() {
return (WorldTime) getReference(TIME);
}
public Player getFirstActivePlayer() {
return (Player) getReference(FIRST_ACTIVE_PLAYER);
}
public void setFirstActivePlayer(Player p) {
setReference(FIRST_ACTIVE_PLAYER, p);
}
public PrototypesRegistry getPrototypesRegistry() {
return (PrototypesRegistry) getReference(PROTOTYPES_REGISTRY);
}
public IndexedSpacesRegistry getIndexedSpacesRegistry() {
return (IndexedSpacesRegistry) getReference(INDEXED_SPACES_REGISTRY);
}
public Set getRaces() {
return getRefSet(RACES);
}
public ResetGroupRegistry getResetGroupRegistry() {
return (ResetGroupRegistry) getReference(RESET_GROUPS);
}
public Space getPlayersQuitSpace() {
return (Space) getReference(PLAYERS_QUIT_SPACE);
}
public Space getDefaultBirthSpace() {
return (Space) getReference(DEFAULT_BIRTH_SPACE);
}
public void setDefaultBirthSpace(Space space) {
setReference(DEFAULT_BIRTH_SPACE, space);
}
public PlayersRegistry getPlayersRegistry() {
return (PlayersRegistry) getReference(PLAYERS_REGISTRY);
}
public Set getGuiToolAdmins() {
return getRefSet(GUI_TOOL_ADMINS);
}
public TimedAffectsQueue getAffectsQueue() {
return (TimedAffectsQueue) getReference(TIME_AFFECTS_QUEUE);
}
}