コード例 #1
0
  /**
   * @param i
   * @param name
   * @throws DatabaseException
   * @throws SQLException
   */
  public Object getConfig(int i, String name) {
    String str = "";
    int in = 0;
    long lng = 0;
    double dbl = 0;
    boolean bln = false;
    try {
      Transaction trans = new JDBCTransaction(createConnection());
      Connection connection = ((JDBCTransaction) trans).getConnection();
      Statement stmt = connection.createStatement();

      String query = SQL_CONFIG_GET + "'" + name + "')";

      ResultSet result = stmt.executeQuery(query);
      if (result.next()) {
        switch (i) {
          case (SQL_BLN):
            {
              bln = result.getBoolean("value");
              return bln;
            }
          case (SQL_INT):
            {
              in = result.getInt("value");
              return in;
            }
          case (SQL_DBL):
            {
              dbl = result.getDouble("value");
              return dbl;
            }
          case (SQL_LNG):
            {
              lng = result.getLong("value");
              return lng;
            }
          case (SQL_STR):
            {
              str = result.getString("value");
              return str;
            }
        }
      } else {
        eng.LOG.printError("MySQL Error loading config: name = " + name + " type = " + i, null);
        return null;
      }
    } catch (DatabaseException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return null;
  }
コード例 #2
0
  public void getRaceInfo(int raceID) throws SQLException, DatabaseException {
    Race race = null;
    String rname;
    int[] base = new int[12];
    float spd;

    Transaction trans = new JDBCTransaction(createConnection());

    Connection connection = ((JDBCTransaction) trans).getConnection();
    Statement stmt = connection.createStatement();

    String query = SQL_RACE_LOAD + "'" + raceID + "')";

    ResultSet result = stmt.executeQuery(query);
    if (result.next()) {
      rname = result.getString("name");
      base[0] = result.getInt("hp");
      base[1] = result.getInt("mp");
      base[2] = result.getInt("str");
      base[3] = result.getInt("vit");
      base[4] = result.getInt("dex");
      base[5] = result.getInt("agi");
      base[6] = result.getInt("avd");
      base[7] = result.getInt("int");
      base[8] = result.getInt("mnd");
      base[9] = result.getInt("res");
      base[10] = result.getInt("rt");
      base[11] = result.getInt("luk");
      spd = result.getFloat("spd_adjust");
    } else {
      eng.LOG.printError("MySQL Error loading job ID:" + raceID, null);
      return;
    }

    race = new Race(raceID, rname, base, spd);
    eng.vctRaces.put(raceID, race);
    eng.LOG.printMessage(Log.INFO, "Loaded '" + rname + " Race' ID#[" + raceID + "]");
  }
コード例 #3
0
  public void getJobInfo(int jobID) throws SQLException, DatabaseException {
    Job job = null;
    String jname, strRaces, strWeapons;
    Vector<Integer> r = new Vector<Integer>();
    Vector<Integer> w = new Vector<Integer>();
    double[] rates = new double[15];
    int rt;

    Transaction trans = new JDBCTransaction(createConnection());

    Connection connection = ((JDBCTransaction) trans).getConnection();
    Statement stmt = connection.createStatement();

    String query = SQL_JOBS_LOAD + "'" + jobID + "')";

    ResultSet result = stmt.executeQuery(query);
    if (result.next()) {
      jname = result.getString("name");
      strRaces = result.getString("races_allowed");
      strWeapons = result.getString("weapons_allowed");
      rates[0] = result.getDouble("hp_rate");
      rates[1] = result.getDouble("mp_rate");
      rates[2] = result.getDouble("str_rate");
      rates[3] = result.getDouble("vit_rate");
      rates[4] = result.getDouble("dex_rate");
      rates[5] = result.getDouble("agi_rate");
      rates[6] = result.getDouble("avd_rate");
      rates[7] = result.getDouble("int_rate");
      rates[8] = result.getDouble("mnd_rate");
      rates[9] = result.getDouble("res_rate");
      rates[10] = result.getDouble("luk_rate");
      rates[11] = result.getDouble("atk_rate");
      rates[12] = result.getDouble("def_rate");
      rates[13] = result.getDouble("spd_adjust");
      rt = result.getInt("base_rt");
    } else {
      eng.LOG.printError("MySQL Error loading job ID:" + jobID, null);
      return;
    }
    r = parseCSVString(strRaces);
    w = parseCSVString(strWeapons);

    job = new Job(jobID, jname, r, w, rates, rt);
    eng.vctJobs.put(jobID, job);
  }