Package net.coljac.pirates

Examples of net.coljac.pirates.Crew


      WebLink link = links[i];
      if (link.getText().indexOf("Crew") > 0) {
        int start = link.getURLString().indexOf("unitid=") + 7;
        int end = link.getURLString().indexOf("'", start);
        String id = link.getURLString().substring(start, end);
        Crew crew = getCrewCard(id);
        MakeDB.db.getCrew().add(crew);
        MakeDB.db.getCards().add(crew);

        if (pw != null) {
          pw.println(crew.toCSV());
        }
        crews++;
      }
    }
//    HibernateUtil.commit();
View Full Code Here


    String response = FileTools.getFileContentsAsString(cacheFile);
    if (response == null) {
      response = WebTools.getURLAsString(url);
      file(cacheFile, response);
    }
    Crew crew = new Crew();
    crew.setName(getTableValue("Name", response));
    crew.setPoints(Integer.parseInt(getTableValue("Point Value", response)));
    String number = getTableValue("Collector's Number", response);
//    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);
//      }
//    }

    crew.setNumber(number);
    crew.setRarity(getTableValue("Rarity", response));
    crew.setRank(getTableValue("Rank", response));
    crew.setLink(getTableValue("Link", response));


    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) {
        crew.setRules("");
        crew.setFlavor(parts[0].trim());
      } else {
        crew.setRules(fixRules(parts[0].trim()));
        crew.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");
      crew.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");
      crew.setFaction(faction.trim());
    }
    return crew;
  }
View Full Code Here

    if (fleetsPanel == null) {
      addToFleet.setEnabled(false);
    }
    addToFleet.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Crew c = cards.get(model.getLastClickedRow());
        Fleet f = fleetsPanel.getCurrentFleet();
        if (f != null) {
          f.addCrew(c);
          fleetsPanel.fleetChanged();
          statusBar.setText(c.getName() + " added to fleet.");
        }
      }
    });
    menu.add(addToFleet);
    addToShip = new JMenu("Add to ship");
View Full Code Here

    if (fleetsPanel.getCurrentFleet() != null) {
      List<Ship> ships = fleetsPanel.getCurrentFleet().getShips();

      for (Ship ship : ships) {
        final Ship craft = ship;
        final Crew man = cards.get(model.getLastClickedRow());
        JMenuItem item = new JMenuItem(ship.getName());
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fleetsPanel.getCurrentFleet().addCrewToShip(craft, man);
            fleetsPanel.fleetChanged();
            statusBar.setText(man.getName() + " added to fleet.");
          }
        });
        addToShip.add(item);
      }
    }
View Full Code Here

    public int getColumnCount() {
      return cols.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
      Crew crew = cards.get(rowIndex);

      switch (columnIndex) {
        case 0:
          return crew.getOwned();
        case 1:
          return crew.getWanted();
        case 2:
          return crew.getNumber();
        case 3:
          return Card.getSetAbbreviation(crew.getExpansion());
        case 4:
          return crew.getName();
        case 5:
          return crew.getPoints();
        case 6:
          return crew.getFaction();
        case 7:
          return crew.getRules();
        case 8:
          return crew.getLink();
        case 9:
          return crew.getRarity();
        default:
          return null;
      }
    }
View Full Code Here

    HibernateUtil.commit();

    List l = HibernateUtil.createQuery("from Ship as ship").list();
    assertEquals(1, l.size());

    Crew crew = new Crew();
    crew.setName("crew");
    crew.setExtra("aa");
    crew.setOwned(1);
    HibernateUtil.save(crew);
    HibernateUtil.commit();

    l = HibernateUtil.createQuery("from Crew as crew").list();
    assertEquals(1, l.size());
View Full Code Here

    Collections.sort(crew, this);
  }


  public int compare(Object o1, Object o2) {
    Crew crew1 = (Crew) o1;
    Crew crew2 = (Crew) o2;

    int criterion = 0;
    for (criterion = 0; criterion < sortOrder.length; criterion ++) {
      int result = compareCrew(crew1, crew2, sortOrder[criterion]);
      if (result != 0) {
View Full Code Here

  public int compareCrew(Crew crew1, Crew crew2, int criterion) {
    int c = criterion;
    if (c < 0) {
      c = Math.abs(c);
      Crew temp = crew1;
      crew1 = crew2;
      crew2 = temp;
    }

    int result = 0;
View Full Code Here

TOP

Related Classes of net.coljac.pirates.Crew

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.