Removed special "party" crap related to starting a game after it's

been created. A party game starts itself without direct user intervention.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3600 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-06-15 23:46:31 +00:00
parent f9f1307884
commit 6ce0059b29
7 changed files with 5 additions and 138 deletions
@@ -35,12 +35,4 @@ public interface GameService extends InvocationService
* room and ready to play.
*/
public void playerReady (Client client);
/**
* Asks the game manager to start the party game. This should only be
* called for party games, and then only by the creating player after
* any other game-specific starting prerequisites (e.g., a required
* number of players) have been fulfilled.
*/
public void startPartyGame (Client client);
}
@@ -47,15 +47,4 @@ public class GameMarshaller extends InvocationMarshaller
});
}
/** The method id used to dispatch {@link #startPartyGame} requests. */
public static final int START_PARTY_GAME = 2;
// documentation inherited from interface
public void startPartyGame (Client arg1)
{
sendRequest(arg1, START_PARTY_GAME, new Object[] {
});
}
}
@@ -58,9 +58,6 @@ public class GameObject extends PlaceObject
/** The field name of the <code>roundId</code> field. */
public static final String ROUND_ID = "roundId";
/** The field name of the <code>creator</code> field. */
public static final String CREATOR = "creator";
/** The field name of the <code>playerStatus</code> field. */
public static final String PLAYER_STATUS = "playerStatus";
// AUTO-GENERATED: FIELDS END
@@ -106,9 +103,6 @@ public class GameObject extends PlaceObject
/** The unique round identifier for the current round. */
public int roundId;
/** The player index of the creating player if this is a party game. */
public int creator;
/** If null, indicates that all present players are active, or for
* more complex games can be non-null to indicate the current status
* of each player in the game. The status value is one of
@@ -377,22 +371,6 @@ public class GameObject extends PlaceObject
this.roundId = value;
}
/**
* Requests that the <code>creator</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 setCreator (int value)
{
int ovalue = this.creator;
requestAttributeChange(
CREATOR, new Integer(value), new Integer(ovalue));
this.creator = value;
}
/**
* Requests that the <code>playerStatus</code> field be set to the
* specified value. The local value will be updated immediately and an
@@ -405,7 +383,7 @@ public class GameObject extends PlaceObject
{
int[] ovalue = this.playerStatus;
requestAttributeChange(
PLAYER_STATUS, value, ovalue);
PLAYER_STATUS, value, ovalue);
this.playerStatus = (value == null) ? null : (int[])value.clone();
}
@@ -422,7 +400,7 @@ public class GameObject extends PlaceObject
{
int ovalue = this.playerStatus[index];
requestElementUpdate(
PLAYER_STATUS, index, new Integer(value), new Integer(ovalue));
PLAYER_STATUS, index, new Integer(value), new Integer(ovalue));
this.playerStatus[index] = value;
}
// AUTO-GENERATED: METHODS END
@@ -61,12 +61,6 @@ public class GameDispatcher extends InvocationDispatcher
);
return;
case GameMarshaller.START_PARTY_GAME:
((GameProvider)provider).startPartyGame(
source
);
return;
default:
super.dispatchRequest(source, methodId, args);
}
@@ -518,9 +518,6 @@ public class GameManager extends PlaceManager
{
super.bodyLeft(bodyOid);
// TODO: if this is a party game not yet in play and the creator
// left, choose a new creator if at least one player still remains
// deal with disappearing players
}
@@ -970,51 +967,6 @@ public class GameManager extends PlaceManager
isAI(pidx)); // player is AI
}
// documentation inherited from interface
public void startPartyGame (ClientObject caller)
{
// make sure this is a party game
if (!isPartyGame()) {
Log.warning("Attempt to player-start a non-party game " +
"[game=" + _gameobj.which() +
", caller=" + caller + "].");
return;
}
// make sure the caller is the creating player
BodyObject plobj = (BodyObject)caller;
int pidx = _gameobj.getPlayerIndex(plobj.username);
if (pidx != _gameobj.creator) {
Log.warning("Attempt to start party game by non-creating player " +
"[game=" + _gameobj.which() +
", creator=" + getPlayerName(_gameobj.creator) +
", caller=" + caller + "].");
return;
}
// make sure the game is ready to go
if (!canStartPartyGame()) {
Log.warning("Attempt to start party game that can't yet begin " +
"[game=" + _gameobj.which() +
", caller=" + caller + "].");
return;
}
// start things up
startGame();
}
/**
* Returns whether this party game is all set to begin. The default
* implementation returns true. Derived classes that implement a
* party game should override this method to enforce any prerequisites
* (such as a minimum number of players) as appropriate.
*/
protected boolean canStartPartyGame ()
{
return true;
}
/**
* Gives game managers an opportunity to perform periodic processing
* that is not driven by events generated by the player.
@@ -35,10 +35,4 @@ public interface GameProvider extends InvocationProvider
* service request.
*/
public void playerReady (ClientObject caller);
/**
* Called when the client has sent a {@link
* GameService#startPartyGame} service request.
*/
public void startPartyGame (ClientObject caller);
}
@@ -553,44 +553,12 @@ public abstract class PuzzleManager extends GameManager
super.bodyLeft(bodyOid);
int pidx = IntListUtil.indexOf(_playerOids, bodyOid);
if (pidx != -1) {
if (_puzobj.isInPlay() && _puzobj.isActivePlayer(pidx)) {
// end the player's game if they bail on an in-progress puzzle
endPlayerGame(pidx);
} else if (_puzobj.state == PuzzleObject.AWAITING_PLAYERS &&
isPartyGame()) {
// handle a player leaving a party game that hasn't yet begun
if (removePlayer(getPlayerName(pidx))) {
// if they were the creator, choose a new creator
if (getPlayerCount() > 0 && _puzobj.creator == pidx) {
int npidx = getNextCreator(pidx);
_puzobj.setCreator(npidx);
// inform occupants of the creator change
String message = MessageBundle.tcompose(
"m.creator_replaced", getPlayerName(npidx));
systemMessage(message);
}
}
}
if (pidx != -1 && _puzobj.isInPlay() && _puzobj.isActivePlayer(pidx)) {
// end the player's game if they bail on an in-progress puzzle
endPlayerGame(pidx);
}
}
/**
* Returns the player index of the next feasible creating player
* following the given player index, or <code>-1</code> if there is no
* such available player.
*/
protected int getNextCreator (int pidx)
{
int size = getPlayerSlots();
int npidx = pidx;
do {
npidx = (npidx + 1) % size;
} while (npidx != pidx && !_puzobj.isOccupiedPlayer(npidx));
return (npidx == pidx) ? -1 : npidx;
}
/**
* Called when a player leaves the game in order to determine whether
* the game should be ended based on its current state, which will