aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-05 12:32:07 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-05 12:32:07 +0200
commit7528e8d897632ff56f93622c324fb86b9debe1bc (patch)
tree4e56adfca05a2525c1bc52a5274408d9e06be477 /src/main/java/io
parent085911df2e55ee3fd490aab2f225abd0f49d91e5 (diff)
downloadNotEnoughUpdates-7528e8d897632ff56f93622c324fb86b9debe1bc.tar.gz
NotEnoughUpdates-7528e8d897632ff56f93622c324fb86b9debe1bc.tar.bz2
NotEnoughUpdates-7528e8d897632ff56f93622c324fb86b9debe1bc.zip
fixed item price calculation and display
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/sources/NpcSource.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java56
3 files changed, 42 insertions, 23 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
index 58c735e2..a7628d31 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
@@ -123,7 +123,10 @@ public class MinionHelperOverlayHover {
lines.add("§7Buy from: §9" + npcName + " (NPC)");
lines.add("");
lines.add("§7Buy costs: " + manager.getPriceCalculation().calculateUpgradeCostsFormat(minion, true));
- lines.add(" §8- " + manager.getPriceCalculation().formatCoins(npcSource.getCoins()));
+ int coins = npcSource.getCoins();
+ if (coins != 0) {
+ lines.add(" §8- " + manager.getPriceCalculation().formatCoins(coins));
+ }
formatItems(lines, grabAllItems(npcSource.getItems()));
}
@@ -136,6 +139,8 @@ public class MinionHelperOverlayHover {
private void formatItems(List<String> lines, Map<String, Integer> allItems) {
for (Map.Entry<String, Integer> entry : allItems.entrySet()) {
String internalName = entry.getKey();
+ if (internalName.equals("SKYBLOCK_PELT")) continue;
+
String name = manager.getRepo().getDisplayName(internalName);
int amount = entry.getValue();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/sources/NpcSource.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/sources/NpcSource.java
index 5acf5841..a11e8a38 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/sources/NpcSource.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/sources/NpcSource.java
@@ -26,7 +26,7 @@ public class NpcSource extends MinionSource {
private final String npcName;
// name -> amount
private final ArrayListMultimap<String, Integer> items;
- private int coins = 0;
+ private final int coins;
public NpcSource(String npcName, int coins, ArrayListMultimap<String, Integer> items) {
this.npcName = npcName;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java
index 6bcae3a7..79a1848a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/util/MinionHelperPriceCalculation.java
@@ -43,15 +43,15 @@ public class MinionHelperPriceCalculation {
private final Map<String, String> upgradeCostFormatCache = new HashMap<>();
private final Map<String, String> fullCostFormatCache = new HashMap<>();
//TODO maybe change logic with 0 coins later or stuff
- private final List<String> cheapItems = Arrays.asList(
- "WOOD_SWORD",
- "WOOD_HOE",
- "WOOD_AXE",
- "WOOD_PICKAXE",
- "WOOD_SPADE",
- "FISHING_ROD",
- "SKYBLOCK_PELT"
- );
+// private final List<String> cheapItems = Arrays.asList(
+// "WOOD_SWORD",
+// "WOOD_HOE",
+// "WOOD_AXE",
+// "WOOD_PICKAXE",
+// "WOOD_SPADE",
+// "FISHING_ROD",
+// "SKYBLOCK_PELT"
+// );
public MinionHelperPriceCalculation(MinionHelperManager manager) {
this.manager = manager;
@@ -124,6 +124,7 @@ public class MinionHelperPriceCalculation {
long upgradeCost = 0;
for (Map.Entry<String, Integer> entry : items.entries()) {
String internalName = entry.getKey();
+ if (internalName.equals("SKYBLOCK_PELT")) continue;
long price = getPrice(internalName);
int amount = entry.getValue();
upgradeCost += price * amount;
@@ -138,24 +139,37 @@ public class MinionHelperPriceCalculation {
}
public long getPrice(String internalName) {
+ //Is minion
+ if (internalName.contains("_GENERATOR_")) {
+ return calculateUpgradeCosts(manager.getMinionById(internalName), false);
+ }
+
+ //Is bazaar item
JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalName);
- if (bazaarInfo == null) {
- if (internalName.contains("_GENERATOR_")) {
- return calculateUpgradeCosts(manager.getMinionById(internalName), false);
- } else {
- if (!cheapItems.contains(internalName)) {
- return (long) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalName);
- }
+ if (bazaarInfo != null) {
+ if (!bazaarInfo.has("curr_sell")) {
+ System.err.println("curr_sell does not exist for '" + internalName + "'");
+ return 0;
}
- return 0;
+ return (long) bazaarInfo.get("curr_sell").getAsDouble();
}
- //TODO use average bazaar price?
- if (!bazaarInfo.has("curr_sell")) {
- System.err.println("curr_sell does not exist for '" + internalName + "'");
+ //Is cheap item
+// if (cheapItems.contains(internalName)) return 0;
+
+ //is ah bin
+ long avgBinPrice = (long) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalName);
+ if (avgBinPrice >= 1) return avgBinPrice;
+
+
+ //is ah without bin
+ JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalName);
+ if (auctionInfo == null) {
+ //only wood axe and similar useless items
return 0;
}
- return (long) bazaarInfo.get("curr_sell").getAsDouble();
+ return (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+
}
public String formatCoins(long coins) {