Skip to content

Commit

Permalink
Feature: Reaction calculations
Browse files Browse the repository at this point in the history
Merge Master
  • Loading branch information
GoldenGnu committed Apr 28, 2024
2 parents bc4801e + 1be47f5 commit 1726286
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 11 deletions.
1 change: 1 addition & 0 deletions credits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Contributors:
Burberius
Lazaren
Boran Lordsworth
Ed Thelleres

Retired Testers:
Varo Jan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Integer, Double> prices = new HashMap<>(); //Adjusted Prices
private Map<Integer, Float> systems = new HashMap<>(); //System Indexs
private Date nextUpdate = getNow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public AboutDialog(final Program program) {
+ "&nbsp;Burberius<br>"
+ "&nbsp;Lazaren<br>"
+ "&nbsp;Boran Lordsworth<br>"
+ "&nbsp;Ed Thelleres<br>"
+ "<br>"
+ "<b>Retired Testers</b><br>"
+ "&nbsp;Varo Jan<br>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,11 +110,14 @@ public String toString() {
private final JComboBox<Integer> jMe;
private final JComboBox<ManufacturingFacility> jFacility;
private final JComboBox<ManufacturingRigs> jRigs;
private final JComboBox<ReactionRigs> jRigsReactions;
private final JComboBox<ManufacturingSecurity> jSecurity;
private final JComboBox<ReactionSecurity> jSecurityReactions;
private final JLabel jIgnoreMultiplierLabel;
private final JCheckBox jIgnoreMultiplier;

private final List<JComponent> manufacturingComponents = new ArrayList<>();
private final List<JComponent> reactionComponents = new ArrayList<>();
private final EventList<Item> items = EventListManager.create();
private Stockpile stockpile;
private StockpileItem stockpileItem;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
)
Expand All @@ -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)
)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -405,7 +446,9 @@ private List<StockpileItem> 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()) {
Expand All @@ -417,7 +460,7 @@ private List<StockpileItem> 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 {
Expand Down Expand Up @@ -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();
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/nikr/eve/jeveasset/io/shared/ApiIdConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 1726286

Please sign in to comment.