raylu 6 дней назад
Родитель
Сommit
5c223c7afb
2 измененных файлов с 31 добавлено и 4 удалено
  1. 28 0
      export_logistics.py
  2. 3 4
      supply.py

+ 28 - 0
export_logistics.py

@@ -0,0 +1,28 @@
+from __future__ import annotations
+
+import sys
+import typing
+
+import cache
+import supply
+
+def main() -> None:
+	(fio_burn,) = supply.get_fio_burn([sys.argv[1]])
+	planet = supply.Planet(fio_burn)
+
+	materials: typing.Mapping[str, supply.Material] = {mat['Ticker']: mat
+			for mat in cache.get('https://rest.fnar.net/material/allmaterials')}
+
+	total_weight = total_volume = 0.0
+	for mat in planet.exporting:
+		if amount := planet.inventory.get(mat):
+			weight = amount * materials[mat]['Weight']
+			volume = amount * materials[mat]['Volume']
+			print(f'{mat:3} {amount:5,} {weight:5.2f}t {volume:5.2f}m³')
+			total_weight += weight
+			total_volume += volume
+	
+	print(f'total {total_weight:.2f}t {total_volume:.2f}m³')
+
+if __name__ == '__main__':
+	main()

+ 3 - 4
supply.py

@@ -60,8 +60,7 @@ def main() -> None:
 		if weight_used > args.weight:
 			print(yellow('warning'), f'need additional {weight_used - args.weight:.1f}t to pick up exports at {planet.name}')
 		if volume_used > args.volume:
-			print(yellow('warning'), f'need additional {volume_used - args.volume:.1f}㎥ to pick up exports at {planet.name}')
-
+			print(yellow('warning'), f'need additional {volume_used - args.volume:.1f}m³ to pick up exports at {planet.name}')
 	print(cyan('\nload at CX:\n') + json.dumps({
 		'actions': [
 			{'name': 'BuyItems', 'type': 'CX Buy', 'group': 'A1', 'exchange': 'IC1',
@@ -112,7 +111,7 @@ def calculate_optimal(planets: typing.Sequence[Planet], materials: typing.Mappin
 			if days < target_days:
 				target_days = days
 
-		print(planet.name, f'consumes {vol_per_day:.1f}, {weight_per_day:.1f}t per day')
+		print(planet.name, f'consumes {vol_per_day:.1f}, {weight_per_day:.1f}t per day')
 
 	optimal: dict[str, dict[str, int]] = None # pyright: ignore[reportAssignmentType]
 	total_weight_used: float = None # pyright: ignore[reportAssignmentType]
@@ -137,7 +136,7 @@ def calculate_optimal(planets: typing.Sequence[Planet], materials: typing.Mappin
 			total_volume_used = iteration_volume
 		target_days += 0.1
 	print('supply for', round(target_days, 1), 'days,', end=' ')
-	print(f'consuming {round(total_weight_used, 1)}t and {round(total_volume_used, 1)}') # pyright: ignore[reportPossiblyUnboundVariable]
+	print(f'consuming {round(total_weight_used, 1)}t and {round(total_volume_used, 1)}') # pyright: ignore[reportPossiblyUnboundVariable]
 
 	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'}