Exemple #1
0
  /**
   * Requests the game to be started. This will only be successful if all players are ready to start
   * the game.
   */
  public void requestLaunch() {
    if (freeColClient.getGame().isAllPlayersReadyToLaunch()) {
      gui.showStatusPanel(Messages.message("status.startingGame"));
      freeColClient.askServer().requestLaunch();

    } else {
      gui.errorMessage("server.notAllReady");
    }
  }
Exemple #2
0
  /** Starts the game. */
  public void startGame() {
    ResourceMapping gameMapping = new ResourceMapping();
    for (Player player : freeColClient.getGame().getPlayers()) {
      addPlayerResources(player.getNationID(), gameMapping);
    }
    // Unknown nation is not in getPlayers() list.
    addPlayerResources(Nation.UNKNOWN_NATION_ID, gameMapping);
    ResourceManager.addGameMapping(gameMapping);

    Player myPlayer = freeColClient.getMyPlayer();
    if (!freeColClient.isHeadless()) {
      gui.closeMainPanel();
      gui.closeMenus();
      gui.closeStatusPanel();
      gui.playSound(null); // Stop the long introduction sound
      gui.playSound("sound.intro." + myPlayer.getNationID());
    }
    freeColClient.askServer().registerMessageHandler(freeColClient.getInGameInputHandler());

    if (!freeColClient.isHeadless()) {
      freeColClient.setInGame(true);
      gui.setupInGameMenuBar();
    }

    InGameController igc = freeColClient.getInGameController();
    gui.setSelectedTile((Tile) myPlayer.getEntryLocation(), false);
    if (freeColClient.currentPlayerIsMyPlayer()) {
      igc.nextActiveUnit();
    }

    gui.setUpMouseListenersForCanvas();

    if (FreeColDebugger.isInDebugMode() && FreeColDebugger.getDebugRunTurns() > 0) {
      freeColClient.skipTurns(FreeColDebugger.getDebugRunTurns());
    } else if (freeColClient.getGame().getTurn().getNumber() == 1) {
      ModelMessage message =
          new ModelMessage(ModelMessage.MessageType.TUTORIAL, "tutorial.startGame", myPlayer);
      String direction = myPlayer.getNation().startsOnEastCoast() ? "west" : "east";
      message.add("%direction%", direction);
      myPlayer.addModelMessage(message);
      // force view of tutorial message
      igc.nextModelMessage();
    }
  }
Exemple #3
0
  /**
   * Sets a nation's state.
   *
   * @param nation The <code>Nation</code> to set.
   * @param state The <code>NationState</code> value to set.
   */
  public void setAvailable(Nation nation, NationState state) {
    freeColClient.getGame().getNationOptions().getNations().put(nation, state);

    freeColClient.askServer().setAvailable(nation, state);
  }
Exemple #4
0
  /**
   * Sets this client's player's nation type.
   *
   * @param nationType Which nation type this player wishes to set.
   */
  public void setNationType(NationType nationType) {
    freeColClient.getMyPlayer().setNationType(nationType);

    freeColClient.askServer().setNationType(nationType);
  }
Exemple #5
0
  /**
   * Sets this client's player's nation.
   *
   * @param nation Which <code>Nation</code> this player wishes to set.
   */
  public void setNation(Nation nation) {
    freeColClient.getMyPlayer().setNation(nation);

    freeColClient.askServer().setNation(nation);
  }
Exemple #6
0
  /**
   * Sets this client to be (or not be) ready to start the game.
   *
   * @param ready Indicates whether or not this client is ready to start the game.
   */
  public void setReady(boolean ready) {
    freeColClient.getMyPlayer().setReady(ready);

    freeColClient.askServer().setReady(ready);
  }
Exemple #7
0
  /**
   * Sends the {@link MapGeneratorOptions} to the server. This method should be called after
   * updating that object.
   */
  public void sendMapGeneratorOptions() {
    OptionGroup mapOptions = freeColClient.getGame().getMapGeneratorOptions();

    freeColClient.askServer().updateMapGeneratorOption(mapOptions);
  }
Exemple #8
0
  /**
   * Sends the {@link GameOptions} to the server. This method should be called after updating that
   * object.
   */
  public void sendGameOptions() {
    OptionGroup gameOptions =
        freeColClient.getGame().getSpecification().getOptionGroup("gameOptions");

    freeColClient.askServer().updateGameOptions(gameOptions);
  }
Exemple #9
0
 /**
  * Sends a chat message.
  *
  * @param message The text of the message.
  */
 public void chat(String message) {
   freeColClient.askServer().chat(freeColClient.getMyPlayer(), message);
 }