Package com.threerings.crowd.data

Examples of com.threerings.crowd.data.BodyObject


    // from interface TableProvider
    public void leaveTable (ClientObject caller, int tableId,
                            TableService.InvocationListener listener)
        throws InvocationException
    {
        BodyObject leaver = (BodyObject)caller;

        // look the table up
        Table table = _tables.get(tableId);
        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        }

        // if the table is in play, the user is not allowed to leave (he must leave the game)
        if (table.inPlay()) {
            throw new InvocationException(GAME_ALREADY_STARTED);
        }

        // request that the user be removed from the table
        if (!table.clearPlayer(leaver.getVisibleName())) {
            throw new InvocationException(NOT_AT_TABLE);
        }

        // remove the mapping from this user to the table
        if (null == notePlayerRemoved(leaver.getOid(), leaver)) {
            log.warning("No body to table mapping to clear?",
                "leaver", leaver.who(), "table", table);
        }

        // either update or delete the table depending on whether or not we just removed the last
        // player
        if (table.isEmpty()) {
View Full Code Here


    // from interface TableProvider
    public void startTableNow (ClientObject caller, int tableId,
                               TableService.InvocationListener listener)
        throws InvocationException
    {
        BodyObject starter = (BodyObject)caller;
        Table table = _tables.get(tableId);
        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        } else if (starter.getOid() != table.bodyOids[0]) {
            throw new InvocationException(MUST_BE_CREATOR);
        } else if (!table.mayBeStarted()) {
            throw new InvocationException(INTERNAL_ERROR);
        }
        createGame(table);
View Full Code Here

    // from interface TableProvider
    public void bootPlayer (ClientObject caller, int tableId, Name target,
                            TableService.InvocationListener listener)
        throws InvocationException
    {
        BodyObject booter = (BodyObject) caller;
        Table table = _tables.get(tableId);

        if (table == null) {
            throw new InvocationException(NO_SUCH_TABLE);
        } else if ( ! _allowBooting) {
            throw new InvocationException(INTERNAL_ERROR);
        }

        int position = ListUtil.indexOf(table.players, target);
        if (position < 0) {
            throw new InvocationException(NOT_AT_TABLE);
        } else if (booter.getOid() != table.bodyOids[0]) {
            throw new InvocationException(MUST_BE_CREATOR);
        } else if (booter.getOid() == table.bodyOids[position]) {
            throw new InvocationException(NO_SELF_BOOT);
        }

        // Remember to keep him banned
        table.addBannedUser(target);
View Full Code Here

                        "game", where(), "player", player);
            return false;
        }

        // get the player's body object
        BodyObject bobj = _locator.lookupBody(player);
        if (bobj == null) {
            log.warning("Unable to get body object while adding player", "game", where(),
                        "player", player);
            return false;
        }

        // fill in the player's information
        _gameobj.setPlayersAt(player, pidx);

        // increment the number of players in the game
        _playerCount++;

        // save off their oid
        _playerOids[pidx] = bobj.getOid();

        // let derived classes do what they like
        playerWasAdded(player, pidx);

        return true;
View Full Code Here

    // 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;
    }
View Full Code Here

    /**
     * Report to the knocked-out player's room that they were knocked out.
     */
    protected void reportPlayerKnockedOut (int pidx)
    {
        BodyObject user = getPlayer(pidx);
        if (user == null) {
            return; // body object can be null for ai players
        }

        DObject place = _omgr.getObject(user.getPlaceOid());
        if (place != null) {
            place.postMessage(PLAYER_KNOCKED_OUT, new Object[] { new int[] { user.getOid() } });
        }
    }
View Full Code Here

            // skip non-existent players and AIs
            if (!_gameobj.isOccupiedPlayer(ii) || isAI(ii)) {
                continue;
            }

            BodyObject bobj = _locator.lookupBody(_gameobj.players[ii]);
            if (bobj == null) {
                log.warning("Unable to deliver game ready to non-existent player",
                            "game", where(), "player", _gameobj.players[ii]);
                continue;
            }
View Full Code Here

        ArrayIntSet winners = new ArrayIntSet(numPlayers);
        ArrayIntSet losers = new ArrayIntSet(numPlayers);
        ArrayIntSet places = new ArrayIntSet(numPlayers);

        for (int ii=0; ii < numPlayers; ii++) {
            BodyObject user = getPlayer(ii);
            if (user != null) {
                places.add(user.getPlaceOid());
                (_gameobj.isWinner(ii) ? winners : losers).add(user.getOid());
            }
        }

        Object[] args = new Object[] { winners.toIntArray(), losers.toIntArray() };
View Full Code Here

    protected BodyObject verifyWritePermission (ClientObject caller, int playerId)
        throws InvocationException
    {
        verifyIsPlayerOrAgent(caller);

        BodyObject player = _gmgr.checkWritePermission(caller, playerId);
        if (player == null) {
            throw new InvocationException(InvocationCodes.ACCESS_DENIED);
        }
        return player;
    }
View Full Code Here

        if (table.equals(_ourTable)) {
            _ourTable = null;
        }

        // look for our username in the occupants array
        BodyObject self = (BodyObject)_ctx.getClient().getClientObject();
        if (table.containsPlayer(self.getVisibleName())) {
            _ourTable = table;
        }

        // if nothing changed, bail now
        if (Objects.equal(oldTable, _ourTable)) {
View Full Code Here

TOP

Related Classes of com.threerings.crowd.data.BodyObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.