当前位置: 首页>>代码示例>>Java>>正文


Java ServerState类代码示例

本文整理汇总了Java中net.sf.freecol.server.FreeColServer.ServerState的典型用法代码示例。如果您正苦于以下问题:Java ServerState类的具体用法?Java ServerState怎么用?Java ServerState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerState类属于net.sf.freecol.server.FreeColServer包,在下文中一共展示了ServerState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: login

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Complete a login.
 *
 * If we are joining a running game, there is little more
 * needed to be done.  If we are restoring from saved, the
 * game should include a map and a full complement of players,
 * including ours.
 *
 * Otherwise we may still need to select a nation, and
 * optionally change game or map options (using several
 * possible messages).  {@link StartGamePanel} does this.
 *
 * When all the parameters are in place and all players are
 * ready (trivially true in single player, needs checking in
 * multiplayer) the client needs to send a requestLaunch
 * message to ask the server to start the game.  That is
 * either done here or by the start game panel.
 *
 * requestLaunch effectively transfers control to
 * {@link FreeColServer#startGame}.
 *
 * @param state The state of the server.
 * @param game The new {@code Game} to attach to.
 * @param user The name of the player in the game.
 * @param single True if this is a single player game.
 * @param current True if the player is the current player.
 */
public void login(ServerState state, Game game, String user,
                  boolean single, boolean current) {
    final FreeColClient fcc = getFreeColClient();

    Player player = game.getPlayerByName(user);
    if (player == null) {
        StringTemplate err = StringTemplate.template("server.noSuchPlayer")
            .addName("%player%", user);
        getGUI().showErrorMessage(err);
        logger.warning(Messages.message(err));
        return;
    }

    // Reattach to the game
    fcc.login(state == ServerState.IN_GAME, game, player, single);
    if (current) game.setCurrentPlayer(player);
    logger.info("Login accepted for client " + player.getName()
        + " to " + ((fcc.isInGame()) ? "running"
            : (game.allPlayersReadyToLaunch()) ? "ready" : "new")
        + " " + ((single) ? "single" : "multi")
        + "-player game as " + user + "/" + player.getId());

    if (fcc.isInGame()) { // Joining existing game or possibly reconnect
        fcc.restoreGUI(player);
        igc().nextModelMessage();
    } else if (game.getMap() != null
        && game.allPlayersReadyToLaunch()) { // Ready to launch!
        pgc().requestLaunch();
    } else { // More parameters need to be set or players to become ready
        getGUI().showStartGamePanel(game, player, single);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:60,代码来源:ConnectController.java

示例2: LoginMessage

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Create a new {@code LoginMessage} with the supplied parameters.
 *
 * @param serverPlayer The {@code ServerPlayer} to send to.
 * @param userName The name of the user logging in.
 * @param version The version of FreeCol at the client.
 * @param state The server state.
 * @param singlePlayer True in single player games.
 * @param currentPlayer True if this player is the current player.
 * @param game The entire game.
 */
public LoginMessage(ServerPlayer serverPlayer, String userName,
                    String version, ServerState state,
                    boolean singlePlayer, boolean currentPlayer,
                    Game game) {
    super(TAG, USER_NAME_TAG, userName, VERSION_TAG, version,
          SINGLE_PLAYER_TAG, Boolean.toString(singlePlayer),
          CURRENT_PLAYER_TAG, Boolean.toString(currentPlayer));

    this.player = serverPlayer;
    if (state != null) setStringAttribute(STATE_TAG, state.toString());
    appendChild(game);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:LoginMessage.java

示例3: GameStateMessage

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Create a new {@code GameStateMessage} with a given state.
 *
 * @param serverState The {@code serverState} to send.
 */
public GameStateMessage(ServerState serverState) {
    super(TAG);

    if (serverState != null) {
        setStringAttribute(STATE_TAG, serverState.toString());
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:13,代码来源:GameStateMessage.java

示例4: getState

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
private ServerState getState() {
    return getEnumAttribute(STATE_TAG, ServerState.class,
                            (ServerState)null);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:5,代码来源:LoginMessage.java

示例5: clientHandler

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void clientHandler(FreeColClient freeColClient) {
    final ServerState state = getState();
    if (state != null) freeColClient.setServerState(state);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:9,代码来源:GameStateMessage.java

示例6: getServerState

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Get the server state, or at least our most recently cached value.
 *
 * @return A server state.
 */
public ServerState getServerState() {
    return (this.freeColServer == null) ? this.cachedServerState
        : this.freeColServer.getServerState();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:10,代码来源:FreeColClient.java

示例7: setServerState

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Set the cached server state.
 *
 * @param state The new {@code ServerState}.
 */
public void setServerState(ServerState state) {
    this.cachedServerState = state;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:9,代码来源:FreeColClient.java

示例8: canSaveCurrentGame

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Verifies if this client can save the current game
 *
 * Clients that do not have the server running, or that have not
 * the required permissions cannot save and should have the menu
 * entry disabled
 *
 * @return True if this client can save the game in progress.
 */
public boolean canSaveCurrentGame() {
    return freeColServer != null
        && (isAdmin() || freeColServer.getServerState() != ServerState.IN_GAME);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:FreeColClient.java

示例9: getState

import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
/**
 * Get the game state.
 *
 * @return The game state, if present.
 */
private ServerState getState() {
    return getEnumAttribute(STATE_TAG, ServerState.class,
                            (ServerState)null);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:10,代码来源:GameStateMessage.java


注:本文中的net.sf.freecol.server.FreeColServer.ServerState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。