本文整理汇总了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);
}
}
示例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);
}
示例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());
}
}
示例4: getState
import net.sf.freecol.server.FreeColServer.ServerState; //导入依赖的package包/类
private ServerState getState() {
return getEnumAttribute(STATE_TAG, ServerState.class,
(ServerState)null);
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}