From c459a337ab577a3aa044513dfa970c0362b46f6d Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 26 Feb 2007 22:59:56 +0000 Subject: [PATCH] Added seating.getMyPosition(), cuz it's so darn convenient, and we can do it on the backend more efficiently than seating.getPlayerPosition(getMyId()); git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@216 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/as/com/threerings/ezgame/SeatingControl.as | 9 +++++++++ .../com/threerings/ezgame/client/GameControlBackend.as | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/as/com/threerings/ezgame/SeatingControl.as b/src/as/com/threerings/ezgame/SeatingControl.as index c8c93068..0fd599ed 100644 --- a/src/as/com/threerings/ezgame/SeatingControl.as +++ b/src/as/com/threerings/ezgame/SeatingControl.as @@ -36,6 +36,15 @@ public class SeatingControl extends SubControl return int(_ctrl.callEZCodeFriend("getPlayerPosition_v1", playerId)); } + /** + * A convenient function to get our own player position, + * or -1 if we're not a player. + */ + public function getMyPosition () :int + { + return int(_ctrl.callEZCodeFriend("getMyPosition_v1")); + } + /** * Get all the players at the table, in their seated position. * Absent players will be represented by a 0. diff --git a/src/as/com/threerings/ezgame/client/GameControlBackend.as b/src/as/com/threerings/ezgame/client/GameControlBackend.as index 81dd47f5..17522523 100644 --- a/src/as/com/threerings/ezgame/client/GameControlBackend.as +++ b/src/as/com/threerings/ezgame/client/GameControlBackend.as @@ -196,6 +196,7 @@ public class GameControlBackend o["getOccupantName_v1"] = getOccupantName_v1; o["getPlayers_v1"] = getPlayers_v1; o["getPlayerPosition_v1"] = getPlayerPosition_v1; + o["getMyPosition_v1"] = getMyPosition_v1; } /** @@ -326,6 +327,13 @@ public class GameControlBackend return _ezObj.getPlayerIndex(occInfo.username); } + // TODO: table only + public function getMyPosition_v1 () :int + { + return _ezObj.getPlayerIndex( + (_ctx.getClient().getClientObject() as BodyObject).getVisibleName()); + } + // TODO: table only public function getTurnHolder_v1 () :int {