Stick the players array in the game object; also implemented toString().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@467 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-10-17 02:48:57 +00:00
parent f863620d39
commit 9e6c104015
2 changed files with 33 additions and 7 deletions
@@ -1,5 +1,5 @@
//
// $Id: GameManager.java,v 1.10 2001/10/12 19:30:44 mdb Exp $
// $Id: GameManager.java,v 1.11 2001/10/17 02:48:57 mdb Exp $
package com.threerings.parlor.game;
@@ -55,11 +55,11 @@ public class GameManager
*/
public void setPlayers (String[] players)
{
// keep this info for later
// keep this around for now, we'll need it later
_players = players;
// instantiate a player oid array which we'll fill in later
_playerOids = new int[_players.length];
_playerOids = new int[players.length];
}
// documentation inherited
@@ -70,6 +70,9 @@ public class GameManager
// obtain a casted reference to our game object
_gameobj = (GameObject)_plobj;
// stick the players into the game object
_gameobj.setPlayers(_players);
// let the players of this game know that we're ready to roll (if
// we have a specific set of players)
if (_players != null) {
@@ -197,12 +200,12 @@ public class GameManager
/** A reference to our game configuration. */
protected GameConfig _gconfig;
/** The usernames of the players of this game. */
protected String[] _players;
/** A reference to our game object. */
protected GameObject _gameobj;
/** The usernames of the players of this game. */
protected String[] _players;
/** The oids of our player's body objects. */
protected int[] _playerOids;
}
@@ -1,8 +1,9 @@
//
// $Id: GameObject.dobj,v 1.4 2001/10/11 21:08:21 mdb Exp $
// $Id: GameObject.dobj,v 1.5 2001/10/17 02:48:57 mdb Exp $
package com.threerings.parlor.game;
import com.samskivert.util.StringUtil;
import com.threerings.crowd.data.PlaceObject;
/**
@@ -23,6 +24,9 @@ public class GameObject extends PlaceObject
/** The field name of the <code>isRated</code> field. */
public static final String IS_RATED = "isRated";
/** The field name of the <code>players</code> 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;
@@ -43,6 +47,9 @@ public class GameObject extends PlaceObject
/** 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 <code>state</code> field be set to the specified
* value. */
public void setState (int state)
@@ -56,4 +63,20 @@ public class GameObject extends PlaceObject
{
requestAttributeChange(IS_RATED, new Boolean(isRated));
}
/** Requests that the <code>players</code> field be set to the
* specified value. */
public void setPlayers (String[] value)
{
requestAttributeChange(PLAYERS, value);
}
// documentation inherited
protected void toString (StringBuffer buf)
{
super.toString(buf);
buf.append(", state=").append(state);
buf.append(", isRated=").append(isRated);
buf.append(", players=").append(StringUtil.toString(players));
}
}