Store the current round id in the game object rather than tracking
separately in the game manager and controller which can then get unhappily out of sync. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1450 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameController.java,v 1.15 2002/06/03 21:08:57 shaper Exp $
|
||||
// $Id: GameController.java,v 1.16 2002/06/12 07:59:18 shaper Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -123,9 +123,6 @@ public abstract class GameController extends PlaceController
|
||||
|
||||
// end the game until we receive a new board
|
||||
setGameOver(true);
|
||||
|
||||
// increment the round identifier
|
||||
_roundId++;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +130,7 @@ public abstract class GameController extends PlaceController
|
||||
*/
|
||||
public int getRoundId ()
|
||||
{
|
||||
return _roundId;
|
||||
return _gobj.roundId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,9 +238,6 @@ public abstract class GameController extends PlaceController
|
||||
* controlling. */
|
||||
protected GameObject _gobj;
|
||||
|
||||
/** The unique round identifier for the current round. */
|
||||
protected int _roundId;
|
||||
|
||||
/** A local flag overriding the game over state for situations where
|
||||
* the client knows the game is over before the server has
|
||||
* transitioned the game object accordingly. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameManager.java,v 1.33 2002/06/06 22:13:56 ray Exp $
|
||||
// $Id: GameManager.java,v 1.34 2002/06/12 07:59:19 shaper Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class GameManager extends PlaceManager
|
||||
*/
|
||||
public int getRoundId ()
|
||||
{
|
||||
return _roundId;
|
||||
return _gameobj.roundId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +375,7 @@ public class GameManager extends PlaceManager
|
||||
gameWillReset();
|
||||
|
||||
// increment the round identifier
|
||||
_roundId++;
|
||||
_gameobj.setRoundId(_gameobj.roundId + 1);
|
||||
|
||||
// do the standard game start processing
|
||||
gameWillStart();
|
||||
@@ -496,9 +496,6 @@ public class GameManager extends PlaceManager
|
||||
/** The oids of our player and AI body objects. */
|
||||
protected int[] _playerOids;
|
||||
|
||||
/** The unique round identifier for the current round. */
|
||||
protected int _roundId;
|
||||
|
||||
/** If AIs are present, contains their skill levels, or -1 at human
|
||||
* player indexes. */
|
||||
protected byte[] _AIs;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameObject.dobj,v 1.8 2002/02/13 03:21:28 mdb Exp $
|
||||
// $Id: GameObject.dobj,v 1.9 2002/06/12 07:59:19 shaper Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -40,4 +40,7 @@ public class GameObject extends PlaceObject
|
||||
|
||||
/** The username of the players involved in this game. */
|
||||
public String[] players;
|
||||
|
||||
/** The unique round identifier for the current round. */
|
||||
public int roundId;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: GameObject.java,v 1.3 2002/02/20 23:35:42 mdb Exp $
|
||||
// $Id: GameObject.java,v 1.4 2002/06/12 07:59:19 shaper Exp $
|
||||
|
||||
package com.threerings.parlor.game;
|
||||
|
||||
@@ -27,6 +27,9 @@ public class GameObject extends PlaceObject
|
||||
/** The field name of the <code>players</code> field. */
|
||||
public static final String PLAYERS = "players";
|
||||
|
||||
/** The field name of the <code>roundId</code> field. */
|
||||
public static final String ROUND_ID = "roundId";
|
||||
|
||||
/** 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;
|
||||
@@ -50,6 +53,9 @@ public class GameObject extends PlaceObject
|
||||
/** The username of the players involved in this game. */
|
||||
public String[] players;
|
||||
|
||||
/** The unique round identifier for the current round. */
|
||||
public int roundId;
|
||||
|
||||
/**
|
||||
* Requests that the <code>state</code> field be set to the specified
|
||||
* value. The local value will be updated immediately and an event
|
||||
@@ -91,4 +97,32 @@ public class GameObject extends PlaceObject
|
||||
this.players = players;
|
||||
requestAttributeChange(PLAYERS, players);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>index</code>th element of
|
||||
* <code>players</code> field be set to the specified value. The local
|
||||
* value will be updated immediately and an event will be propagated
|
||||
* through the system to notify all listeners that the attribute did
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
public void setPlayersAt (String value, int index)
|
||||
{
|
||||
this.players[index] = value;
|
||||
requestElementUpdate(PLAYERS, value, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>roundId</code> field be set to the specified
|
||||
* value. The local value will be updated immediately and an event
|
||||
* will be propagated through the system to notify all listeners that
|
||||
* the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
public void setRoundId (int roundId)
|
||||
{
|
||||
this.roundId = roundId;
|
||||
requestAttributeChange(ROUND_ID, new Integer(roundId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user