The PuzzleService was superfluous. The ParlorService can handle starting
single player games and indeed should because it's useful outside the context of puzzles and their ilk. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3359 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ParlorDirector.java,v 1.21 2004/08/27 02:20:12 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -28,6 +28,7 @@ import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.client.BasicDirector;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
import com.threerings.parlor.Log;
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
@@ -119,6 +120,20 @@ public class ParlorDirector extends BasicDirector
|
||||
return invite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified single player game be started.
|
||||
*
|
||||
* @param config the configuration of the single player game to be
|
||||
* started.
|
||||
* @param listener a listener to be informed of failure if the game
|
||||
* cannot be started.
|
||||
*/
|
||||
public void startSolitaire (
|
||||
GameConfig config, InvocationService.ConfirmListener listener)
|
||||
{
|
||||
_pservice.startSolitaire(_ctx.getClient(), config, listener);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void clientDidLogoff (Client client)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ParlorService.java,v 1.16 2004/08/27 02:20:12 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -151,4 +151,11 @@ public interface ParlorService extends InvocationService
|
||||
*/
|
||||
public void leaveTable (Client client, int lobbyOid, int tableId,
|
||||
InvocationListener listener);
|
||||
|
||||
/**
|
||||
* Requests to start a single player game with the specified game
|
||||
* configuration.
|
||||
*/
|
||||
public void startSolitaire (Client client, GameConfig config,
|
||||
ConfirmListener listener);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ParlorCodes.java,v 1.5 2004/08/27 02:20:13 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
|
||||
@@ -179,4 +179,17 @@ public class ParlorMarshaller extends InvocationMarshaller
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #startSolitaire} requests. */
|
||||
public static final int START_SOLITAIRE = 7;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void startSolitaire (Client arg1, GameConfig arg2, InvocationService.ConfirmListener arg3)
|
||||
{
|
||||
InvocationMarshaller.ConfirmMarshaller listener3 = new InvocationMarshaller.ConfirmMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, START_SOLITAIRE, new Object[] {
|
||||
arg2, listener3
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,13 @@ public class ParlorDispatcher extends InvocationDispatcher
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.START_SOLITAIRE:
|
||||
((ParlorProvider)provider).startSolitaire(
|
||||
source,
|
||||
(GameConfig)args[0], (InvocationService.ConfirmListener)args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.threerings.parlor.server;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
import com.threerings.presents.client.InvocationService.InvocationListener;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
@@ -37,6 +38,7 @@ import com.threerings.parlor.client.ParlorService.InviteListener;
|
||||
import com.threerings.parlor.client.ParlorService.TableListener;
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.parlor.game.GameManager;
|
||||
|
||||
/**
|
||||
* The parlor provider handles the server side of the various Parlor
|
||||
@@ -160,6 +162,40 @@ public class ParlorProvider
|
||||
// themselves removed from the table they just left
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a {@link ParlorService#startSolitaire} request.
|
||||
*/
|
||||
public void startSolitaire (ClientObject caller, GameConfig config,
|
||||
InvocationService.ConfirmListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
BodyObject user = (BodyObject)caller;
|
||||
|
||||
Log.debug("Processing start puzzle [caller=" + user.who() +
|
||||
", config=" + config + "].");
|
||||
|
||||
try {
|
||||
// just this fellow will be playing
|
||||
config.players = new Name[] { user.username };
|
||||
|
||||
// create the game manager and begin its initialization
|
||||
// process
|
||||
GameManager gmgr = (GameManager)
|
||||
CrowdServer.plreg.createPlace(config, null);
|
||||
|
||||
// the game manager will take care of notifying the player
|
||||
// that the game has been created once it has been started up;
|
||||
// but we let the caller know that we processed their request
|
||||
listener.requestProcessed();
|
||||
|
||||
} catch (InstantiationException ie) {
|
||||
Log.warning("Error instantiating game manager " +
|
||||
"[for=" + caller.who() + ", config=" + config + "].");
|
||||
Log.logStackTrace(ie);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the place manager associated with the supplied lobby oid,
|
||||
* casts it to a table lobby manager and obtains the associated table
|
||||
|
||||
Reference in New Issue
Block a user