raylu 1 săptămână în urmă
părinte
comite
8c4214824c
2 a modificat fișierele cu 64 adăugiri și 4 ștergeri
  1. 11 4
      ts/production.ts
  2. 53 0
      www/aen.html

+ 11 - 4
ts/production.ts

@@ -38,15 +38,13 @@ async function render() {
 }
 
 async function _render() {
-	const [allPrices, {recipes, extractables}, buildingList, buildingPlanets, storage] = await Promise.all([
-		cachedFetchJSON('https://refined-prun.github.io/refined-prices/all.json') as Promise<RawPrice[]>,
+	const [prices, {recipes, extractables}, buildingList, buildingPlanets, storage] = await Promise.all([
+		fetchPrices(),
 		recipeForMats(),
 		cachedFetchJSON('https://api.prunplanner.org/data/buildings/') as Promise<Building[]>,
 		fetchSites(),
 		fetchStorage(),
 	]);
-	const prices = Object.fromEntries(allPrices.filter((price) => price.ExchangeCode === cx)
-			.map((price) => [price.MaterialTicker, price]));
 	const buildings = Object.fromEntries(buildingList.map((b) => [b.building_ticker, b]));
 
 	const production: Production = {};
@@ -397,6 +395,15 @@ function renderProductionBuildingMat(expertise: string, mat: string, amount: num
 	return wrapper;
 }
 
+async function fetchPrices(): Promise<Record<string, RawPrice>> {
+	const allPrices: RawPrice[] = await cachedFetchJSON('https://refined-prun.github.io/refined-prices/all.json');
+	const prices = Object.fromEntries(allPrices.filter((price) => price.ExchangeCode === cx)
+			.map((price) => [price.MaterialTicker, price]));
+	if (prices['AFP'].Ask === null)
+		prices['AFP'] = {MaterialTicker: 'AFP', ExchangeCode: cx, Ask: 30000, AverageTraded30D: null, VWAP30D: 30000, Supply: 24};
+	return prices;
+}
+
 async function fetchSites(): Promise<Record<string, Set<string>>> {
 	if (!apiKey.value)
 		return {};

+ 53 - 0
www/aen.html

@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta charset="UTF-8">
+	<title>PrUn AEN</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,
+			'HPR': 1,
+			'LFE': 2,
+			'MFE': 2,
+			'SFE': 2,
+			'LCB': 1,
+			'LFL': 1,
+			'MSL': 1,
+			'LHP': 97,
+			'SSC': 134,
+			'BR2': 1,
+			'CQL': 1,
+		};
+		const buy = new Set([
+			// definitely buy
+			'AFP', 'FIR', 'C', 'FLX', 'H', 'H2O', 'HAL', 'HCP', 'HE', 'LST', 'MG', 'N', 'NA', 'NCS', 'NS', 'O', 'PE', 'PG', 'S', 'TCL', 'THF',
+			// maybe buy
+			'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',
+		])
+		setupProduction(blueprint, buy, 'IC1', 5, document.querySelector('#aen'));
+	</script>
+</body>
+</html>