Package net.coljac.pirates

Examples of net.coljac.pirates.Fort


      if (!(link.getText().indexOf("(Fort)") > 0)) continue;
      if (link.getText().indexOf("Firepot") < 0) {
        int start = link.getURLString().indexOf("unitid=") + 7;
        int end = link.getURLString().indexOf("'", start);
        String id = link.getURLString().substring(start, end);
        Fort fort = getFort(id);
        MakeDB.db.getShips().add(fort);
        MakeDB.db.getCards().add(fort);

        if (pw != null) {
          pw.println(fort.toCSV());
          pw.flush();
        }
        evts++;
      }
    }
View Full Code Here


    String response = FileTools.getFileContentsAsString(cacheFile);
    if (response == null) {
      response = WebTools.getURLAsString(url);
      file(cacheFile, response);
    }
    Fort fort = new Fort();
    fort.setName(getTableValue("Name", response));
    fort.setPoints(Integer.parseInt(getTableValue("Point Value", response)));
    String colNumber = getTableValue("Collector's Number", response);
    String number = colNumber;
    if (number.indexOf("-") > 0) {
      int base = -1;
      if (number.startsWith("PS")) {
        base = 0;
      }
      if (number.startsWith("ES")) {
        base = 40;
      }
      if (number.startsWith("SS")) {
        base = 68;
      }
      String remainder = number.substring(number.indexOf("-") + 1);
      if (base >= 0) {
        number = "" + (Integer.parseInt(remainder) + base);
      }
    }


    String goldCostString = getTableValue("Gold Cost", response);
    if(goldCostString !=null) {
      int cost = Integer.parseInt(goldCostString);
      fort.setGoldCost(cost);
    }

    fort.setNumber(number);
    fort.setExtra(colNumber);
    fort.setRarity(getTableValue("Rarity", response));

    String guns = "";
    for (int i = 1; i < 7; i++) {
      String gun = getTableValue("Mast " + i + " Cannon", response);
      if (gun != null) {
        guns += "," + gun;
      } else {
        gun = getTableValue("Gun " + i, response);
        if (gun != null) {
          guns += "," + gun;
        } else {
          break;
        }
      }
    }
    if (guns.startsWith(",")) {
      guns = guns.substring(1);
    }

    fort.setCannons(cleanGuns(guns));

    String masts = getTableValue("Cannons", response);
    if (masts == null) {
      masts = getTableValue(" Cannons", response);
    }
    fort.setMasts(Integer.parseInt(masts));

    // <td><strong>Broadsides Attack</strong>
    //      <p>Not every fort can live up to the name "La Magnifique," but with Capitaine de
    // St. Croix in command, this fort is just that?nigh invincible when delivering a full cannon barrage.</p></td>

    String marker = "<td><strong>";

    if (response.indexOf(marker) > -1) {
      int start = response.indexOf(marker);
      int end = response.indexOf("</td>", start);

      String cell = response.substring(start + 12, end - 4);
      cell = cell.trim();
      cell = cell.replaceAll("<P>", "<p>");
      cell = cell.replaceAll("</strong>", "");
      cell = cell.replaceAll("^ *<p>", "");
      cell = cell.trim();
      cell = cell.replaceAll("^<p>", "");
      String[] parts = cell.trim().split("<p>");
      if (parts.length == 1) {
        fort.setRules("No ability.");
        fort.setFlavor(parts[0].trim());
      } else {
        fort.setRules(fixRules(parts[0].trim()));
        fort.setFlavor(parts[1].trim());
      }
    }

    if (response.indexOf("src=\"images/Release") > -1) {
      int start = response.indexOf("src=\"images/Release");
      int end = response.indexOf("width", start);
      String set = response.substring(start, end);
      set = set.replaceAll(".*alt=\"(.*)\"", "$1");
      fort.setExpansion(set.trim());
    }

    if (response.indexOf("src=\"images/faction") > -1) {
      int start = response.indexOf("src=\"images/faction");
      int end = response.indexOf("width", start);
      String faction = response.substring(start, end);
      faction = faction.replaceAll(".*alt=\"(.*)\"", "$1");
      fort.setFaction(faction.trim());
    }
    return fort;
  }
View Full Code Here

TOP

Related Classes of net.coljac.pirates.Fort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.