diff --git a/src/java/com/threerings/parlor/game/server/GameManager.java b/src/java/com/threerings/parlor/game/server/GameManager.java index 21f2d774..9491f481 100644 --- a/src/java/com/threerings/parlor/game/server/GameManager.java +++ b/src/java/com/threerings/parlor/game/server/GameManager.java @@ -33,6 +33,7 @@ import com.samskivert.util.StringUtil; import com.samskivert.util.Tuple; import com.threerings.util.Name; +import com.threerings.presents.data.ClientObject; import com.threerings.presents.dobj.AttributeChangeListener; import com.threerings.presents.dobj.AttributeChangedEvent; import com.threerings.presents.dobj.DObject; @@ -41,6 +42,7 @@ import com.threerings.crowd.chat.server.SpeakUtil; import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.server.PlaceManagerDelegate; +import com.threerings.crowd.server.PlayManager; import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.game.data.GameAI; @@ -61,7 +63,7 @@ import static com.threerings.parlor.Log.log; * location, the players of the game implicitly bodies in that location. */ public class GameManager extends PlaceManager - implements ParlorCodes, GameCodes + implements ParlorCodes, GameCodes, PlayManager { /** * An interface for identifying users. A larger system using the Parlor game services can @@ -652,6 +654,43 @@ public class GameManager extends PlaceManager isAI(pidx)); // player is AI } + // from PlayManager + public boolean isPlayer (ClientObject client) + { + // players must have bodies + if (client != null && client instanceof BodyObject) { + BodyObject body = (BodyObject) client; + + // players must be occupants + if (_gameobj.occupants.contains(body.getOid())) { + + // in a party game, all occupants are players + if (getGameConfig().getMatchType() == GameConfig.PARTY) { + return true; + } + + // else they must be seated + return _gameobj.getPlayerIndex(body.getVisibleName()) >= 0; + } + } + return false; + } + + // from PlayManager + public boolean isAgent (ClientObject client) + { + // agent-savvy subclasses override this + return false; + } + + // from PlayManager + public BodyObject checkWritePermission (ClientObject client, int playerId) + { + // subclasses can be more restrictive here + return true; + } + + /** * Returns true if this game requires a no-show timer. The default implementation returns true * for non-party games and false for party games. Derived classes may wish to change or augment diff --git a/src/java/com/threerings/parlor/game/server/GameManagerDelegate.java b/src/java/com/threerings/parlor/game/server/GameManagerDelegate.java index cb8903d1..7c78d76b 100644 --- a/src/java/com/threerings/parlor/game/server/GameManagerDelegate.java +++ b/src/java/com/threerings/parlor/game/server/GameManagerDelegate.java @@ -21,16 +21,16 @@ package com.threerings.parlor.game.server; -import com.threerings.util.Name; +import com.threerings.crowd.server.PlayManagerDelegate; -import com.threerings.crowd.server.PlaceManagerDelegate; +import com.threerings.util.Name; import com.threerings.parlor.game.data.GameAI; /** - * Extends the {@link PlaceManagerDelegate} mechanism with game manager specific methods. + * Extends the {@link PlayManagerDelegate} mechanism with game manager specific methods. */ -public class GameManagerDelegate extends PlaceManagerDelegate +public class GameManagerDelegate extends PlayManagerDelegate { public GameManagerDelegate () { diff --git a/src/java/com/threerings/parlor/rating/server/RatingDelegate.java b/src/java/com/threerings/parlor/rating/server/RatingDelegate.java index b1062bae..ed6ea439 100644 --- a/src/java/com/threerings/parlor/rating/server/RatingDelegate.java +++ b/src/java/com/threerings/parlor/rating/server/RatingDelegate.java @@ -46,7 +46,6 @@ import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceObject; -import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameObject; import com.threerings.parlor.game.server.GameManager; import com.threerings.parlor.game.server.GameManagerDelegate; @@ -181,30 +180,6 @@ public abstract class RatingDelegate extends GameManagerDelegate return new Rating(bobj, playerId); } - /** - * Returns true if the supplied occupant is a player, false if not. - */ - protected boolean isPlayer (BodyObject occupant) - { - // avoid having to do this check all over the damned place - if (occupant == null) { - return false; - } - - // if this is a seated table game, ask the game object - if (_gobj.getPlayerIndex(occupant.getVisibleName()) != -1) { - return true; - } - - // if this is a party game, everyone's a player! - if (_gmgr.getGameConfig().getMatchType() == GameConfig.PARTY) { - return true; - } - - // otherwise, sorry pardner - return false; - } - /** * Loads up rating information for the specified set of player ids and stores them in the * {@link #_ratings} table.