Browse Source

Improved getting max offer for resource

JoostSijm 3 years ago
parent
commit
d1c571ae5a
1 changed files with 23 additions and 37 deletions
  1. 23 37
      src/rival_regions_marketbot/marketbot.py

+ 23 - 37
src/rival_regions_marketbot/marketbot.py

@@ -6,6 +6,27 @@ from rival_regions_wrapper.wrapper import Storage
 
 from rival_regions_marketbot import RR_WRAPPER, PROFILE_ID, wrapper
 
+MARKET_MAX = {
+    "helium-3": 153600,
+    "liquid_oxygen": 38400000,
+    "oil": 614400000,
+    "ore": 614400000,
+    "uranium": 15360000,
+    "diamonds": 153600,
+    "rivalium": 614400,
+    "antirad": 76800,
+    "spacerockets": 3840,
+    "lss": 15360000,
+    "tanks": 4388571,
+    "aircrafts": 640000,
+    "missiles": 256000,
+    "bombers": 128000,
+    "battleships": 128000,
+    "laser_drones": 256000,
+    "moon_tanks": 12800,
+    "space_stations": 1280,
+}
+
 
 def sell(item, minimum_price):
     if minimum_price >= 500000000:
@@ -14,45 +35,10 @@ def sell(item, minimum_price):
     first_offer = market.first_offer(item)
     if first_offer["profile_id"] != PROFILE_ID:
         # op_markt = market.offer_by(item, PROFILE_ID)
-        totaal = Storage(RR_WRAPPER).info()[item]
+        # totaal = Storage(RR_WRAPPER).info()[item]
         # totaal = opslag + op_markt
+        totaal = min(Storage(RR_WRAPPER).info()[item], MARKET_MAX[item])
         price = max(minimum_price, (first_offer["price"] * 100 - 10) / 100)
-        if item == "helium-3":
-            totaal = min(totaal, 153600)
-        if item == "liquid_oxygen":
-            totaal = min(totaal, 38400000)
-        if item == "oil":
-            totaal = min(totaal, 614400000)
-        if item == "ore":
-            totaal = min(totaal, 614400000)
-        if item == "uranium":
-            totaal = min(totaal, 15360000)
-        if item == "diamonds":
-            totaal = min(totaal, 153600)
-        if item == "rivalium":
-            totaal = min(totaal, 614400)
-        if item == "antirad":
-            totaal = min(totaal, 76800)
-        if item == "spacerockets":
-            totaal = min(totaal, 3840)
-        if item == "lss":
-            totaal = min(totaal, 15360000)
-        if item == "tanks":
-            totaal = min(totaal, 4388571)
-        if item == "aircrafts":
-            totaal = min(totaal, 640000)
-        if item == "missiles":
-            totaal = min(totaal, 256000)
-        if item == "bombers":
-            totaal = min(totaal, 128000)
-        if item == "battleships":
-            totaal = min(totaal, 128000)
-        if item == "laser_drones":
-            totaal = min(totaal, 256000)
-        if item == "moon_tanks":
-            totaal = min(totaal, 12800)
-        if item == "space_stations":
-            totaal = min(totaal, 1280)
         # if totaal == op_markt and own_price == minimum_price:
         if totaal != 0:
             item = util.ITEM_KEYS[item]