package net.sourceforge.pain.tinylib.data;
import net.sourceforge.pain.data.*;
import net.sourceforge.pain.db.*;
import net.sourceforge.pain.tinylib.data.type.*;
import java.util.*;
public final class World extends DbObject {
private static final int NAME = 0;
private static final int PROTOTYPES_REGISTRY = 1;
private static final int RACES = 2;
private static final int ROOMS_REGISTRY = 3;
private static final int FIRST_ACTIVE_PLAYER = 4;
private static final int RESET_GROUPS_REGISTRY = 5;
private static final int SPACE_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 BAN_REGISTRY = 10;
private static final int NFIELDS = 11;
public World() {
}
public World(PainDB db) throws Exception {
super(db);
// all these values aggregated!
setReference(PROTOTYPES_REGISTRY, new PrototypesRegistry(db));
setReference(ROOMS_REGISTRY, new RoomsRegistry(db));
setReference(RESET_GROUPS_REGISTRY, new ResetGroupRegistry(db));
setReference(PLAYERS_REGISTRY, new PlayersRegistry(db));
setReference(BAN_REGISTRY, new BanRegistry(db));
final Space quitSpace = (Space) ObjectFactory.createRaw(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[PROTOTYPES_REGISTRY] = DbType.REFERENCE;
names[PROTOTYPES_REGISTRY] = "prototypes_registry";
types[ROOMS_REGISTRY] = DbType.REFERENCE;
names[ROOMS_REGISTRY] = "rooms_registry";
types[RACES] = DbType.REFERENCE_SET;
names[RACES] = "races";
types[FIRST_ACTIVE_PLAYER] = DbType.REFERENCE;
names[FIRST_ACTIVE_PLAYER] = "first_active_player";
types[RESET_GROUPS_REGISTRY] = DbType.REFERENCE;
names[RESET_GROUPS_REGISTRY] = "resets_groups_registry";
types[SPACE_GROUPS] = DbType.LINKED_LIST;
names[SPACE_GROUPS] = "space_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[BAN_REGISTRY] = DbType.REFERENCE;
names[BAN_REGISTRY] = "ban_info";
return new DbClassSchema(types, names);
}
public void setName(String name) {
setString(NAME, name);
}
public String getName() {
return getString(NAME);
}
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 RoomsRegistry getRoomsRegistry() {
return (RoomsRegistry) getReference(ROOMS_REGISTRY);
}
public Set getRaces() {
return getRefSet(RACES);
}
public ResetGroupRegistry getResetGroupRegistry() {
return (ResetGroupRegistry) getReference(RESET_GROUPS_REGISTRY);
}
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 List getSpaceGroups() {
return getLinkedList(SPACE_GROUPS);
}
public BanRegistry getBanRegistry() {
return (BanRegistry) getReference(BAN_REGISTRY);
}
}