diff --git a/src/java/com/threerings/micasa/lobby/LobbyObject.dobj b/src/java/com/threerings/micasa/lobby/LobbyObject.dobj index e402fcbc6..e004324bc 100644 --- a/src/java/com/threerings/micasa/lobby/LobbyObject.dobj +++ b/src/java/com/threerings/micasa/lobby/LobbyObject.dobj @@ -1,10 +1,15 @@ // -// $Id: LobbyObject.dobj,v 1.3 2001/10/11 04:13:33 mdb Exp $ +// $Id: LobbyObject.dobj,v 1.4 2002/02/08 23:55:24 mdb Exp $ package com.threerings.micasa.lobby; import com.threerings.crowd.data.PlaceObject; +/** + * Presently the lobby object contains nothing specific, but the class + * acts as a placeholder in case lobby-wide fields are needed in the + * future. + */ public class LobbyObject extends PlaceObject { } diff --git a/src/java/com/threerings/micasa/lobby/LobbyObject.java b/src/java/com/threerings/micasa/lobby/LobbyObject.java new file mode 100644 index 000000000..79b097e6b --- /dev/null +++ b/src/java/com/threerings/micasa/lobby/LobbyObject.java @@ -0,0 +1,15 @@ +// +// $Id: LobbyObject.java,v 1.1 2002/02/08 23:55:24 mdb Exp $ + +package com.threerings.micasa.lobby; + +import com.threerings.crowd.data.PlaceObject; + +/** + * Presently the lobby object contains nothing specific, but the class + * acts as a placeholder in case lobby-wide fields are needed in the + * future. + */ +public class LobbyObject extends PlaceObject +{ +} diff --git a/src/java/com/threerings/micasa/lobby/table/TableListView.java b/src/java/com/threerings/micasa/lobby/table/TableListView.java index 9eafd26a4..175e793c8 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableListView.java +++ b/src/java/com/threerings/micasa/lobby/table/TableListView.java @@ -1,5 +1,5 @@ // -// $Id: TableListView.java,v 1.2 2001/10/23 23:52:01 mdb Exp $ +// $Id: TableListView.java,v 1.3 2002/02/08 23:55:24 mdb Exp $ package com.threerings.micasa.lobby.table; @@ -59,7 +59,7 @@ public class TableListView _ctx = ctx; // create our table director - _tdtr = new TableDirector(ctx, TableLobbyObject.TABLES, this); + _tdtr = new TableDirector(ctx, TableLobbyObject.TABLE_SET, this); // add ourselves as a seatedness observer _tdtr.addSeatednessObserver(this); @@ -132,7 +132,7 @@ public class TableListView // iterate over the tables already active in this lobby and put // them in their respective lists TableLobbyObject tlobj = (TableLobbyObject)place; - Iterator iter = tlobj.tables.elements(); + Iterator iter = tlobj.tableSet.elements(); while (iter.hasNext()) { tableAdded((Table)iter.next()); } diff --git a/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.dobj b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.dobj index 5816d14b4..9d3b5bc7e 100644 --- a/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.dobj +++ b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.dobj @@ -1,5 +1,5 @@ // -// $Id: TableLobbyObject.dobj,v 1.1 2001/10/23 20:24:10 mdb Exp $ +// $Id: TableLobbyObject.dobj,v 1.2 2002/02/08 23:55:24 mdb Exp $ package com.threerings.micasa.lobby.table; @@ -11,51 +11,30 @@ public class TableLobbyObject extends LobbyObject implements com.threerings.parlor.data.TableLobbyObject { - /** The field name of the tables field. */ - public static final String TABLES = "tables"; - /** A set containing all of the tables being managed by this lobby. */ - public DSet tables = new DSet(Table.class); + public DSet tableSet = new DSet(Table.class); // documentation inherited public DSet getTables () { - return tables; + return tableSet; } - /** - * Requests that the tables field be set to the specified - * value. - */ - public void setTables (DSet value) - { - requestAttributeChange(TABLES, value); - } - - /** - * Requests that the specified element be added to the - * tables set. - */ + // documentation inherited from interface public void addToTables (Table table) { - requestElementAdd(TABLES, table); + addToTableSet(table); } - /** - * Requests that the specified element be updated in the - * tables set. - */ + // documentation inherited from interface public void updateTables (Table table) { - requestElementUpdate(TABLES, table); + updateTableSet(table); } - /** - * Requests that the element matching the supplied key be removed from - * the tables set. - */ + // documentation inherited from interface public void removeFromTables (Object key) { - requestElementRemove(TABLES, key); + removeFromTableSet(key); } } diff --git a/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java new file mode 100644 index 000000000..db625aefa --- /dev/null +++ b/src/java/com/threerings/micasa/lobby/table/TableLobbyObject.java @@ -0,0 +1,81 @@ +// +// $Id: TableLobbyObject.java,v 1.1 2002/02/08 23:55:24 mdb Exp $ + +package com.threerings.micasa.lobby.table; + +import com.threerings.presents.dobj.DSet; +import com.threerings.parlor.data.Table; +import com.threerings.micasa.lobby.LobbyObject; + +public class TableLobbyObject + extends LobbyObject + implements com.threerings.parlor.data.TableLobbyObject +{ + /** The field name of the tableSet field. */ + public static final String TABLE_SET = "tableSet"; + + /** A set containing all of the tables being managed by this lobby. */ + public DSet tableSet = new DSet(Table.class); + + // documentation inherited + public DSet getTables () + { + return tableSet; + } + + // documentation inherited from interface + public void addToTables (Table table) + { + addToTableSet(table); + } + + // documentation inherited from interface + public void updateTables (Table table) + { + updateTableSet(table); + } + + // documentation inherited from interface + public void removeFromTables (Object key) + { + removeFromTableSet(key); + } + + /** + * Requests that the specified element be added to the + * tableSet set. + */ + public void addToTableSet (DSet.Element elem) + { + requestElementAdd(TABLE_SET, elem); + } + + /** + * Requests that the element matching the supplied key be removed from + * the tableSet set. + */ + public void removeFromTableSet (Object key) + { + requestElementRemove(TABLE_SET, key); + } + + /** + * Requests that the specified element be updated in the + * tableSet set. + */ + public void updateTableSet (DSet.Element elem) + { + requestElementUpdate(TABLE_SET, elem); + } + + /** + * Requests that the tableSet field be set to the + * specified value. Generally one only adds, updates and removes + * elements of a distributed set, but certain situations call for a + * complete replacement of the set value. + */ + public void setTableSet (DSet value) + { + requestAttributeChange(TABLE_SET, value); + } +} diff --git a/src/java/com/threerings/parlor/game/GameObject.dobj b/src/java/com/threerings/parlor/game/GameObject.dobj index 0e59c0f90..ab2d19516 100644 --- a/src/java/com/threerings/parlor/game/GameObject.dobj +++ b/src/java/com/threerings/parlor/game/GameObject.dobj @@ -1,5 +1,5 @@ // -// $Id: GameObject.dobj,v 1.6 2002/02/04 01:47:20 mdb Exp $ +// $Id: GameObject.dobj,v 1.7 2002/02/08 23:55:25 mdb Exp $ package com.threerings.parlor.game; @@ -18,15 +18,6 @@ import com.threerings.crowd.data.PlaceObject; */ public class GameObject extends PlaceObject { - /** The field name of the state field. */ - public static final String STATE = "state"; - - /** The field name of the isRated field. */ - public static final String IS_RATED = "isRated"; - - /** The field name of the players field. */ - public static final String PLAYERS = "players"; - /** A game state constant indicating that the game has not yet started * and is still awaiting the arrival of all of the players. */ public static final int AWAITING_PLAYERS = 0; @@ -49,25 +40,4 @@ public class GameObject extends PlaceObject /** The username of the players involved in this game. */ public String[] players; - - /** Requests that the state field be set to the specified - * value. */ - public void setState (int state) - { - requestAttributeChange(STATE, new Integer(state)); - } - - /** Requests that the isRated field be set to the - * specified value. */ - public void setIsRated (boolean isRated) - { - requestAttributeChange(IS_RATED, new Boolean(isRated)); - } - - /** Requests that the players field be set to the - * specified value. */ - public void setPlayers (String[] value) - { - requestAttributeChange(PLAYERS, value); - } } diff --git a/src/java/com/threerings/parlor/game/GameObject.java b/src/java/com/threerings/parlor/game/GameObject.java new file mode 100644 index 000000000..4b3da6988 --- /dev/null +++ b/src/java/com/threerings/parlor/game/GameObject.java @@ -0,0 +1,115 @@ +// +// $Id: GameObject.java,v 1.1 2002/02/08 23:55:25 mdb Exp $ + +package com.threerings.parlor.game; + +import com.samskivert.util.StringUtil; +import com.threerings.crowd.data.PlaceObject; + +/** + * A game object hosts the shared data associated with a game played by + * one or more players. The game object extends the place object so that + * the game can act as a place where players actually go when playing the + * game. Only very basic information is maintained in the base game + * object. It serves as the base for a hierarchy of game object + * derivatives that handle basic gameplay for a suite of different game + * types (ie. turn based games, party games, board games, card games, + * etc.). + */ +public class GameObject extends PlaceObject +{ + /** The field name of the state field. */ + public static final String STATE = "state"; + + /** The field name of the isRated field. */ + public static final String IS_RATED = "isRated"; + + /** The field name of the players field. */ + public static final String PLAYERS = "players"; + + /** A game state constant indicating that the game has not yet started + * and is still awaiting the arrival of all of the players. */ + public static final int AWAITING_PLAYERS = 0; + + /** A game state constant indicating that the game is in play. */ + public static final int IN_PLAY = 1; + + /** A game state constant indicating that the game ended normally. */ + public static final int GAME_OVER = 2; + + /** A game state constant indicating that the game was cancelled. */ + public static final int CANCELLED = 3; + + /** The game state, one of {@link #AWAITING_PLAYERS}, {@link #IN_PLAY}, + * {@link #GAME_OVER}, or {@link #CANCELLED}. */ + public int state; + + /** Indicates whether or not this game is rated. */ + public boolean isRated; + + /** The username of the players involved in this game. */ + public String[] players; + + /** + * Requests that the state field be set to the specified + * value. + */ + public void setState (int state) + { + requestAttributeChange(STATE, new Integer(state)); + } + + /** + * Requests that the state field be set to the + * specified value and immediately updates the state of the object + * to reflect the change. This should only be called on the + * server and only then if you know what you're doing. + */ + public void setStateImmediate (int state) + { + this.state = state; + requestAttributeChange(STATE, new Integer(state)); + } + + /** + * Requests that the isRated field be set to the specified + * value. + */ + public void setIsRated (boolean isRated) + { + requestAttributeChange(IS_RATED, new Boolean(isRated)); + } + + /** + * Requests that the isRated field be set to the + * specified value and immediately updates the state of the object + * to reflect the change. This should only be called on the + * server and only then if you know what you're doing. + */ + public void setIsRatedImmediate (boolean isRated) + { + this.isRated = isRated; + requestAttributeChange(IS_RATED, new Boolean(isRated)); + } + + /** + * Requests that the players field be set to the specified + * value. + */ + public void setPlayers (String[] players) + { + requestAttributeChange(PLAYERS, players); + } + + /** + * Requests that the players field be set to the + * specified value and immediately updates the state of the object + * to reflect the change. This should only be called on the + * server and only then if you know what you're doing. + */ + public void setPlayersImmediate (String[] players) + { + this.players = players; + requestAttributeChange(PLAYERS, players); + } +} diff --git a/src/java/com/threerings/parlor/turn/TurnGameObject.dobj b/src/java/com/threerings/parlor/turn/TurnGameObject.dobj index e800b5069..c8657fba0 100644 --- a/src/java/com/threerings/parlor/turn/TurnGameObject.dobj +++ b/src/java/com/threerings/parlor/turn/TurnGameObject.dobj @@ -1,5 +1,5 @@ // -// $Id: TurnGameObject.dobj,v 1.3 2002/02/04 01:47:20 mdb Exp $ +// $Id: TurnGameObject.dobj,v 1.4 2002/02/08 23:55:25 mdb Exp $ package com.threerings.parlor.turn; @@ -10,18 +10,8 @@ import com.threerings.parlor.game.GameObject; */ public class TurnGameObject extends GameObject { - /** The field name of the turnHolder field. */ - public static final String TURN_HOLDER = "turnHolder"; - /** The username of the player who is currently taking their turn in * this turn-based game or null if no user currently holds the * turn. */ public String turnHolder; - - /** Requests that the turnHolder field be set to the - * specified value. */ - public void setTurnHolder (String turnHolder) - { - requestAttributeChange(TURN_HOLDER, turnHolder); - } } diff --git a/src/java/com/threerings/parlor/turn/TurnGameObject.java b/src/java/com/threerings/parlor/turn/TurnGameObject.java new file mode 100644 index 000000000..c20847269 --- /dev/null +++ b/src/java/com/threerings/parlor/turn/TurnGameObject.java @@ -0,0 +1,41 @@ +// +// $Id: TurnGameObject.java,v 1.1 2002/02/08 23:55:25 mdb Exp $ + +package com.threerings.parlor.turn; + +import com.threerings.parlor.game.GameObject; + +/** + * Extends the basic game object with support for turn-based games. + */ +public class TurnGameObject extends GameObject +{ + /** The field name of the turnHolder field. */ + public static final String TURN_HOLDER = "turnHolder"; + + /** The username of the player who is currently taking their turn in + * this turn-based game or null if no user currently holds the + * turn. */ + public String turnHolder; + + /** + * Requests that the turnHolder field be set to the specified + * value. + */ + public void setTurnHolder (String turnHolder) + { + requestAttributeChange(TURN_HOLDER, turnHolder); + } + + /** + * Requests that the turnHolder field be set to the + * specified value and immediately updates the state of the object + * to reflect the change. This should only be called on the + * server and only then if you know what you're doing. + */ + public void setTurnHolderImmediate (String turnHolder) + { + this.turnHolder = turnHolder; + requestAttributeChange(TURN_HOLDER, turnHolder); + } +}