From 402ef10aa47580667b0333701afc94ed8152393c Mon Sep 17 00:00:00 2001 From: Ed Thelleres Date: Fri, 3 Nov 2023 21:43:50 +0100 Subject: [PATCH 1/2] reactions calculations were basically ignored --- .../data/settings/ManufacturingSettings.java | 80 ++++++++++++++++ .../tabs/stockpile/StockpileItemDialog.java | 95 ++++++++++++++++--- .../jeveasset/io/shared/ApiIdConverter.java | 14 +++ 3 files changed, 178 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/nikr/eve/jeveasset/data/settings/ManufacturingSettings.java b/src/main/java/net/nikr/eve/jeveasset/data/settings/ManufacturingSettings.java index 6d81b47c5..fcc76864a 100644 --- a/src/main/java/net/nikr/eve/jeveasset/data/settings/ManufacturingSettings.java +++ b/src/main/java/net/nikr/eve/jeveasset/data/settings/ManufacturingSettings.java @@ -127,6 +127,49 @@ public static ManufacturingRigs getDefault() { } } + public static enum ReactionRigs { + NONE(0) { + @Override + public String getText() { + return DialoguesSettings.get().manufacturingRigsNone(); + } + }, + T1(2.0) { + @Override + public String getText() { + return DialoguesSettings.get().manufacturingRigsT1(); + } + }, + T2(2.40) { + @Override + public String getText() { + return DialoguesSettings.get().manufacturingRigsT2(); + } + }; + + private final double materialBonus; + + private ReactionRigs(double materialBonus) { + this.materialBonus = materialBonus; + } + + public abstract String getText(); + + @Override + public String toString() { + return getText(); + //return getText() + " (" + materialBonus + "%)"; + } + + public double getMaterialBonus() { + return materialBonus; + } + + public static ReactionRigs getDefault() { + return NONE; + } + } + public static enum ManufacturingSecurity { HIGHSEC(1) { @Override @@ -170,6 +213,43 @@ public static ManufacturingSecurity getDefault() { } } + public static enum ReactionSecurity { + LOWSEC(1.0) { + @Override + public String getText() { + return DialoguesSettings.get().manufacturingSecurityLowSec(); + } + }, + NULLSEC(1.1) { + @Override + public String getText() { + return DialoguesSettings.get().manufacturingSecurityNullSec(); + } + }; + + private final double rigBonus; + + private ReactionSecurity(double rigBonus) { + this.rigBonus = rigBonus; + } + + public abstract String getText(); + + public double getRigBonus() { + return rigBonus; + } + + @Override + public String toString() { + return getText(); + //return getText() + " (" + rigBonus + "%)"; + } + + public static ReactionSecurity getDefault() { + return LOWSEC; + } + } + private Map prices = new HashMap<>(); //Adjusted Prices private Map systems = new HashMap<>(); //System Indexs private Date nextUpdate = getNow(); diff --git a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/stockpile/StockpileItemDialog.java b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/stockpile/StockpileItemDialog.java index f9ab85300..02b87eb4f 100644 --- a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/stockpile/StockpileItemDialog.java +++ b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/stockpile/StockpileItemDialog.java @@ -52,7 +52,9 @@ import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingFacility; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingRigs; +import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ReactionRigs; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingSecurity; +import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ReactionSecurity; import net.nikr.eve.jeveasset.data.settings.Settings; import net.nikr.eve.jeveasset.gui.images.Images; import net.nikr.eve.jeveasset.gui.shared.components.JDialogCentered; @@ -108,11 +110,14 @@ public String toString() { private final JComboBox jMe; private final JComboBox jFacility; private final JComboBox jRigs; + private final JComboBox jRigsReactions; private final JComboBox jSecurity; + private final JComboBox jSecurityReactions; private final JLabel jIgnoreMultiplierLabel; private final JCheckBox jIgnoreMultiplier; private final List manufacturingComponents = new ArrayList<>(); + private final List reactionComponents = new ArrayList<>(); private final EventList items = EventListManager.create(); private Stockpile stockpile; private StockpileItem stockpileItem; @@ -193,11 +198,35 @@ public void actionPerformed(ActionEvent e) { }); manufacturingComponents.add(jRigs); + JLabel jRigsReactionsLabel = new JLabel(TabsStockpile.get().blueprintRigs()); + reactionComponents.add(jRigsReactionsLabel); + jRigsReactions = new JComboBox<>(ReactionRigs.values()); + jRigsReactions.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ReactionRigs rigs = jRigsReactions.getItemAt(jRigsReactions.getSelectedIndex()); + if (rigs == ReactionRigs.NONE) { + jSecurityReactions.setSelectedIndex(0); + jSecurityReactions.setEnabled(false); + } else { + jSecurityReactions.setEnabled(true); + } + } + }); + reactionComponents.add(jRigsReactions); + + JLabel jSecurityLabel = new JLabel(TabsStockpile.get().blueprintSecurity()); manufacturingComponents.add(jSecurityLabel); jSecurity = new JComboBox<>(ManufacturingSecurity.values()); manufacturingComponents.add(jSecurity); + JLabel jSecurityReactionsLabel = new JLabel(TabsStockpile.get().blueprintSecurity()); + reactionComponents.add(jSecurityReactionsLabel); + jSecurityReactions = new JComboBox<>(ReactionSecurity.values()); + reactionComponents.add(jSecurityReactions); + + jOK = new JButton(TabsStockpile.get().ok()); jOK.setActionCommand(StockpileItemAction.OK.name()); jOK.addActionListener(listener); @@ -216,7 +245,9 @@ public void actionPerformed(ActionEvent e) { .addComponent(jMeLabel) .addComponent(jFacilityLabel) .addComponent(jRigsLabel) + .addComponent(jRigsReactionsLabel) .addComponent(jSecurityLabel) + .addComponent(jSecurityReactionsLabel) .addComponent(jIgnoreMultiplierLabel) .addComponent(jCountMinimumLabel) ) @@ -227,7 +258,9 @@ public void actionPerformed(ActionEvent e) { .addComponent(jMe, 300, 300, 300) .addComponent(jFacility, 300, 300, 300) .addComponent(jRigs, 300, 300, 300) + .addComponent(jRigsReactions, 300, 300, 300) .addComponent(jSecurity, 300, 300, 300) + .addComponent(jSecurityReactions, 300, 300, 300) .addComponent(jIgnoreMultiplier, 300, 300, 300) .addComponent(jCountMinimum, 300, 300, 300) ) @@ -260,10 +293,18 @@ public void actionPerformed(ActionEvent e) { .addComponent(jRigsLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jRigs, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) ) + .addGroup(layout.createParallelGroup() + .addComponent(jRigsReactionsLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) + .addComponent(jRigsReactions, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) + ) .addGroup(layout.createParallelGroup() .addComponent(jSecurityLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jSecurity, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) ) + .addGroup(layout.createParallelGroup() + .addComponent(jSecurityReactionsLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) + .addComponent(jSecurityReactions, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) + ) .addGroup(layout.createParallelGroup() .addComponent(jIgnoreMultiplierLabel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) .addComponent(jIgnoreMultiplier, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight()) @@ -405,7 +446,9 @@ private List getStockpileItems() { Integer me = jMe.getItemAt(jMe.getSelectedIndex()); ManufacturingFacility facility = jFacility.getItemAt(jFacility.getSelectedIndex()); ManufacturingRigs rigs = jRigs.getItemAt(jRigs.getSelectedIndex()); + ReactionRigs rigsReactions = jRigsReactions.getItemAt(jRigsReactions.getSelectedIndex()); ManufacturingSecurity security = jSecurity.getItemAt(jSecurity.getSelectedIndex()); + ReactionSecurity securityReactions = jSecurityReactions.getItemAt(jSecurityReactions.getSelectedIndex()); if (jBlueprintType.isEnabled() && jBlueprintType.getItemAt(jBlueprintType.getSelectedIndex()) == BlueprintAddType.MANUFACTURING_MATERIALS) { //Manufacturing Materials for (IndustryMaterial material : item.getManufacturingMaterials()) { @@ -417,7 +460,7 @@ private List getStockpileItems() { //Reaction Materials for (IndustryMaterial material : item.getReactionMaterials()) { Item materialItem = ApiIdConverter.getItem(material.getTypeID()); - double count = ApiIdConverter.getManufacturingQuantity(material.getQuantity(), me, facility, rigs, security, countMinimum, false); + double count = ApiIdConverter.getReactionQuantity(material.getQuantity(), rigsReactions, securityReactions, countMinimum, false); itemsMaterial.add(new StockpileItem(getStockpile(), materialItem, material.getTypeID(), count, false, ignoreMultiplier)); } } else { @@ -619,17 +662,47 @@ public void actionPerformed(final ActionEvent e) { autoSet(); autoValidate(); BlueprintAddType currentBlueprintAddType = jBlueprintType.getItemAt(jBlueprintType.getSelectedIndex()); - if ((lastBlueprintAddType == null || lastBlueprintAddType != BlueprintAddType.MANUFACTURING_MATERIALS) && jBlueprintType.isEnabled() && currentBlueprintAddType == BlueprintAddType.MANUFACTURING_MATERIALS) { - for (JComponent jComponent : manufacturingComponents) { - jComponent.setVisible(true); + if (lastBlueprintAddType != currentBlueprintAddType) { + if (lastBlueprintAddType == null) { + for (JComponent jComponent : manufacturingComponents) { + jComponent.setVisible(false); + } + for (JComponent jComponent : reactionComponents) { + jComponent.setVisible(false); + } + } else { + switch (lastBlueprintAddType) { + case MANUFACTURING_MATERIALS: + for (JComponent jComponent : manufacturingComponents) { + jComponent.setVisible(false); + } + break; + case REACTION_MATERIALS: + for (JComponent jComponent : reactionComponents) { + jComponent.setVisible(false); + } + break; + } } - jMe.setSelectedIndex(0); - jFacility.setSelectedIndex(0); - jRigs.setSelectedIndex(0); - getDialog().pack(); - } else if ((lastBlueprintAddType == null || lastBlueprintAddType == BlueprintAddType.MANUFACTURING_MATERIALS) && currentBlueprintAddType != BlueprintAddType.MANUFACTURING_MATERIALS) { - for (JComponent jComponent : manufacturingComponents) { - jComponent.setVisible(false); + if (jBlueprintType.isEnabled()) { + switch (currentBlueprintAddType) { + case MANUFACTURING_MATERIALS: + for (JComponent jComponent : manufacturingComponents) { + jComponent.setVisible(true); + } + jMe.setSelectedIndex(0); + jFacility.setSelectedIndex(0); + jRigs.setSelectedIndex(0); + break; + case REACTION_MATERIALS: + for (JComponent jComponent : reactionComponents) { + jComponent.setVisible(true); + jComponent.setEnabled(true); + } + jRigsReactions.setSelectedIndex(0); + jRigsReactions.setEnabled(true); + break; + } } getDialog().pack(); } diff --git a/src/main/java/net/nikr/eve/jeveasset/io/shared/ApiIdConverter.java b/src/main/java/net/nikr/eve/jeveasset/io/shared/ApiIdConverter.java index a290d4c42..b38eee7f2 100644 --- a/src/main/java/net/nikr/eve/jeveasset/io/shared/ApiIdConverter.java +++ b/src/main/java/net/nikr/eve/jeveasset/io/shared/ApiIdConverter.java @@ -47,7 +47,9 @@ import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingFacility; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingRigs; +import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ReactionRigs; import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ManufacturingSecurity; +import net.nikr.eve.jeveasset.data.settings.ManufacturingSettings.ReactionSecurity; import net.nikr.eve.jeveasset.data.settings.PriceData; import net.nikr.eve.jeveasset.data.settings.ReprocessSettings; import net.nikr.eve.jeveasset.data.settings.Settings; @@ -383,6 +385,10 @@ public static double getManufacturingQuantity(int quantity, int me, Manufacturin return roundManufacturingQuantity(quantity * percentToBonus(me) * percentToBonus(facility.getMaterialBonus()) * rigToBonus(rigs, security), runs, round); } + public static double getReactionQuantity(int quantity, ManufacturingSettings.ReactionRigs rigs, ManufacturingSettings.ReactionSecurity security, double runs, boolean round) { + return roundManufacturingQuantity(quantity * rigToBonus(rigs, security), runs, round); + } + private static double roundManufacturingQuantity(double manufacturingQuantity, double runs, boolean round) { //max(runs,round(ceil((base * ((100-ME)/100) * (EC modifier) * (EC Rig modifier))*runs,2))) double quantity = Math.max(runs, roundQuantity(manufacturingQuantity, 2) * runs); @@ -405,6 +411,14 @@ private static double rigToBonus(ManufacturingRigs rigs, ManufacturingSecurity s } } + private static double rigToBonus(ReactionRigs rigs, ReactionSecurity security) { + if (rigs == ReactionRigs.NONE) { + return 1; + } else { + return percentToBonus(rigs.getMaterialBonus() * security.getRigBonus()); + } + } + private static double roundQuantity(double value, int places) { double scale = Math.pow(10, places); return Math.round(value * scale) / scale; From c48ec965a11217d57214cea8675049e1319c92d5 Mon Sep 17 00:00:00 2001 From: Ed Thelleres Date: Fri, 3 Nov 2023 21:53:21 +0100 Subject: [PATCH 2/2] contribution credits --- credits.txt | 1 + .../java/net/nikr/eve/jeveasset/gui/dialogs/AboutDialog.java | 1 + 2 files changed, 2 insertions(+) diff --git a/credits.txt b/credits.txt index 012e11c75..f3d8e7959 100644 --- a/credits.txt +++ b/credits.txt @@ -39,6 +39,7 @@ Contributors: Burberius Lazaren Boran Lordsworth + Ed Thelleres Retired Testers: Varo Jan diff --git a/src/main/java/net/nikr/eve/jeveasset/gui/dialogs/AboutDialog.java b/src/main/java/net/nikr/eve/jeveasset/gui/dialogs/AboutDialog.java index 3351dc9cf..423ce908f 100644 --- a/src/main/java/net/nikr/eve/jeveasset/gui/dialogs/AboutDialog.java +++ b/src/main/java/net/nikr/eve/jeveasset/gui/dialogs/AboutDialog.java @@ -111,6 +111,7 @@ public AboutDialog(final Program program) { + " Burberius
" + " Lazaren
" + " Boran Lordsworth
" + + " Ed Thelleres
" + "
" + "Retired Testers
" + " Varo Jan
"