From 9e6c104015106ba665f220c633bb97e75ab0fe40 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 17 Oct 2001 02:48:57 +0000 Subject: [PATCH] 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 --- .../threerings/parlor/game/GameManager.java | 15 ++++++----- .../threerings/parlor/game/GameObject.dobj | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/parlor/game/GameManager.java b/src/java/com/threerings/parlor/game/GameManager.java index b508dfc29..a6ea3bb95 100644 --- a/src/java/com/threerings/parlor/game/GameManager.java +++ b/src/java/com/threerings/parlor/game/GameManager.java @@ -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; } diff --git a/src/java/com/threerings/parlor/game/GameObject.dobj b/src/java/com/threerings/parlor/game/GameObject.dobj index f4495c5c9..06cc49b22 100644 --- a/src/java/com/threerings/parlor/game/GameObject.dobj +++ b/src/java/com/threerings/parlor/game/GameObject.dobj @@ -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 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; @@ -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 state 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 players 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)); + } }