فهرست منبع

supply: warn about space for exports

raylu 1 ماه پیش
والد
کامیت
995fd345ba
1فایلهای تغییر یافته به همراه19 افزوده شده و 0 حذف شده
  1. 19 0
      supply.py

+ 19 - 0
supply.py

@@ -43,6 +43,25 @@ def main() -> None:
 	materials = {mat['Ticker']: mat for mat in raw_materials}
 
 	optimal, from_cx = calculate_optimal(planets, materials, args.weight, args.volume)
+
+	weight_used = volume_used = 0
+	for mat, amount in from_cx.items():
+		weight_used += amount * materials[mat]['Weight']
+		volume_used += amount * materials[mat]['Volume']
+	for planet in planets:
+		unload = optimal[planet.name]
+		for mat, amount in unload.items():
+			weight_used -= amount * materials[mat]['Weight']
+			volume_used -= amount * materials[mat]['Volume']
+		for mat in planet.exporting:
+			amount = planet.inventory.get(mat, 0)
+			weight_used += amount * materials[mat]['Weight']
+			volume_used += amount * materials[mat]['Volume']
+		if weight_used > args.weight:
+			print(f'\033[33mwarning:\033[0m need additional {weight_used - args.weight:.1f}t to pick up exports at {planet.name}')
+		if volume_used > args.volume:
+			print(f'\033[33mwarning:\033[0m need additional {volume_used - args.volume:.1f}㎥ 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',