|
@@ -85,7 +85,7 @@ def main() -> None:
|
|
|
|
|
|
|
|
warehouse = warehouse_inventory()
|
|
warehouse = warehouse_inventory()
|
|
|
total_cost = 0
|
|
total_cost = 0
|
|
|
- for planet in planets:
|
|
|
|
|
|
|
+ for i, planet in enumerate(planets):
|
|
|
print('\n' + cyan(planet.name))
|
|
print('\n' + cyan(planet.name))
|
|
|
supply_config = config.supply_config(planet.name)
|
|
supply_config = config.supply_config(planet.name)
|
|
|
for consumption in planet.net_consumption:
|
|
for consumption in planet.net_consumption:
|
|
@@ -98,11 +98,19 @@ def main() -> None:
|
|
|
if ticker in supply_config.ignore_materials:
|
|
if ticker in supply_config.ignore_materials:
|
|
|
print(f' | {need:5.0f} (ignored)')
|
|
print(f' | {need:5.0f} (ignored)')
|
|
|
else:
|
|
else:
|
|
|
|
|
+ print(f' | {need:5.0f}', end='')
|
|
|
|
|
+ sources = []
|
|
|
|
|
+ for exporter in planets[:i]:
|
|
|
|
|
+ if ticker in exporter.exporting and (avail := exporter.inventory.get(ticker, 0)):
|
|
|
|
|
+ need -= min(need, avail)
|
|
|
|
|
+ exporter.inventory[ticker] -= max(avail - need, 0)
|
|
|
|
|
+ sources.append(f'{exporter.name}: {avail}')
|
|
|
|
|
+ if avail := warehouse.get(ticker, 0):
|
|
|
|
|
+ need -= min(need, avail)
|
|
|
|
|
+ warehouse[ticker] -= max(avail - need, 0)
|
|
|
|
|
+ sources.append(f'WH: {avail}')
|
|
|
cost = raw_prices[ticker]['Ask'] * need
|
|
cost = raw_prices[ticker]['Ask'] * need
|
|
|
- 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)
|
|
|
|
|
|
|
+ print(f' (${cost:6.0f}) ' + ' '.join(sources))
|
|
|
total_cost += cost
|
|
total_cost += cost
|
|
|
else:
|
|
else:
|
|
|
print()
|
|
print()
|
|
@@ -189,10 +197,13 @@ class Planet:
|
|
|
name: str
|
|
name: str
|
|
|
inventory: dict[str, int]
|
|
inventory: dict[str, int]
|
|
|
net_consumption: typing.Sequence[Amount]
|
|
net_consumption: typing.Sequence[Amount]
|
|
|
|
|
+ exporting: typing.Set[str]
|
|
|
|
|
|
|
|
def __init__(self, fio_burn: FIOBurn) -> None:
|
|
def __init__(self, fio_burn: FIOBurn) -> None:
|
|
|
self.name = fio_burn['PlanetName'] or fio_burn['PlanetNaturalId']
|
|
self.name = fio_burn['PlanetName'] or fio_burn['PlanetNaturalId']
|
|
|
self.inventory = {item['MaterialTicker']: item['MaterialAmount'] for item in fio_burn['Inventory']}
|
|
self.inventory = {item['MaterialTicker']: item['MaterialAmount'] for item in fio_burn['Inventory']}
|
|
|
|
|
+
|
|
|
|
|
+ # producing any amount (including less than consumption)
|
|
|
producing = {item['MaterialTicker']: item for item in fio_burn['OrderProduction']}
|
|
producing = {item['MaterialTicker']: item for item in fio_burn['OrderProduction']}
|
|
|
self.net_consumption = []
|
|
self.net_consumption = []
|
|
|
for c in fio_burn['OrderConsumption'] + fio_burn['WorkforceConsumption']:
|
|
for c in fio_burn['OrderConsumption'] + fio_burn['WorkforceConsumption']:
|
|
@@ -204,6 +215,13 @@ class Planet:
|
|
|
c['net_consumption'] = net
|
|
c['net_consumption'] = net
|
|
|
self.net_consumption.append(c)
|
|
self.net_consumption.append(c)
|
|
|
|
|
|
|
|
|
|
+ consuming = {item['MaterialTicker'] for item in self.net_consumption}
|
|
|
|
|
+ # producing more than consumption
|
|
|
|
|
+ self.exporting = set()
|
|
|
|
|
+ for item in fio_burn['OrderProduction']:
|
|
|
|
|
+ if item['MaterialTicker'] not in consuming:
|
|
|
|
|
+ self.exporting.add(item['MaterialTicker'])
|
|
|
|
|
+
|
|
|
def supply_for_days(self, target_days: float) -> dict[str, int]:
|
|
def supply_for_days(self, target_days: float) -> dict[str, int]:
|
|
|
buy: dict[str, int] = {}
|
|
buy: dict[str, int] = {}
|
|
|
for consumption in self.net_consumption:
|
|
for consumption in self.net_consumption:
|