Slight change to playerReady() handling. For party games all occupants will
call playerReady() rather than none of them. Also tidied up the way EZGameController delays playerReady() until the game backend is connected. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@520 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -34,6 +34,7 @@ import com.threerings.crowd.data.PlaceObject;
|
|||||||
import com.threerings.crowd.util.CrowdContext;
|
import com.threerings.crowd.util.CrowdContext;
|
||||||
|
|
||||||
import com.threerings.parlor.game.client.GameController;
|
import com.threerings.parlor.game.client.GameController;
|
||||||
|
import com.threerings.parlor.game.data.GameConfig;
|
||||||
import com.threerings.parlor.game.data.GameObject;
|
import com.threerings.parlor.game.data.GameObject;
|
||||||
|
|
||||||
import com.threerings.parlor.turn.client.TurnGameController;
|
import com.threerings.parlor.turn.client.TurnGameController;
|
||||||
@@ -58,6 +59,13 @@ public class EZGameController extends GameController
|
|||||||
*/
|
*/
|
||||||
public function userCodeIsConnected (autoReady :Boolean) :void
|
public function userCodeIsConnected (autoReady :Boolean) :void
|
||||||
{
|
{
|
||||||
|
// if we're not a player, we don't need to report anything to the server
|
||||||
|
var bobj :BodyObject = (_ctx.getClient().getClientObject() as BodyObject);
|
||||||
|
if (_gconfig.getMatchType() != GameConfig.PARTY &&
|
||||||
|
_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (autoReady) {
|
if (autoReady) {
|
||||||
// let the game manager know that we're here and we want to start the game now
|
// let the game manager know that we're here and we want to start the game now
|
||||||
playerIsReady();
|
playerIsReady();
|
||||||
@@ -99,6 +107,14 @@ public class EZGameController extends GameController
|
|||||||
_panel.backend.turnDidChange();
|
_panel.backend.turnDidChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from GameController
|
||||||
|
override protected function shouldAutoPlayerReady (bobj :BodyObject) :Boolean
|
||||||
|
{
|
||||||
|
// we don't want to auto-player ready in willEnterPlace(), we'll do it ourselves after the
|
||||||
|
// client code has connected
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// from GameController
|
// from GameController
|
||||||
override public function attributeChanged (event :AttributeChangedEvent) :void
|
override public function attributeChanged (event :AttributeChangedEvent) :void
|
||||||
{
|
{
|
||||||
@@ -116,22 +132,6 @@ public class EZGameController extends GameController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from GameController
|
|
||||||
override protected function playerReady () :void
|
|
||||||
{
|
|
||||||
// we require the user to be connected, and we redundantly only do this if the user is in
|
|
||||||
// the players array
|
|
||||||
if (_panel.backend.isConnected()) {
|
|
||||||
var bobj :BodyObject = (_ctx.getClient().getClientObject() as BodyObject);
|
|
||||||
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
|
|
||||||
super.playerReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log.debug("Waiting to call playerReady, userCode not yet connected.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// from GameController
|
// from GameController
|
||||||
override protected function gameDidStart () :void
|
override protected function gameDidStart () :void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -540,7 +540,8 @@ public class GameControlBackend
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the client code when it is ready for the game to be started.
|
* Called by the client code when it is ready for the game to be started (if called before the
|
||||||
|
* game ever starts) or rematched (if called after the game has ended).
|
||||||
*/
|
*/
|
||||||
protected function playerReady_v1 () :void
|
protected function playerReady_v1 () :void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,14 +95,15 @@ public /*abstract*/ class GameController extends PlaceController
|
|||||||
// and add ourselves as a listener
|
// and add ourselves as a listener
|
||||||
_gobj.addListener(this);
|
_gobj.addListener(this);
|
||||||
|
|
||||||
// we don't want to claim to be finished until any derived classes that overrode this
|
// potentially let the game manager know that we're ready to roll
|
||||||
// method have executed, so we'll queue up a runnable here that will let the game manager
|
if (shouldAutoPlayerReady(bobj)) {
|
||||||
// know that we're ready on the next pass through the distributed event loop
|
// we don't want to claim to be finished until any derived classes that overrode this
|
||||||
log.info("Entering game " + _gobj.which() + ".");
|
// method have executed, so we'll queue up a runnable here that will let the game
|
||||||
if (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1) {
|
// manager know that we're ready on the next pass through the distributed event loop
|
||||||
// finally let the game manager know that we're ready to roll
|
|
||||||
_ctx.getClient().callLater(playerReady);
|
_ctx.getClient().callLater(playerReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Entered game " + _gobj.which() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,6 +223,14 @@ public /*abstract*/ class GameController extends PlaceController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if we should automatically call playerReady() in willEnterPlace().
|
||||||
|
*/
|
||||||
|
protected function shouldAutoPlayerReady (bobj :BodyObject) :Boolean
|
||||||
|
{
|
||||||
|
return (_gobj.getPlayerIndex(bobj.getVisibleName()) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after we've entered the game and everything has initialized
|
* Called after we've entered the game and everything has initialized
|
||||||
* to notify the server that we, as a player, are ready to play.
|
* to notify the server that we, as a player, are ready to play.
|
||||||
|
|||||||
Reference in New Issue
Block a user