|
@@ -0,0 +1,33 @@
|
|
|
|
|
+from __future__ import annotations
|
|
|
|
|
+
|
|
|
|
|
+import collections
|
|
|
|
|
+import typing
|
|
|
|
|
+
|
|
|
|
|
+import cache
|
|
|
|
|
+from config import config
|
|
|
|
|
+import supply
|
|
|
|
|
+
|
|
|
|
|
+def main() -> None:
|
|
|
|
|
+ fio_burns: typing.Sequence[supply.FIOBurn] = cache.get('https://rest.fnar.net/fioweb/burn/user/' + config.username,
|
|
|
|
|
+ headers={'Authorization': config.fio_api_key})
|
|
|
|
|
+ planets = [supply.Planet(fio_burn) for fio_burn in fio_burns]
|
|
|
|
|
+
|
|
|
|
|
+ total_consumption: dict[str, float] = collections.defaultdict(float)
|
|
|
|
|
+ for planet in planets:
|
|
|
|
|
+ for mat, consumption in planet.net_consumption.items():
|
|
|
|
|
+ if consumption > 0:
|
|
|
|
|
+ total_consumption[mat] += consumption
|
|
|
|
|
+
|
|
|
|
|
+ supplies: list[tuple[float, str]] = []
|
|
|
|
|
+ for mat, amount in supply.warehouse_inventory().items():
|
|
|
|
|
+ if (consumption := total_consumption.get(mat)) is None:
|
|
|
|
|
+ supplies.append((float('inf'), mat))
|
|
|
|
|
+ else:
|
|
|
|
|
+ supplies.append((amount / consumption, mat))
|
|
|
|
|
+
|
|
|
|
|
+ supplies.sort(reverse=True)
|
|
|
|
|
+ for days, mat in supplies:
|
|
|
|
|
+ print(f'{mat}: {days:.2f} d')
|
|
|
|
|
+
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
|
+ main()
|