Behold Vilya, Ring of Air and repository for our game and virtual worldly
extensions to the distributed environment provided by Narya. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@1 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// $Id: GameConfigurator.java 3590 2005-06-08 23:20:18Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.client;
|
||||
|
||||
import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* Provides the base from which interfaces can be built to configure games
|
||||
* prior to starting them. Derived classes would extend the base
|
||||
* configurator adding interface elements and wiring them up properly to
|
||||
* allow the user to configure an instance of their game.
|
||||
*
|
||||
* <p> Clients that use the game configurator will want to instantiate one
|
||||
* based on the class returned from the {@link GameConfig} and then
|
||||
* initialize it with a call to {@link #init}.
|
||||
*/
|
||||
public abstract class GameConfigurator
|
||||
{
|
||||
/**
|
||||
* Initializes this game configurator, creates its user interface
|
||||
* elements and prepares it for display.
|
||||
*/
|
||||
public void init (ParlorContext ctx)
|
||||
{
|
||||
// save this for later
|
||||
_ctx = ctx;
|
||||
|
||||
// create our interface elements
|
||||
createConfigInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* The default implementation creates nothing.
|
||||
*/
|
||||
protected void createConfigInterface ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides this configurator with its configuration. It should set up
|
||||
* all of its user interface elements to reflect the configuration.
|
||||
*/
|
||||
public void setGameConfig (GameConfig config)
|
||||
{
|
||||
_config = config;
|
||||
// set up the user interface
|
||||
gotGameConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will likely want to override this method and
|
||||
* configure their user interface elements accordingly.
|
||||
*/
|
||||
protected void gotGameConfig ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a configured game configuration.
|
||||
*/
|
||||
public GameConfig getGameConfig ()
|
||||
{
|
||||
// flush our changes to the config object
|
||||
flushGameConfig();
|
||||
return _config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes will want to override this method, flushing values
|
||||
* from the user interface to the game config object so that it is
|
||||
* properly configured prior to being returned to the {@link
|
||||
* #getGameConfig} caller.
|
||||
*/
|
||||
protected void flushGameConfig ()
|
||||
{
|
||||
}
|
||||
|
||||
/** Provides access to client services. */
|
||||
protected ParlorContext _ctx;
|
||||
|
||||
/** Our game configuration. */
|
||||
protected GameConfig _config;
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
//
|
||||
// $Id: GameController.java 3804 2006-01-13 01:52:36Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.client;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||
|
||||
import com.threerings.crowd.client.PlaceController;
|
||||
import com.threerings.crowd.client.PlaceControllerDelegate;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.util.CrowdContext;
|
||||
|
||||
import com.threerings.parlor.Log;
|
||||
import com.threerings.parlor.game.data.GameCodes;
|
||||
import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.game.data.GameObject;
|
||||
import com.threerings.parlor.game.data.PartyGameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* The game controller manages the flow and control of a game on the
|
||||
* client side. This class serves as the root of a hierarchy of controller
|
||||
* classes that aim to provide functionality shared between various
|
||||
* similar games. The base controller provides functionality for starting
|
||||
* and ending the game and for calculating ratings adjustements when a
|
||||
* game ends normally. It also handles the basic house keeping like
|
||||
* subscription to the game object and dispatch of commands and
|
||||
* distributed object events.
|
||||
*/
|
||||
public abstract class GameController extends PlaceController
|
||||
implements AttributeChangeListener
|
||||
{
|
||||
/**
|
||||
* Initializes this game controller with the game configuration that
|
||||
* was established during the match making process. Derived classes
|
||||
* may want to override this method to initialize themselves with
|
||||
* game-specific configuration parameters but they should be sure to
|
||||
* call <code>super.init</code> in such cases.
|
||||
*
|
||||
* @param ctx the client context.
|
||||
* @param config the configuration of the game we are intended to
|
||||
* control.
|
||||
*/
|
||||
public void init (CrowdContext ctx, PlaceConfig config)
|
||||
{
|
||||
// cast our references before we call super.init() so that when
|
||||
// super.init() calls createPlaceView(), we have our casted
|
||||
// references already in place
|
||||
_ctx = (ParlorContext)ctx;
|
||||
_config = (GameConfig)config;
|
||||
|
||||
super.init(ctx, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this controller as a listener to the game object (thus derived
|
||||
* classes need not do so) and lets the game manager know that we are
|
||||
* now ready to go.
|
||||
*/
|
||||
public void willEnterPlace (PlaceObject plobj)
|
||||
{
|
||||
super.willEnterPlace(plobj);
|
||||
|
||||
// obtain a casted reference
|
||||
_gobj = (GameObject)plobj;
|
||||
|
||||
// if this place object is not our current location we'll need to
|
||||
// add it as an auxiliary chat source
|
||||
BodyObject bobj = (BodyObject)_ctx.getClient().getClientObject();
|
||||
if (bobj.location != plobj.getOid()) {
|
||||
_ctx.getChatDirector().addAuxiliarySource(
|
||||
_gobj, GameCodes.GAME_CHAT_TYPE);
|
||||
}
|
||||
|
||||
// and add ourselves as a listener
|
||||
_gobj.addListener(this);
|
||||
|
||||
// we don't want to claim to be finished until any derived classes
|
||||
// that overrode this method have executed, so we'll queue up a
|
||||
// runnable here that will let the game manager know that we're
|
||||
// ready on the next pass through the distributed event loop
|
||||
Log.info("Entering game " + _gobj.which() + ".");
|
||||
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
|
||||
_ctx.getClient().getRunQueue().postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
// finally let the game manager know that we're ready
|
||||
// to roll
|
||||
playerReady();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes our listener registration from the game object and cleans
|
||||
* house.
|
||||
*/
|
||||
public void didLeavePlace (PlaceObject plobj)
|
||||
{
|
||||
super.didLeavePlace(plobj);
|
||||
|
||||
_ctx.getChatDirector().removeAuxiliarySource(_gobj);
|
||||
|
||||
// unlisten to the game object
|
||||
_gobj.removeListener(this);
|
||||
_gobj = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the game is over.
|
||||
*/
|
||||
public boolean isGameOver ()
|
||||
{
|
||||
boolean gameOver =
|
||||
((_gobj != null) ? (_gobj.state != GameObject.IN_PLAY) : true);
|
||||
return (_gameOver || gameOver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client game over override. This is used in situations
|
||||
* where we determine that the game is over before the server has
|
||||
* informed us of such.
|
||||
*/
|
||||
public void setGameOver (boolean gameOver)
|
||||
{
|
||||
_gameOver = gameOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #gameWillReset}, ends the current game (locally, it
|
||||
* does not tell the server to end the game), and waits to receive a
|
||||
* reset notification (which is simply an event setting the game state
|
||||
* to <code>IN_PLAY</code> even though it's already set to
|
||||
* <code>IN_PLAY</code>) from the server which will start up a new
|
||||
* game. Derived classes should override {@link #gameWillReset} to
|
||||
* perform any game-specific animations.
|
||||
*/
|
||||
public void resetGame ()
|
||||
{
|
||||
// let derived classes do their thing
|
||||
gameWillReset();
|
||||
|
||||
// end the game until we receive a new board
|
||||
setGameOver(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique round identifier for the current round.
|
||||
*/
|
||||
public int getRoundId ()
|
||||
{
|
||||
return (_gobj == null) ? -1 : _gobj.roundId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles basic game controller action events. Derived classes should
|
||||
* be sure to call <code>super.handleAction</code> for events they
|
||||
* don't specifically handle.
|
||||
*/
|
||||
public boolean handleAction (ActionEvent action)
|
||||
{
|
||||
return super.handleAction(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* A way for controllers to display a game-related system message.
|
||||
*/
|
||||
public void systemMessage (String bundle, String msg)
|
||||
{
|
||||
_ctx.getChatDirector().displayInfo(
|
||||
bundle, msg, GameCodes.GAME_CHAT_TYPE);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void attributeChanged (AttributeChangedEvent event)
|
||||
{
|
||||
// deal with game state changes
|
||||
if (event.getName().equals(GameObject.STATE)) {
|
||||
if (!stateDidChange(event.getIntValue())) {
|
||||
Log.warning("Game transitioned to unknown state " +
|
||||
"[gobj=" + _gobj +
|
||||
", state=" + event.getIntValue() + "].");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes can override this method if they add additional game
|
||||
* states and should handle transitions to those states, returning true to
|
||||
* indicate they were handled and calling super for the normal game states.
|
||||
*/
|
||||
protected boolean stateDidChange (int state)
|
||||
{
|
||||
switch (state) {
|
||||
case GameObject.IN_PLAY:
|
||||
gameDidStart();
|
||||
return true;
|
||||
case GameObject.GAME_OVER:
|
||||
gameDidEnd();
|
||||
return true;
|
||||
case GameObject.CANCELLED:
|
||||
gameWasCancelled();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after we've entered the game and everything has initialized
|
||||
* to notify the server that we, as a player, are ready to play.
|
||||
*/
|
||||
protected void playerReady ()
|
||||
{
|
||||
Log.info("Reporting ready " + _gobj.which() + ".");
|
||||
_gobj.gameService.playerReady(_ctx.getClient());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game transitions to the <code>IN_PLAY</code>
|
||||
* state. This happens when all of the players have arrived and the
|
||||
* server starts the game.
|
||||
*/
|
||||
protected void gameDidStart ()
|
||||
{
|
||||
if (_gobj == null) {
|
||||
Log.info("Received gameDidStart() after leaving game room.");
|
||||
return;
|
||||
}
|
||||
|
||||
// clear out our game over flag
|
||||
setGameOver(false);
|
||||
|
||||
// let our delegates do their business
|
||||
applyToDelegates(new DelegateOp() {
|
||||
public void apply (PlaceControllerDelegate delegate) {
|
||||
((GameControllerDelegate)delegate).gameDidStart();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game transitions to the <code>GAME_OVER</code>
|
||||
* state. This happens when the game reaches some end condition by
|
||||
* normal means (is not cancelled or aborted).
|
||||
*/
|
||||
protected void gameDidEnd ()
|
||||
{
|
||||
// let our delegates do their business
|
||||
applyToDelegates(new DelegateOp() {
|
||||
public void apply (PlaceControllerDelegate delegate) {
|
||||
((GameControllerDelegate)delegate).gameDidEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game was cancelled for some reason.
|
||||
*/
|
||||
protected void gameWasCancelled ()
|
||||
{
|
||||
// let our delegates do their business
|
||||
applyToDelegates(new DelegateOp() {
|
||||
public void apply (PlaceControllerDelegate delegate) {
|
||||
((GameControllerDelegate)delegate).gameWasCancelled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to give derived classes a chance to display animations, send
|
||||
* a final packet, or do any other business they care to do when the
|
||||
* game is about to reset.
|
||||
*/
|
||||
protected void gameWillReset ()
|
||||
{
|
||||
// let our delegates do their business
|
||||
applyToDelegates(new DelegateOp() {
|
||||
public void apply (PlaceControllerDelegate delegate) {
|
||||
((GameControllerDelegate)delegate).gameWillReset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determine if this game is a party game.
|
||||
*/
|
||||
protected boolean isPartyGame ()
|
||||
{
|
||||
return (_config instanceof PartyGameConfig) &&
|
||||
(((PartyGameConfig)_config).getPartyGameType() !=
|
||||
PartyGameConfig.NOT_PARTY_GAME);
|
||||
}
|
||||
|
||||
/** A reference to the active parlor context. */
|
||||
protected ParlorContext _ctx;
|
||||
|
||||
/** Our game configuration information. */
|
||||
protected GameConfig _config;
|
||||
|
||||
/** A reference to the game object for the game that we're
|
||||
* controlling. */
|
||||
protected GameObject _gobj;
|
||||
|
||||
/** 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. */
|
||||
protected boolean _gameOver;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// $Id: GameControllerDelegate.java 3381 2005-03-03 19:36:34Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.client;
|
||||
|
||||
import com.threerings.crowd.client.PlaceControllerDelegate;
|
||||
|
||||
/**
|
||||
* Extends the {@link PlaceControllerDelegate} mechanism with game
|
||||
* controller specific methods.
|
||||
*/
|
||||
public class GameControllerDelegate extends PlaceControllerDelegate
|
||||
{
|
||||
/**
|
||||
* Provides the delegate with a reference to the game controller for
|
||||
* which it is delegating.
|
||||
*/
|
||||
public GameControllerDelegate (GameController ctrl)
|
||||
{
|
||||
super(ctrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game transitions to the <code>IN_PLAY</code>
|
||||
* state. This happens when all of the players have arrived and the
|
||||
* server starts the game.
|
||||
*/
|
||||
public void gameDidStart ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game transitions to the <code>GAME_OVER</code>
|
||||
* state. This happens when the game reaches some end condition by
|
||||
* normal means (is not cancelled or aborted).
|
||||
*/
|
||||
public void gameDidEnd ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game was cancelled for some reason.
|
||||
*/
|
||||
public void gameWasCancelled ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to give derived classes a chance to display animations, send
|
||||
* a final packet, or do any other business they care to do when the
|
||||
* game is about to reset.
|
||||
*/
|
||||
public void gameWillReset ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// $Id: GameService.java 3600 2005-06-15 23:46:31Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.client;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
/**
|
||||
* Provides services used by game clients to request that actions be taken
|
||||
* by the game manager.
|
||||
*/
|
||||
public interface GameService extends InvocationService
|
||||
{
|
||||
/**
|
||||
* Lets the game manager know that the calling player is in the game
|
||||
* room and ready to play.
|
||||
*/
|
||||
public void playerReady (Client client);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// $Id: GameConfigurator.java 3590 2005-06-08 23:20:18Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.client;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.samskivert.swing.VGroupLayout;
|
||||
|
||||
import com.threerings.parlor.game.data.GameConfig;
|
||||
import com.threerings.parlor.util.ParlorContext;
|
||||
|
||||
/**
|
||||
* Provides the base from which interfaces can be built to configure games
|
||||
* prior to starting them. Derived classes would extend the base
|
||||
* configurator adding interface elements and wiring them up properly to
|
||||
* allow the user to configure an instance of their game.
|
||||
*
|
||||
* <p> Clients that use the game configurator will want to instantiate one
|
||||
* based on the class returned from the {@link GameConfig} and then
|
||||
* initialize it with a call to {@link #init}.
|
||||
*/
|
||||
public abstract class SwingGameConfigurator extends GameConfigurator
|
||||
{
|
||||
/**
|
||||
* Get the Swing JPanel that contains the UI elements for this configurator.
|
||||
*/
|
||||
public JPanel getPanel ()
|
||||
{
|
||||
return _panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a control to the interface. This should be the standard way
|
||||
* that configurator controls are added, but note also that external
|
||||
* entities may add their own controls that are related to the game,
|
||||
* but do not directly alter the game config, so that all the controls
|
||||
* are added in a uniform manner and are well aligned.
|
||||
*/
|
||||
public void addControl (JComponent label, JComponent control)
|
||||
{
|
||||
// Set up the constraints. There's really no point in saving
|
||||
// these somewhere, as they're cloned anyway with every component
|
||||
// insertion.
|
||||
GridBagConstraints lc = new GridBagConstraints();
|
||||
lc.gridx = 0;
|
||||
lc.anchor = GridBagConstraints.NORTHWEST;
|
||||
lc.insets = _labelInsets;
|
||||
|
||||
GridBagConstraints cc = new GridBagConstraints();
|
||||
cc.gridx = 1;
|
||||
cc.anchor = GridBagConstraints.NORTHWEST;
|
||||
cc.insets = _controlInsets;
|
||||
cc.gridwidth = GridBagConstraints.REMAINDER;
|
||||
|
||||
// add the components
|
||||
_panel.add(label, lc);
|
||||
_panel.add(control, cc);
|
||||
}
|
||||
|
||||
/** The panel on which the config options are placed. */
|
||||
protected JPanel _panel = new JPanel(new GridBagLayout());
|
||||
|
||||
/** Insets for configuration labels. */
|
||||
protected Insets _labelInsets = new Insets(1, 0, 1, 4);
|
||||
|
||||
/** Insets for configuration controls. */
|
||||
protected Insets _controlInsets = new Insets(1, 4, 1, 0);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// $Id: GameAI.java 3399 2005-03-12 07:37:34Z mdb $
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* Represents attributes of an AI player.
|
||||
*/
|
||||
public class GameAI extends SimpleStreamableObject
|
||||
{
|
||||
/** The "personality" of the AI, which can be interpreted by
|
||||
* each puzzle. */
|
||||
public int personality;
|
||||
|
||||
/** The skill level of the AI. */
|
||||
public int skill;
|
||||
|
||||
/** A blank constructor for serialization. */
|
||||
public GameAI ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an AI with the specified (game-interpreted) skill and
|
||||
* personality.
|
||||
*/
|
||||
public GameAI (int personality, int skill)
|
||||
{
|
||||
this.personality = personality;
|
||||
this.skill = skill;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// $Id: PuzzleCodes.java 3184 2004-10-28 19:20:27Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
/**
|
||||
* Constants relating to the game services.
|
||||
*/
|
||||
public interface GameCodes extends InvocationCodes
|
||||
{
|
||||
/** The message bundle identifier for general game messages. */
|
||||
public static final String GAME_MESSAGE_BUNDLE = "game.general";
|
||||
|
||||
/** The name of the message event to a placeObject that a player
|
||||
* was knocked out of a puzzle. */
|
||||
public static final String PLAYER_KNOCKED_OUT = "playerKnocked";
|
||||
|
||||
/** The name of the message event to a placeObject that reports
|
||||
* the winners and losers of a game. */
|
||||
public static final String WINNERS_AND_LOSERS = "winnersAndLosers";
|
||||
|
||||
/** A chat type for chatting on the game object. */
|
||||
public static final String GAME_CHAT_TYPE = "gameChat";
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// $Id: GameConfig.java 4026 2006-04-18 01:32:41Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.parlor.client.TableConfigurator;
|
||||
import com.threerings.parlor.game.client.GameConfigurator;
|
||||
|
||||
/**
|
||||
* The game config class encapsulates the configuration information for a
|
||||
* particular type of game. The hierarchy of game config objects mimics the
|
||||
* hierarchy of game managers and controllers. Both the game manager and game
|
||||
* controller are provided with the game config object when the game is
|
||||
* created.
|
||||
*
|
||||
* <p> The game config object is also the mechanism used to instantiate the
|
||||
* appropriate game manager and controller. Every game must have an associated
|
||||
* game config derived class that overrides {@link #createController} and
|
||||
* {@link #getManagerClassName}, returning the appropriate game controller and
|
||||
* manager class for that game. Thus the entire chain of events that causes a
|
||||
* particular game to be created is the construction of the appropriate game
|
||||
* config instance which is provided to the server as part of an invitation or
|
||||
* via some other matchmaking mechanism.
|
||||
*/
|
||||
public abstract class GameConfig extends PlaceConfig implements Cloneable
|
||||
{
|
||||
/** The usernames of the players involved in this game, or an empty
|
||||
* array if such information is not needed by this particular game. */
|
||||
public Name[] players = new Name[0];
|
||||
|
||||
/** Indicates whether or not this game is rated. */
|
||||
public boolean rated = true;
|
||||
|
||||
/** Configurations for AIs to be used in this game. Slots with real
|
||||
* players should be null and slots with AIs should contain
|
||||
* configuration for those AIs. A null array indicates no use of AIs
|
||||
* at all. */
|
||||
public GameAI[] ais = new GameAI[0];
|
||||
|
||||
/**
|
||||
* Returns the message bundle identifier for the bundle that should be
|
||||
* used to translate the translatable strings used to describe the
|
||||
* game config parameters.
|
||||
*/
|
||||
public abstract String getBundleName ();
|
||||
|
||||
/**
|
||||
* Creates a configurator that can be used to create a user interface
|
||||
* for configuring this instance prior to starting the game. If no
|
||||
* configuration is necessary, this method should return null.
|
||||
*/
|
||||
public abstract GameConfigurator createConfigurator ();
|
||||
|
||||
/**
|
||||
* Creates a table configurator for initializing 'table' properties
|
||||
* of the game. The default implementation returns null.
|
||||
*/
|
||||
public TableConfigurator createTableConfigurator ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a translatable label describing this game.
|
||||
*/
|
||||
public String getGameName ()
|
||||
{
|
||||
// the whole getRatingTypeId(), getGameName(), getBundleName()
|
||||
// business should be cleaned up. we should have getGameIdent()
|
||||
// and everything should have a default implementation using that
|
||||
return "m." + getBundleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the game rating type, if the system uses such things.
|
||||
*/
|
||||
public byte getRatingTypeId ()
|
||||
{
|
||||
return (byte)-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List of strings that describe the configuration of this
|
||||
* game. Default implementation returns an empty list.
|
||||
*/
|
||||
public List getDescription ()
|
||||
{
|
||||
return new ArrayList(); // nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this game config object is equal to the supplied
|
||||
* object (meaning it is also a game config object and its
|
||||
* configuration settings are the same as ours).
|
||||
*/
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
// make sure they're of the same class
|
||||
if (other.getClass() == this.getClass()) {
|
||||
GameConfig that = (GameConfig) other;
|
||||
return this.rated == that.rated;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hashcode for this game config object that supports our
|
||||
* {@link #equals} implementation. Objects that are equal should have
|
||||
* the same hashcode.
|
||||
*/
|
||||
public int hashCode ()
|
||||
{
|
||||
// look ma, it's so sophisticated!
|
||||
return getClass().hashCode() + (rated ? 1 : 0);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Object clone ()
|
||||
{
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException cnse) {
|
||||
throw new RuntimeException("clone() failed: " + cnse);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// $Id: GameMarshaller.java 4145 2006-05-24 01:24:24Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import com.threerings.parlor.game.client.GameService;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link GameService} interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class GameMarshaller extends InvocationMarshaller
|
||||
implements GameService
|
||||
{
|
||||
/** The method id used to dispatch {@link #playerReady} requests. */
|
||||
public static final int PLAYER_READY = 1;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void playerReady (Client arg1)
|
||||
{
|
||||
sendRequest(arg1, PLAYER_READY, new Object[] {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
//
|
||||
// $Id: GameObject.java 4191 2006-06-13 22:42:20Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
import com.samskivert.util.ListUtil;
|
||||
import com.samskivert.util.StringUtil;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
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
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>gameService</code> field. */
|
||||
public static final String GAME_SERVICE = "gameService";
|
||||
|
||||
/** The field name of the <code>state</code> field. */
|
||||
public static final String STATE = "state";
|
||||
|
||||
/** The field name of the <code>isRated</code> field. */
|
||||
public static final String IS_RATED = "isRated";
|
||||
|
||||
/** The field name of the <code>isPrivate</code> field. */
|
||||
public static final String IS_PRIVATE = "isPrivate";
|
||||
|
||||
/** The field name of the <code>players</code> field. */
|
||||
public static final String PLAYERS = "players";
|
||||
|
||||
/** The field name of the <code>winners</code> field. */
|
||||
public static final String WINNERS = "winners";
|
||||
|
||||
/** The field name of the <code>roundId</code> field. */
|
||||
public static final String ROUND_ID = "roundId";
|
||||
|
||||
/** The field name of the <code>playerStatus</code> field. */
|
||||
public static final String PLAYER_STATUS = "playerStatus";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/** 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 PRE_GAME = 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 player status constant for a player whose game is in play. */
|
||||
public static final int PLAYER_IN_PLAY = 0;
|
||||
|
||||
/** The player status constant for a player whose has been knocked out
|
||||
* of the game. NOTE: This can include a player choosing to leave a
|
||||
* game prematurely. */
|
||||
public static final int PLAYER_LEFT_GAME = 1;
|
||||
|
||||
/** Provides general game invocation services. */
|
||||
public GameMarshaller gameService;
|
||||
|
||||
/** The game state, one of {@link #PRE_GAME}, {@link #IN_PLAY},
|
||||
* {@link #GAME_OVER}, or {@link #CANCELLED}. */
|
||||
public int state = PRE_GAME;
|
||||
|
||||
/** Indicates whether or not this game is rated. */
|
||||
public boolean isRated;
|
||||
|
||||
/** Indicates whether the game is "private". */
|
||||
public boolean isPrivate;
|
||||
|
||||
/** The usernames of the players involved in this game. */
|
||||
public Name[] players;
|
||||
|
||||
/** Whether each player in the game is a winner, or <code>null</code>
|
||||
* if the game is not yet over. */
|
||||
public boolean[] winners;
|
||||
|
||||
/** The unique round identifier for the current round. */
|
||||
public int roundId;
|
||||
|
||||
/** 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
|
||||
* {@link #PLAYER_LEFT_GAME} or {@link #PLAYER_IN_PLAY}. */
|
||||
public int[] playerStatus;
|
||||
|
||||
/**
|
||||
* Returns the number of players in the game.
|
||||
*/
|
||||
public int getPlayerCount ()
|
||||
{
|
||||
int count = 0;
|
||||
int size = players.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
if (players[ii] != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of active players in the game.
|
||||
*/
|
||||
public int getActivePlayerCount ()
|
||||
{
|
||||
int count = 0;
|
||||
int size = players.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
if (isActivePlayer(ii)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given player is still an active player in
|
||||
* the game. (Ie. whether or not they are still participating.)
|
||||
*/
|
||||
public boolean isActivePlayer (int pidx)
|
||||
{
|
||||
return isOccupiedPlayer(pidx) &&
|
||||
(playerStatus == null || isActivePlayerStatus(playerStatus[pidx]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the player index of the given user in the game, or
|
||||
* <code>-1</code> if the player is not involved in the game.
|
||||
*/
|
||||
public int getPlayerIndex (Name username)
|
||||
{
|
||||
int size = (players == null) ? 0 : players.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
if (players[ii] != null && players[ii].equals(username)) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the game is in play. A game that is not in play
|
||||
* could either be awaiting players, ended, or cancelled.
|
||||
*/
|
||||
public boolean isInPlay ()
|
||||
{
|
||||
return (state == IN_PLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given player index in the game is occupied.
|
||||
*/
|
||||
public boolean isOccupiedPlayer (int pidx)
|
||||
{
|
||||
return (pidx >= 0 && pidx < players.length) && (players[pidx] != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given player index is a winner, or false if the
|
||||
* winners are not yet assigned.
|
||||
*/
|
||||
public boolean isWinner (int pidx)
|
||||
{
|
||||
return (winners == null) ? false : winners[pidx];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of winners for this game, or <code>0</code> if
|
||||
* the winners array is not populated, e.g., the game is not yet over.
|
||||
*/
|
||||
public int getWinnerCount ()
|
||||
{
|
||||
int count = 0;
|
||||
int size = (winners == null) ? 0 : winners.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
if (winners[ii]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the game is ended in a draw.
|
||||
*/
|
||||
public boolean isDraw ()
|
||||
{
|
||||
return getWinnerCount() == getPlayerCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the winner index of the first winning player for this game,
|
||||
* or <code>-1</code> if there are no winners or the winners array is
|
||||
* not yet assigned. This is only likely to be useful for games that
|
||||
* are known to have a single winner.
|
||||
*/
|
||||
public int getWinnerIndex ()
|
||||
{
|
||||
int size = (winners == null) ? 0 : winners.length;
|
||||
for (int ii = 0; ii < size; ii++) {
|
||||
if (winners[ii]) {
|
||||
return ii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of party game being played or NOT_PARTY_GAME.
|
||||
* {@link PartyGameConfig}.
|
||||
*/
|
||||
public byte getPartyGameType ()
|
||||
{
|
||||
return PartyGameConfig.NOT_PARTY_GAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by {@link #isActivePlayer} to determine if the supplied status is
|
||||
* associated with an active player (one that has not resigned from the
|
||||
* game and/or left the game room).
|
||||
*/
|
||||
protected boolean isActivePlayerStatus (int playerStatus)
|
||||
{
|
||||
return playerStatus == PLAYER_IN_PLAY;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected void which (StringBuilder buf)
|
||||
{
|
||||
super.which(buf);
|
||||
StringUtil.toString(buf, players);
|
||||
buf.append(":").append(state);
|
||||
}
|
||||
|
||||
// AUTO-GENERATED: METHODS START
|
||||
/**
|
||||
* Requests that the <code>gameService</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 setGameService (GameMarshaller value)
|
||||
{
|
||||
GameMarshaller ovalue = this.gameService;
|
||||
requestAttributeChange(
|
||||
GAME_SERVICE, value, ovalue);
|
||||
this.gameService = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>state</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 setState (int value)
|
||||
{
|
||||
int ovalue = this.state;
|
||||
requestAttributeChange(
|
||||
STATE, Integer.valueOf(value), Integer.valueOf(ovalue));
|
||||
this.state = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>isRated</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 setIsRated (boolean value)
|
||||
{
|
||||
boolean ovalue = this.isRated;
|
||||
requestAttributeChange(
|
||||
IS_RATED, Boolean.valueOf(value), Boolean.valueOf(ovalue));
|
||||
this.isRated = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>isPrivate</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 setIsPrivate (boolean value)
|
||||
{
|
||||
boolean ovalue = this.isPrivate;
|
||||
requestAttributeChange(
|
||||
IS_PRIVATE, Boolean.valueOf(value), Boolean.valueOf(ovalue));
|
||||
this.isPrivate = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <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 setPlayers (Name[] value)
|
||||
{
|
||||
Name[] ovalue = this.players;
|
||||
requestAttributeChange(
|
||||
PLAYERS, value, ovalue);
|
||||
this.players = (value == null) ? null : (Name[])value.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 (Name value, int index)
|
||||
{
|
||||
Name ovalue = this.players[index];
|
||||
requestElementUpdate(
|
||||
PLAYERS, index, value, ovalue);
|
||||
this.players[index] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>winners</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 setWinners (boolean[] value)
|
||||
{
|
||||
boolean[] ovalue = this.winners;
|
||||
requestAttributeChange(
|
||||
WINNERS, value, ovalue);
|
||||
this.winners = (value == null) ? null : (boolean[])value.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>index</code>th element of
|
||||
* <code>winners</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 setWinnersAt (boolean value, int index)
|
||||
{
|
||||
boolean ovalue = this.winners[index];
|
||||
requestElementUpdate(
|
||||
WINNERS, index, Boolean.valueOf(value), Boolean.valueOf(ovalue));
|
||||
this.winners[index] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 value)
|
||||
{
|
||||
int ovalue = this.roundId;
|
||||
requestAttributeChange(
|
||||
ROUND_ID, Integer.valueOf(value), Integer.valueOf(ovalue));
|
||||
this.roundId = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>playerStatus</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 setPlayerStatus (int[] value)
|
||||
{
|
||||
int[] ovalue = this.playerStatus;
|
||||
requestAttributeChange(
|
||||
PLAYER_STATUS, value, ovalue);
|
||||
this.playerStatus = (value == null) ? null : (int[])value.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>index</code>th element of
|
||||
* <code>playerStatus</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 setPlayerStatusAt (int value, int index)
|
||||
{
|
||||
int ovalue = this.playerStatus[index];
|
||||
requestElementUpdate(
|
||||
PLAYER_STATUS, index, Integer.valueOf(value), Integer.valueOf(ovalue));
|
||||
this.playerStatus[index] = value;
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// $Id: PartyGameConfig.java 3804 2006-01-13 01:52:36Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.data;
|
||||
|
||||
/**
|
||||
* Provides additional information for party games.
|
||||
* A party game is a game in which the players are not set prior to starting,
|
||||
* but players can come and go at will during the normal progression of
|
||||
* the game.
|
||||
*/
|
||||
public interface PartyGameConfig
|
||||
{
|
||||
/** Party game constant indicating that this game, while it does
|
||||
* implement PartyGameConfig, is not currently being played in party
|
||||
* mode. */
|
||||
public static final byte NOT_PARTY_GAME = 0;
|
||||
|
||||
/** Party game constant indicating that we're in a party game in which
|
||||
* players must sit at an available seat to play, otherwise they're
|
||||
* an observer. */
|
||||
public static final byte SEATED_PARTY_GAME = 1;
|
||||
|
||||
/** Party game constant indicating that everyone in the game place is
|
||||
* a "player", meaning that they do not need to claim a seat to play. */
|
||||
public static final byte FREE_FOR_ALL_PARTY_GAME = 2;
|
||||
|
||||
/**
|
||||
* Get the type of party game being played.
|
||||
*/
|
||||
public byte getPartyGameType ();
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// $Id: AIGameTicker.java 3381 2005-03-03 19:36:34Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.samskivert.util.Interval;
|
||||
|
||||
import com.threerings.crowd.server.CrowdServer;
|
||||
|
||||
/**
|
||||
* Handles ticking all the GameManagers that are hosting games with AIs.
|
||||
*/
|
||||
public class AIGameTicker extends Interval
|
||||
{
|
||||
/** The frequency with which we dispatch AI game ticks. */
|
||||
public static final long TICK_FREQUENCY = 3333L; // every 3 1/3 seconds
|
||||
|
||||
/**
|
||||
* Register the specified GameManager to receive AI ticks.
|
||||
*/
|
||||
public static synchronized void registerAIGame (GameManager mgr)
|
||||
{
|
||||
if (_ticker == null) {
|
||||
_ticker = new AIGameTicker();
|
||||
}
|
||||
_ticker.addAIGame(mgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the specified GameManager off the AI tick list.
|
||||
*/
|
||||
public static synchronized void unregisterAIGame (GameManager mgr)
|
||||
{
|
||||
if (_ticker != null) {
|
||||
_ticker.removeAIGame(mgr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an AIGameTicker and start it ticking.
|
||||
*/
|
||||
private AIGameTicker ()
|
||||
{
|
||||
super(CrowdServer.omgr);
|
||||
_games = new HashSet();
|
||||
|
||||
schedule(TICK_FREQUENCY, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified manager to the list of those receiving AI ticks.
|
||||
*/
|
||||
protected void addAIGame (GameManager mgr)
|
||||
{
|
||||
_games.add(mgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified manager from receiving AI ticks.
|
||||
*/
|
||||
protected void removeAIGame (GameManager mgr)
|
||||
{
|
||||
_games.remove(mgr);
|
||||
|
||||
// if there aren't any AIs, let's stop running
|
||||
if (_games.isEmpty()) {
|
||||
cancel();
|
||||
_ticker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tick all the game AIs while on the dobj thread.
|
||||
*/
|
||||
public void expired ()
|
||||
{
|
||||
Iterator iter = _games.iterator();
|
||||
while (iter.hasNext()) {
|
||||
((GameManager) iter.next()).tickAIs();
|
||||
}
|
||||
}
|
||||
|
||||
/** Our set of ai games. */
|
||||
protected HashSet _games;
|
||||
|
||||
/** Our single ticker for all AI games. */
|
||||
protected static AIGameTicker _ticker;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// $Id: GameDispatcher.java 4145 2006-05-24 01:24:24Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import com.threerings.parlor.game.client.GameService;
|
||||
import com.threerings.parlor.game.data.GameMarshaller;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link GameProvider}.
|
||||
*/
|
||||
public class GameDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public GameDispatcher (GameProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new GameMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case GameMarshaller.PLAYER_READY:
|
||||
((GameProvider)provider).playerReady(
|
||||
source
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// $Id: GameManagerDelegate.java 3667 2005-08-03 07:46:54Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.crowd.server.PlaceManagerDelegate;
|
||||
|
||||
import com.threerings.parlor.game.data.GameAI;
|
||||
|
||||
/**
|
||||
* Extends the {@link PlaceManagerDelegate} mechanism with game manager
|
||||
* specific methods.
|
||||
*/
|
||||
public class GameManagerDelegate extends PlaceManagerDelegate
|
||||
{
|
||||
/**
|
||||
* Provides the delegate with a reference to the game manager for
|
||||
* which it is delegating.
|
||||
*/
|
||||
public GameManagerDelegate (GameManager gmgr)
|
||||
{
|
||||
super(gmgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the game manager when the game is about to start.
|
||||
*/
|
||||
public void gameWillStart ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the game manager after the game was started.
|
||||
*/
|
||||
public void gameDidStart ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player in the game has been replaced by a call to
|
||||
* {@link GameManager#replacePlayer}.
|
||||
*/
|
||||
public void playerWasReplaced (int pidx, Name oldPlayer, Name newPlayer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the manager when we should do some AI. Only called while
|
||||
* the game is IN_PLAY.
|
||||
*
|
||||
* @param pidx the player index to fake some gameplay for.
|
||||
* @param ai a record indicating the AI's configuration.
|
||||
*/
|
||||
public void tickAI (int pidx, GameAI ai)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the game manager when the game is about to end.
|
||||
*/
|
||||
public void gameWillEnd ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the game manager after the game ended.
|
||||
*/
|
||||
public void gameDidEnd ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game is about to reset, but before any other
|
||||
* clearing out of game data has taken place. Derived classes should
|
||||
* override this if they need to perform some pre-reset activities.
|
||||
*/
|
||||
public void gameWillReset ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the specified player has been set as an AI with the
|
||||
* supplied AI configuration.
|
||||
*/
|
||||
public void setAI (int pidx, GameAI ai)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// $Id: GameProvider.java 4145 2006-05-24 01:24:24Z ray $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import com.threerings.parlor.game.client.GameService;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
|
||||
/**
|
||||
* Defines the server-side of the {@link GameService}.
|
||||
*/
|
||||
public interface GameProvider extends InvocationProvider
|
||||
{
|
||||
/**
|
||||
* Handles a {@link GameService#playerReady} request.
|
||||
*/
|
||||
public void playerReady (ClientObject caller);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// $Id: GameWatcher.java 3381 2005-03-03 19:36:34Z mdb $
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
import com.threerings.presents.dobj.AttributeChangeListener;
|
||||
import com.threerings.presents.dobj.AttributeChangedEvent;
|
||||
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.parlor.game.data.GameObject;
|
||||
|
||||
/**
|
||||
* An abstract convenience class used server-side to keep an eye on a game
|
||||
* and perform a one-time game-over activity when the game ends. Classes
|
||||
* that care to make use of the game watcher should create an instance,
|
||||
* implement {@link #gameDidEnd}, and pass the instance to the place
|
||||
* registry in the call to {@link PlaceRegistry#createPlace} when the
|
||||
* puzzle is created.
|
||||
*/
|
||||
public abstract class GameWatcher
|
||||
implements PlaceRegistry.CreationObserver, AttributeChangeListener
|
||||
{
|
||||
// documentation inherited
|
||||
public void placeCreated (PlaceObject place, PlaceManager pmgr)
|
||||
{
|
||||
_gameobj = (GameObject)place;
|
||||
_gameobj.addListener(this);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void attributeChanged (AttributeChangedEvent event)
|
||||
{
|
||||
if (event.getName().equals(GameObject.STATE)) {
|
||||
// if we transitioned to a non-in-play state, the game has
|
||||
// completed
|
||||
if (!_gameobj.isInPlay()) {
|
||||
try {
|
||||
gameDidEnd(_gameobj);
|
||||
} finally {
|
||||
_gameobj.removeListener(this);
|
||||
_gameobj = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the game ends to give derived classes a chance to
|
||||
* engage in their game-over antics.
|
||||
*/
|
||||
protected abstract void gameDidEnd (GameObject gameobj);
|
||||
|
||||
/** The game object we're observing. */
|
||||
protected GameObject _gameobj;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://www.threerings.net/code/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.parlor.game.server;
|
||||
|
||||
/**
|
||||
* An interface to be implemented by a game if it wants to hear about
|
||||
* the team indices that were configured during matchmaking.
|
||||
*/
|
||||
public interface TeamGameManager
|
||||
{
|
||||
/**
|
||||
* Set the team member indices. For example, a game with
|
||||
* three players in two teams- players 0 and 2 versus player 1- would
|
||||
* have { {0, 2}, {1} } set.
|
||||
*/
|
||||
public void setTeamMemberIndices (int[][] teams);
|
||||
}
|
||||
Reference in New Issue
Block a user