Package com.threerings.parlor.data

Examples of com.threerings.parlor.data.Table


        if (_boidMap.containsKey(creator.getOid())) {
            throw new InvocationException(ALREADY_AT_TABLE);
        }

        // create a brand spanking new table
        Table table;
        try {
            table = _tableClass.newInstance();
        } catch (Exception e) {
            log.warning("Table.newInstance() failed", "class", _tableClass, e);
            throw new InvocationException(INTERNAL_ERROR);
        }
        table.init(_dobj.getOid(), tableConfig, config);

        if (table.bodyOids != null && table.bodyOids.length > 0) {
            // stick the creator into the first non-AI position
            int cpos = (config.ais == null) ? 0 : config.ais.length;
            String error = table.setPlayer(cpos, creator);
            if (error != null) {
                log.warning("Unable to add creator to position zero of table!?",
                   "table", table, "creator", creator, "error", error);
                // bail out now and abort the table creation process
                throw new InvocationException(error);
            }

            // make a mapping from the creator to this table
            notePlayerAdded(table, creator);
        }

        // stick the table into our tables tables
        _tables.put(table.tableId, table);

        // if the table has only one seat, start the game immediately
        if (table.shouldBeStarted()) {
            createGame(table);
        }

        // wire our table into our bits
        tableCreated(table);
View Full Code Here


        if (_boidMap.containsKey(joiner.getOid())) {
            throw new InvocationException(ALREADY_AT_TABLE);
        }

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

        // request that the user be added to the table at that position
        String error = table.setPlayer(position, joiner);
        // if that failed, report the error
        if (error != null) {
            throw new InvocationException(error);
        }

        // if the table is sufficiently full, start the game automatically
        if (table.shouldBeStarted()) {
            createGame(table);
        } else {
            // make a mapping from this player to this table
            notePlayerAdded(table, joiner);
        }
View Full Code Here

        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()) {
            purgeTable(table);
        } else {
            updateTableInLobby(table);
        }
View Full Code Here

    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

    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);

        // Remove the player from the table
        if (notePlayerRemoved(table.bodyOids[position]) == null) {
            log.warning("No body to table mapping to clear?",
               "position", position, "table", table);
        }
        table.clearPlayerPos(position);
        updateTableInLobby(table);
    }
View Full Code Here

                }
            }
        }

        // remove the mapping by gameOid
        Table removed = _goidMap.remove(table.gameOid); // no-op if gameOid == 0

        // remove the table from the lobby object (the table may not have been published if a
        // derived class decided it was not worth publishing, see shouldPublish())
        removeTableFromLobby(table.tableId);
View Full Code Here

        // if we've been shutdown, then we've got nothing to worry about
        if (_tlobj == null) {
            return;
        }

        Table table = _goidMap.get(gameOid);
        if (table != null) {
            purgeTable(table);
        } else {
            log.warning("Requested to unmap table that wasn't mapped", "gameOid", gameOid);
        }
View Full Code Here

        // if we've been shutdown, then we've got nothing to worry about
        if (_tlobj == null) {
            return;
        }

        Table table = _goidMap.get(gameOid);
        if (table == null) {
            log.warning("Unable to find table for running game", "gameOid", gameOid);
            return;
        }

        // update this table's occupants information and update the table
        GameObject gameObj = (GameObject)_omgr.getObject(gameOid);
        table.updateOccupants(gameObj);
        updateTableInLobby(table);
    }
View Full Code Here

     * off of the server.
     */
    protected void bodyLeft (int bodyOid)
    {
        // look up the table to which this player is mapped
        Table pender = notePlayerRemoved(bodyOid);
        if (pender == null) {
            return;
        }

        // remove this player from the table
        if (!pender.clearPlayerByOid(bodyOid)) {
            log.warning("Attempt to remove body from mapped table failed",
                "table", pender, "bodyOid", bodyOid);
            return;
        }

        // update or delete the table depending on whether or not we just removed the last player
        if (pender.isEmpty()) {
            purgeTable(pender);
        } else {
            updateTableInLobby(pender);
        }
    }
View Full Code Here

    // documentation inherited
    public void entryAdded (EntryAddedEvent<Table> event)
    {
        if (event.getName().equals(_tableField)) {
            Table table = event.getEntry();
            // check to see if we just joined a table
            checkSeatedness(table);
            // now let the observer know what's up
            _observer.tableAdded(table);
        }
View Full Code Here

TOP

Related Classes of com.threerings.parlor.data.Table

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.