|
|
@@ -83,6 +83,7 @@ def main() -> None:
|
|
|
raw_prices: typing.Mapping[str, market.RawPrice] = {p['MaterialTicker']: p
|
|
|
for p in cache.get('https://refined-prun.github.io/refined-prices/all.json') if p['ExchangeCode'] == 'IC1'}
|
|
|
|
|
|
+ warehouse = warehouse_inventory()
|
|
|
total_cost = 0
|
|
|
for planet in planets:
|
|
|
print('\n' + cyan(planet.name))
|
|
|
@@ -98,8 +99,11 @@ def main() -> None:
|
|
|
print(f' | {need:5.0f} (ignored)')
|
|
|
else:
|
|
|
cost = raw_prices[ticker]['Ask'] * need
|
|
|
- total_cost += cost
|
|
|
print(f' | {need:5.0f} (${cost:6.0f})')
|
|
|
+ if have := warehouse.get(ticker, 0):
|
|
|
+ cost = raw_prices[ticker]['Ask'] * max(need - have, 0)
|
|
|
+ warehouse[ticker] = max(have - need, 0)
|
|
|
+ total_cost += cost
|
|
|
else:
|
|
|
print()
|
|
|
print(f'\ntotal cost: {total_cost:,}')
|
|
|
@@ -157,6 +161,17 @@ def shipping_used(materials: dict[str, Material], ignore: typing.Collection[str]
|
|
|
volume += amount * materials[ticker]['Volume']
|
|
|
return weight, volume
|
|
|
|
|
|
+def warehouse_inventory() -> dict[str, int]:
|
|
|
+ warehouses: typing.Sequence[market.Warehouse] = cache.get('https://rest.fnar.net/sites/warehouses/' + config.username,
|
|
|
+ headers={'Authorization': config.fio_api_key})
|
|
|
+ for warehouse in warehouses:
|
|
|
+ if warehouse['LocationNaturalId'] == 'HRT':
|
|
|
+ storage: market.Storage = cache.get(f'https://rest.fnar.net/storage/{config.username}/{warehouse["StoreId"]}',
|
|
|
+ headers={'Authorization': config.fio_api_key})
|
|
|
+ assert storage['Type'] == 'WAREHOUSE_STORE'
|
|
|
+ return {item['MaterialTicker']: item['MaterialAmount'] for item in storage['StorageItems']}
|
|
|
+ raise Exception("couldn't find HRT warehouse")
|
|
|
+
|
|
|
def cyan(text: str) -> str:
|
|
|
return '\033[36m' + text + '\033[0m'
|
|
|
|