private StockpileItem getExistingItem() {
   Item typeItem = (Item) jItems.getSelectedItem();
   boolean copy = jCopy.isSelected();
   if (getStockpile() != null && typeItem != null) {
     for (StockpileItem item : getStockpile().getItems()) {
       if (item.getTypeID() == typeItem.getTypeID() && (copy == item.isBPC())) {
         return item;
       }
     }
   }
   return null;
 }
Esempio n. 2
0
 public static float getVolume(final int typeID, final boolean packaged) {
   Item item = StaticData.get().getItems().get(typeID);
   if (item != null) {
     if (packagedVolume.isEmpty()) {
       buildVolume();
     }
     if (packaged && packagedVolume.containsKey(item.getGroup())) {
       return packagedVolume.get(item.getGroup());
     } else {
       return item.getVolume();
     }
   }
   return 0;
 }
 private StockpileItem getStockpileItem() {
   Item item = (Item) jItems.getSelectedItem();
   double countMinimum;
   try {
     countMinimum = Double.valueOf(jCountMinimum.getText());
   } catch (NumberFormatException ex) {
     countMinimum = 0;
   }
   boolean copy = jCopy.isSelected() && jCopy.isEnabled();
   int typeID;
   if (copy) {
     typeID = -item.getTypeID();
   } else {
     typeID = item.getTypeID();
   }
   return new StockpileItem(getStockpile(), item, typeID, countMinimum);
 }
Esempio n. 4
0
 public static double getPriceReprocessed(Item item) {
   double priceReprocessed = 0;
   int portionSize = 0;
   for (ReprocessedMaterial material : item.getReprocessedMaterial()) {
     // Calculate reprocessed price
     portionSize = material.getPortionSize();
     double price = ApiIdConverter.getPriceReprocessed(material.getTypeID(), false);
     priceReprocessed =
         priceReprocessed
             + (price
                 * Settings.get()
                     .getReprocessSettings()
                     .getLeft(material.getQuantity(), item.isOre()));
   }
   if (priceReprocessed > 0 && portionSize > 0) {
     priceReprocessed = priceReprocessed / portionSize;
   }
   return priceReprocessed;
 }
Esempio n. 5
0
  public double getPriceSellMin() {
    if (item.isBlueprint() && !isBPO()) {
      return 0;
    }

    if (this.getPriceData() != null) {
      return this.getPriceData().getSellMin();
    }

    return 0;
  }
 private void autoValidate() {
   boolean valid = true;
   boolean color = false;
   if (jItems.getSelectedItem() == null) {
     valid = false;
     jCopy.setEnabled(false);
     jCopy.setSelected(false);
   } else {
     Item item = (Item) jItems.getSelectedItem();
     boolean blueprint = item.getTypeName().toLowerCase().contains("blueprint");
     jCopy.setEnabled(blueprint);
     if (!blueprint) {
       jCopy.setSelected(blueprint);
     }
   }
   if (itemExist() || stockpileItem != null) {
     color = true;
     jCountMinimum.setBackground(new Color(255, 255, 200));
   }
   try {
     double d = Double.valueOf(jCountMinimum.getText());
     if (d <= 0) {
       valid = false; // Negative and zero is not valid
       color = true;
       jCountMinimum.setBackground(new Color(255, 200, 200));
     }
   } catch (NumberFormatException ex) {
     valid = false; // Empty and NaN is not valid
     if (!jCountMinimum.getText().isEmpty()) {
       color = true;
       jCountMinimum.setBackground(new Color(255, 200, 200));
     }
   }
   if (!color) {
     jCountMinimum.setBackground(Color.WHITE);
   }
   jOK.setEnabled(valid);
 }
Esempio n. 7
0
 public MyAsset(
     final Item item,
     final MyLocation location,
     final Owner owner,
     final long count,
     final List<MyAsset> parents,
     final String flag,
     final int flagID,
     final long itemID,
     final boolean singleton,
     final int rawQuantity) {
   this.item = item;
   this.location = location;
   this.owner = owner;
   this.count = count;
   this.parents = parents;
   this.flag = flag;
   this.flagID = flagID;
   this.itemID = itemID;
   this.volume = item.getVolume();
   this.singleton = singleton;
   this.rawQuantity = rawQuantity;
   // The order matter!
   // 1st
   // rawQuantity: -1 = BPO. Only BPOs can be packaged (singleton == false). Only packaged items
   // can be stacked (count > 1)
   this.bpo = (item.isBlueprint() && (rawQuantity == -1 || !singleton || count > 1));
   // rawQuantity: -2 = BPC
   this.bpc = (item.isBlueprint() && rawQuantity == -2);
   // 2nd
   if (item.isBlueprint()) {
     if (isBPO()) {
       this.typeName = item.getTypeName() + " (BPO)";
     } else if (isBPC()) {
       this.typeName = item.getTypeName() + " (BPC)";
     } else {
       this.bpc = true;
       this.typeName = item.getTypeName() + " (BP)";
     }
   } else {
     this.typeName = item.getTypeName();
   }
   // 3rd
   this.name = getTypeName();
 }
Esempio n. 8
0
  private static double getPriceType(
      final int typeID, final boolean isBlueprintCopy, boolean reprocessed) {
    UserItem<Integer, Double> userPrice;
    if (isBlueprintCopy) { // Blueprint Copy
      userPrice = Settings.get().getUserPrices().get(-typeID);
    } else { // All other
      userPrice = Settings.get().getUserPrices().get(typeID);
    }
    if (userPrice != null) {
      return userPrice.getValue();
    }

    // Blueprint Copy (Default Zero)
    if (isBlueprintCopy) {
      return 0;
    }

    // Blueprints Base Price
    Item item = getItem(typeID);
    // Tech 1
    if (item.isBlueprint()) {
      if (Settings.get().isBlueprintBasePriceTech1()
          && !item.getTypeName().toLowerCase().contains("ii")) {
        return item.getPriceBase();
      }
      // Tech 2
      if (Settings.get().isBlueprintBasePriceTech2()
          && item.getTypeName().toLowerCase().contains("ii")) {
        return item.getPriceBase();
      }
    }

    // Price data
    PriceData priceData = Settings.get().getPriceData().get(typeID);
    if (priceData != null && priceData.isEmpty()) {
      priceData = null;
    }
    if (reprocessed) {
      return Settings.get().getPriceDataSettings().getDefaultPriceReprocessed(priceData);
    } else {
      return Settings.get().getPriceDataSettings().getDefaultPrice(priceData);
    }
  }
 @Override
 public void getFilterStrings(final List<String> baseList, final Item element) {
   baseList.add(element.getTypeName());
 }