package net.sourceforge.pain.data.type; import net.sourceforge.pain.data.*; import net.sourceforge.pain.db.*; /** * Mobile objects have an ability to move from one space to another. <br> * Mobiles are not required to be LifeForms or even Interactive objects.<br> * So it can be a some king of system object that browse the world and make it's own task<br> * or this role could be a part of more complex object - example: Players usually mobile (have an ability to move)<br> * Mobile objects are required to be {@link Located} (have role named Located) */ public final class Mobile extends Role { public static final int MAX_MOVES = 1 + LAST_BASE_FIELD_INDEX; public static final int MOVES = 2 + LAST_BASE_FIELD_INDEX; public static final int NFIELDS = 3 + LAST_BASE_FIELD_INDEX; public final static Class[] superroles = new Class[]{Located.class}; public Mobile(PainDB db) { super(db); } public Mobile() { } public DbClassSchema provideSchema() { byte types[] = new byte[NFIELDS]; String names[] = new String[NFIELDS]; fillSuperSchema(types, names); types[MAX_MOVES] = DbType.INT; names[MAX_MOVES] = "max_moves"; types[MOVES] = DbType.INT; names[MOVES] = "moves"; return new DbClassSchema(types, names); } public void setMoves(int value) { setInt(MOVES, value); } public void setMaxMoves(int value) { setInt(MAX_MOVES, value); } public int getMoves() { return getInt(MOVES); } public int getMaxMoves() { return getInt(MAX_MOVES); } public Class[] getSuperroles() { return superroles; } public Located asLocated() { return (Located) getRole(Located.class); } }