2 Commits a3bf250558 ... 83b9426a2a

Auteur SHA1 Message Date
  raylu 83b9426a2a AEN VSC il y a 5 jours
  raylu 05a4ac084a junk finder il y a 1 semaine
3 fichiers modifiés avec 88 ajouts et 28 suppressions
  1. 0 28
      export_logistics.py
  2. 33 0
      junk.py
  3. 55 0
      www/vsc.html

+ 0 - 28
export_logistics.py

@@ -1,28 +0,0 @@
-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()

+ 33 - 0
junk.py

@@ -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()

+ 55 - 0
www/vsc.html

@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta charset="UTF-8">
+	<title>PrUn VSC</title>
+	<link rel="stylesheet" type="text/css" href="style.css">
+	<link rel="icon" href="https://www.raylu.net/hammer-man.svg" />
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<meta name="theme-color" content="#222">
+</head>
+<body>
+	<a href="/">← back</a>
+	<main class="production">
+		<form>
+			<label>PUNoted API key: <input type="password" size="30" id="api-key"></label>
+			<input type="button" value="fetch" id="fetch">
+		</form>
+		<section id="loader"></section>
+		<div id="aen"></div>
+	</main>
+	<div id="popover" popover="hint"></div>
+	<script type="module">
+		import {setupProduction} from './production.js';
+		const blueprint = {
+			'FFC': 1,
+			'AEN': 1,
+			'HYR': 1,
+			'MFE': 3,
+			'SFE': 1,
+			'LFL': 1,
+			'SSL': 1,
+			'VSC': 1,
+			'AGS': 1,
+			'LHP': 44,
+			'SSC': 41,
+			'BR2': 1,
+			'CQT': 1,
+		};
+		const buy = new Set([
+			// definitely buy
+			'AFP', 'AFR', 'EES', 'NV2',
+			'C', 'FLX', 'H', 'H2O', 'HAL', 'HCP', 'HE', 'LST', 'MG', 'N', 'NA', 'NCS', 'NS', 'O', 'PE', 'PG', 'S', 'TCL', 'THF',
+			// maybe buy
+			'CTF',
+			'AIR', 'AU', 'BE', 'BRM', 'BOR', 'BTS', 'CU', 'FAN', 'FC', 'FE', 'HCC', 'HD', 'LDI', 'LI', 'MFK', 'MWF',
+			'REA', 'RG', 'RGO', 'ROM', 'SFK', 'SI', 'STL', 'TCO', 'TPU',
+			// import
+			'AAR', 'AWF', 'CAP', 'CF', 'RAD',
+			// skip
+			'LFE', 'LHP', 'MFE', 'SFE', 'SSC', 'BGS', 'AGS',
+		])
+		setupProduction(blueprint, buy, 'IC1', 5, document.querySelector('#aen'));
+	</script>
+</body>
+</html>