コード例 #1
0
  /**
   * Used to DE-Serialise a MF
   *
   * @param s The Serialised Version
   * @param p A SPlanetOld where this MF is placed upon
   * @param r The Random Object
   */
  public void fromString(String s, SPlanetOld p, Random r) {
    s = s.substring(3);
    StringTokenizer ST = new StringTokenizer(s, "*");
    setName(TokenReader.readString(ST));
    setSize(TokenReader.readString(ST));
    setFounder(TokenReader.readString(ST));
    setTicksUntilRefresh(TokenReader.readInt(ST));
    setRefreshSpeed(TokenReader.readInt(ST));

    setBuildTableFolder(TokenReader.readString(ST));

    setType(TokenReader.readInt(ST));
    setLock(TokenReader.readBoolean(ST));
    setAccessLevel(TokenReader.readInt(ST));

    setPlanet(p);
  }
コード例 #2
0
ファイル: CCampaign.java プロジェクト: FireSight/GoonWars
  /**
   * Method that reads data generated by Market2.getAutoMarketStatus() on the server. All data for
   * all BM units sent at once. "|" used to seperate units, * used to seperate fields inside each
   * unit.
   */
  public void setBMData(String command) {

    // create tokenizer
    StringTokenizer mainTokenizer = new StringTokenizer(command, "$");

    // clear all current BM data
    BlackMarket.clear();

    while (mainTokenizer.hasMoreTokens()) {
      boolean hidden = Boolean.parseBoolean(mwclient.getserverConfigs("HiddenBMUnits"));
      CBMUnit currBMUnit = new CBMUnit(TokenReader.readString(mainTokenizer), this, hidden);
      BlackMarket.put(currBMUnit.getAuctionID(), currBMUnit);
    }
  }
コード例 #3
0
ファイル: CCampaign.java プロジェクト: FireSight/GoonWars
  public void setComponentConverter(String converterData) {
    try {
      StringTokenizer st = new StringTokenizer(converterData, "#");

      ComponentConverter.clear();
      while (st.hasMoreTokens()) {
        ComponentToCritsConverter converter = new ComponentToCritsConverter();
        converter.setCritName(TokenReader.readString(st));
        converter.setMinCritLevel(TokenReader.readInt(st));
        converter.setComponentUsedType(TokenReader.readInt(st));
        converter.setComponentUsedWeight(TokenReader.readInt(st));
        ComponentConverter.put(converter.getCritName(), converter);
      }
      mwclient.setWaiting(false);
    } catch (Exception ex) {
      CampaignData.mwlog.errLog(ex);
    }
  }
コード例 #4
0
ファイル: CCampaign.java プロジェクト: FireSight/GoonWars
  public boolean decodeCommand(String command) {
    StringTokenizer ST;
    String element;

    ST = new StringTokenizer(command, "|");
    element = TokenReader.readString(ST);
    /*    if (!element.equals("CC")) {return(false);}
    element = TokenReader.readString(ST);*/
    command = command.substring(3);

    if (element.equals("PS")) {
      if (!Player.setData(command)) {
        mwclient.addToChat("Player data load failed!<br>");
        return (false);
      }
      return (true);
    }

    if (element.equals("CC")) // Campaign Command
    {
      String commandid = TokenReader.readString(ST);
      if (commandid.equals("AT")) { // incoming attack

        if (mwclient.getConfig().isParam("ENABLEATTACKSOUND")) {
          mwclient.doPlaySound(mwclient.getConfigParam("SOUNDONATTACK"));
        }

        mwclient.addToChat(
            "<font color=\"red\"><b>Your forces are under attack!</b></font>",
            CCommPanel.CHANNEL_HMAIL);
        mwclient.addToChat(
            "<font color=\"red\"><b>Your forces are under attack!</b></font>",
            CCommPanel.CHANNEL_PMAIL,
            "Server");
        if (mwclient.getConfig().isParam("POPUPONATTACK")) {
          int opID = TokenReader.readInt(ST);
          int teams = TokenReader.readInt(ST);
          // mwclient.showInfoWindow("Your forces are under attack!");
          new ArmyViewerDialog(
              mwclient, null, ST, ArmyViewerDialog.AVD_DEFEND, null, null, opID, teams);
        }
      }
      if (commandid.equals("NT")) { // next tick

        int time = TokenReader.readInt(ST);
        boolean decrement = TokenReader.readBoolean(ST);
        mwclient.processTick(time);

        /*
         * Decrements tick counters for units without explicit auction
         * length being sent from the server to save a bit of bandwidth.
         */
        if (decrement) {
          for (CBMUnit currUnit : BlackMarket.values()) {
            currUnit.decrementSalesTicks();
          }
          mwclient.refreshGUI(MWClient.REFRESH_BMPANEL);
        }
      }
      return (true);
    }
    if (element.equals("CA")) {
      if (!setData(command)) {
        mwclient.addToChat("<b>Error: Campaign data load failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("PL")) {
      if (!Player.decodeCommand(command)) {
        mwclient.addToChat("<b>Error: Player data load failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("MS")) {
      if (!showMsg(command)) {
        mwclient.addToChat("<b>Error: Message show failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("ST")) {
      if (!showStatus(command)) {
        mwclient.addToChat("<b>Error: Status show failed.</b><br>");
        return (false);
      }
      return (true);
    }

    mwclient.addToChat("<b>Error: Wrong campaign command from server.</b><br>");
    return (false);
  }