production.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. import {cachedFetchJSON} from './cache';
  2. import {setupPopover} from './popover';
  3. let blueprint: Record<string, number>;
  4. let BUY: Set<string>;
  5. let renderTarget: Element;
  6. let cx: string;
  7. let daysPerBundle: number;
  8. const apiKey = document.querySelector('#api-key') as HTMLInputElement;
  9. export function setupProduction(bp: Record<string, number>, buy: Set<string>, cxCode: string, days: number, target: Element) {
  10. blueprint = bp;
  11. BUY = buy;
  12. cx = cxCode;
  13. daysPerBundle = days;
  14. renderTarget = target;
  15. const storedApiKey = localStorage.getItem('punoted-api-key');
  16. if (storedApiKey)
  17. apiKey.value = storedApiKey;
  18. document.querySelector('#fetch')!.addEventListener('click', render);
  19. setupPopover();
  20. render();
  21. }
  22. async function render() {
  23. const loader = document.querySelector('#loader') as HTMLElement;
  24. loader.style.display = 'block';
  25. try {
  26. await _render();
  27. if (apiKey.value)
  28. localStorage.setItem('punoted-api-key', apiKey.value);
  29. } catch (e) {
  30. renderTarget.innerHTML = e instanceof Error ? e.message : String(e);
  31. }
  32. loader.style.display = 'none';
  33. }
  34. async function _render() {
  35. const [prices, {recipes, extractables}, buildingList, buildingPlanets, storage] = await Promise.all([
  36. fetchPrices(),
  37. recipeForMats(),
  38. cachedFetchJSON('https://api.prunplanner.org/data/buildings/') as Promise<Building[]>,
  39. fetchSites(),
  40. fetchStorage(),
  41. ]);
  42. const buildings = Object.fromEntries(buildingList.map((b) => [b.building_ticker, b]));
  43. const production: Production = {};
  44. const extract: Record<string, number> = {};
  45. const buy: Record<string, number> = {};
  46. const analysisNodes: AnalysisNode[] = [];
  47. let cost = 0;
  48. for (const [mat, amount] of Object.entries(blueprint)) {
  49. const node = analyzeMat(mat, amount, production, extract, buy, prices, recipes, extractables, storage.allItems);
  50. cost += node.cost;
  51. analysisNodes.push(node);
  52. }
  53. // requiredMats = buy + production
  54. const requiredMats: Record<string, number> = {...buy};
  55. for (const buildingProduction of Object.values(production))
  56. for (const [mat, amount] of Object.entries(buildingProduction))
  57. requiredMats[mat] = (requiredMats[mat] ?? 0) + amount;
  58. const expertiseGroups: Record<string, string[]> = {};
  59. for (const building of buildingList) {
  60. if (!(building.building_ticker in production))
  61. continue;
  62. if (!expertiseGroups[building.expertise])
  63. expertiseGroups[building.expertise] = [];
  64. expertiseGroups[building.expertise].push(building.building_ticker);
  65. }
  66. renderTarget.innerHTML = '';
  67. renderTarget.append(
  68. renderAnalysis(analysisNodes),
  69. element('p', {textContent: `total cost: ${formatWhole(cost)}`}),
  70. renderProduction(expertiseGroups, production, buildingPlanets, storage, prices, recipes, buildings),
  71. renderMatList('extract', extract, storage.allItems),
  72. renderMatList('buy', buy, storage.allItems),
  73. );
  74. }
  75. function renderMatList(header: string, mats: Record<string, number>, storage: Record<string, number>): HTMLElement {
  76. const section = element('section');
  77. section.append(element('h2', {textContent: header}));
  78. const matsSorted = Object.entries(mats).sort(([a], [b]) => a.localeCompare(b));
  79. for (const [mat, amount] of matsSorted) {
  80. const div = element('div', {textContent: `${formatAmount(amount)}x${mat}`});
  81. const storageText = element('span', {textContent: ` (${formatAmount(storage[mat] ?? 0)})`});
  82. const percent = Math.min((storage[mat] ?? 0) / (amount * 2), 1);
  83. storageText.style.color = `color-mix(in xyz, #0aa ${percent * 100}%, #f80 )`;
  84. div.append(storageText);
  85. section.append(div);
  86. }
  87. return section;
  88. }
  89. async function recipeForMats(): Promise<{recipes: Record<string, Recipe>, extractables: Set<string>}> {
  90. const [allRecipes, materials]: [Recipe[], Material[]] = await Promise.all([
  91. cachedFetchJSON('https://api.prunplanner.org/data/recipes/'),
  92. cachedFetchJSON('https://api.prunplanner.org/data/materials/'),
  93. ]);
  94. const extractables = new Set(materials.filter(
  95. (m) => ['ores', 'minerals', 'liquids', 'gases'].includes(m.category_name)).map((m) => m.ticker));
  96. const chosenRecipes: Record<string, string> = {
  97. 'AL': '6xALO 1xO 1xC 1xFLX=>4xAL',
  98. 'C': '4xHCP=>4xC',
  99. 'DRF': '50xNFI 1xDCS=>1xDRF',
  100. 'DW': '10xH2O 1xPG=>10xDW',
  101. 'FE': '6xFEO 1xC 1xO 1xFLX=>4xFE',
  102. 'GL': '2xSIO 1xNA 1xSEN=>10xGL',
  103. 'GRA': '30xH2O 1xDDT 3xSOI=>6xGRA',
  104. 'HCB': '600xWAL 100xMFK=>1xHCB',
  105. 'HCP': '14xH2O 1xNS=>8xHCP',
  106. 'LCB': '200xAST 20xMFK=>1xLCB',
  107. 'MCB': '100xAST 16xMFK=>1xMCB',
  108. 'RE': '8xREO 1xC 1xO 1xFLX=>5xRE',
  109. 'RG': '10xGL 15xPG 1xSEN=>10xRG',
  110. 'SCB': '50xFAL 12xMFK=>1xSCB',
  111. 'SI': '3xSIO 1xC 1xO 1xFLX=>1xSI',
  112. 'TA': '2xTAI 4xNA=>1xTA 1xFE',
  113. 'TCB': '20xFE 4xMFK=>1xTCB',
  114. 'TI': '4xTIO 1xC 1xO 1xNA=>2xTI',
  115. 'VCB': '200xFET 20xMFK=>1xVCB',
  116. 'VSC': '35xFE 8xMFK=>1xVSC',
  117. 'WCB': '100xAST 100xFET 20xMFK=>1xWCB',
  118. 'ZR': '2xZIR 4xNA=>1xZR 2xSIO',
  119. }
  120. const matRecipes: Record<string, Recipe[]> = {}; // all ways to make a mat
  121. for (const recipe of allRecipes)
  122. for (const output of recipe.outputs) {
  123. if (extractables.has(output.material_ticker))
  124. continue;
  125. if (chosenRecipes[output.material_ticker] && recipe.recipe_name != chosenRecipes[output.material_ticker])
  126. continue;
  127. const recipes = matRecipes[output.material_ticker];
  128. if (recipes)
  129. recipes.push(recipe);
  130. else
  131. matRecipes[output.material_ticker] = [recipe];
  132. }
  133. const matRecipe: Record<string, Recipe> = {};
  134. for (const [mat, recipes] of Object.entries(matRecipes))
  135. if (recipes.length === 1)
  136. matRecipe[mat] = recipes[0];
  137. return {recipes: matRecipe, extractables};
  138. }
  139. function analyzeMat(mat: string, amount: number, production: Production, extract: Record<string, number>, buy: Record<string, number>,
  140. prices: Record<string, RawPrice>, recipes: Record<string, Recipe>, extractables: Set<string>, storage: Record<string, number>): AnalysisNode {
  141. const price = prices[mat];
  142. if (!price)
  143. throw new Error(`missing price for ${mat}`);
  144. const traded = price.AverageTraded30D ?? 0;
  145. const inStorage = storage[mat] ?? 0;
  146. if (BUY.has(mat)) {
  147. const matPrice = price.VWAP30D ?? price.Ask;
  148. if (matPrice == null) throw new Error(`missing ask price for ${mat}`);
  149. buy[mat] = (buy[mat] ?? 0) + amount;
  150. return {
  151. ticker: mat,
  152. amount,
  153. inStorage,
  154. acquisition: `buy: ${formatAmount(matPrice)}, daily traded ${formatFixed(traded, 1)}`,
  155. children: [],
  156. cost: matPrice * amount,
  157. };
  158. }
  159. if (extractables.has(mat)) {
  160. extract[mat] = (extract[mat] ?? 0) + amount;
  161. return {ticker: mat, amount, inStorage, acquisition: `extract`, children: [], cost: 0};
  162. }
  163. const recipe = recipes[mat];
  164. if (!recipe)
  165. throw new Error(`no recipe for ${mat}`);
  166. const building = recipe.building_ticker;
  167. if (!production[building])
  168. production[building] = {};
  169. production[building][mat] = (production[building][mat] ?? 0) + amount;
  170. const liquid = traded > amount * 2 ? 'liquid' : 'not liquid';
  171. let totalCost = 0;
  172. const children: AnalysisNode[] = [];
  173. for (const inputMat of recipe.inputs) {
  174. const inputAmount = inputMat.material_amount * amount / recipe.outputs[0].material_amount;
  175. const node = analyzeMat(inputMat.material_ticker, inputAmount, production, extract, buy, prices, recipes, extractables, storage);
  176. totalCost += node.cost;
  177. children.push(node);
  178. }
  179. return {
  180. ticker: mat,
  181. amount,
  182. inStorage,
  183. acquisition: `make (${building}, ${liquid})`,
  184. children,
  185. cost: totalCost,
  186. };
  187. }
  188. function renderAnalysis(nodes: AnalysisNode[]): HTMLElement {
  189. const section = element('section');
  190. for (const node of nodes)
  191. section.append(renderAnalysisNode(node));
  192. return section;
  193. }
  194. function renderAnalysisNode(node: AnalysisNode, level = 0): HTMLElement {
  195. const amountText = element('span', {textContent: `${formatAmount(node.amount)}x${node.ticker} `});
  196. const storageText = element('span', {textContent: `(${formatAmount(node.inStorage)})`});
  197. const percent = Math.min(node.inStorage / node.amount, 1);
  198. storageText.style.color = `color-mix(in xyz, #0aa ${percent * 100}%, #f80)`;
  199. const acquisitionText = element('span', {textContent: ' ' + node.acquisition});
  200. let el;
  201. if (node.children.length === 0) {
  202. el = element('div', {className: 'analysis-node'});
  203. el.append(amountText, storageText, acquisitionText);
  204. } else {
  205. el = element('details', {className: 'analysis-node', open: level > 0 && percent < 1});
  206. const summary = element('summary');
  207. summary.append(amountText, storageText, acquisitionText);
  208. el.append(summary);
  209. for (const child of node.children)
  210. el.append(renderAnalysisNode(child, level + 1));
  211. el.append(document.createTextNode(`total cost: ${formatWhole(node.cost)}`));
  212. }
  213. if (level === 0)
  214. el.classList.add('root');
  215. return el;
  216. }
  217. const WORKER_CONSUMPTION: Record<'pioneers' | 'settlers' | 'technicians' | 'engineers' | 'scientists', Record<string, number>> = {
  218. pioneers: {'COF': 0.5, 'DW': 4, 'RAT': 4, 'OVE': 0.5, 'PWO': 0.2},
  219. settlers: {'DW': 5, 'RAT': 6, 'KOM': 1, 'EXO': 0.5, 'REP': 0.2, 'PT': 0.5},
  220. technicians: {'DW': 7.5, 'RAT': 7, 'ALE': 1, 'MED': 0.5, 'SC': 0.1, 'HMS': 0.5, 'SCN': 0.1},
  221. engineers: {'DW': 10, 'MED': 0.5, 'GIN': 1, 'FIM': 7, 'VG': 0.2, 'HSS': 0.2, 'PDA': 0.1},
  222. scientists: {'DW': 10, 'MED': 0.5, 'WIN': 1, 'MEA': 7, 'NST': 0.1, 'LC': 0.2, 'WS': 0.05},
  223. };
  224. function buildingDailyCost(building: Building, prices: Record<string, RawPrice>): number {
  225. let cost = 0;
  226. for (const [workerType, mats] of Object.entries(WORKER_CONSUMPTION)) {
  227. const workers = building[workerType as keyof typeof WORKER_CONSUMPTION];
  228. for (const [mat, per100] of Object.entries(mats)) {
  229. const price = prices[mat].VWAP30D;
  230. if (price == null) throw new Error(`no price for ${mat}`);
  231. cost += price * workers * per100 / 100;
  232. }
  233. }
  234. return cost;
  235. }
  236. function renderProduction(expertiseGroups: Record<string, string[]>, production: Production,
  237. buildingPlanets: Record<string, Set<string>>, storage: Storage, prices: Record<string, RawPrice>,
  238. recipes: Record<string, Recipe>, buildings: Record<string, Building>): HTMLElement {
  239. const section = element('section');
  240. section.append(element('h2', {textContent: 'production'}));
  241. const matInputs: Record<string, {upstreamMat: string, amount: number}[]> = {};
  242. // mat → list of {outputMat, expertise, amount} that consume it as an input
  243. const matConsumers: Record<string, {downstreamMat: string, expertise: string, amount: number}[]> = {};
  244. for (const [expertise, productionBuildings] of Object.entries(expertiseGroups)) {
  245. for (const building of productionBuildings) {
  246. for (const [mat, totalAmount] of Object.entries(production[building])) {
  247. const recipe = recipes[mat];
  248. if (!matInputs[mat])
  249. matInputs[mat] = [];
  250. const outputPerRun = recipe.outputs.find((o) => o.material_ticker === mat)!.material_amount;
  251. for (const input of recipe.inputs) {
  252. const ticker = input.material_ticker;
  253. const amount = input.material_amount * totalAmount / outputPerRun;
  254. matInputs[mat].push({upstreamMat: ticker, amount});
  255. if (!matConsumers[ticker])
  256. matConsumers[ticker] = [];
  257. matConsumers[ticker].push({downstreamMat: mat, expertise, amount});
  258. }
  259. }
  260. }
  261. }
  262. let totalConsumablesCost = 0;
  263. for (const [expertise, productionBuildings] of Object.entries(expertiseGroups)) {
  264. section.append(element('h3', {textContent: expertise.toLocaleLowerCase()}));
  265. const imports: Record<string, number> = {};
  266. const exportTo: Record<string, Record<string, number>> = {};
  267. const planets = new Set<string>();
  268. for (const building of productionBuildings) {
  269. const buildingRow = element('div', {className: 'building-row'});
  270. const mats = Object.entries(production[building]);
  271. let buildingMins = 0;
  272. for (const [mat, amount] of mats) {
  273. buildingRow.append(document.createTextNode(' '));
  274. buildingRow.append(renderProductionBuildingMat(expertise, mat, amount, storage,
  275. matInputs, matConsumers, imports, exportTo));
  276. const recipe = recipes[mat];
  277. const outputPerRun = recipe.outputs.find((o) => o.material_ticker === mat)!.material_amount;
  278. buildingMins += amount / outputPerRun * (recipe.time_ms / 1000 / 60);
  279. }
  280. const numBuildings = buildingMins / (24*60) / daysPerBundle / 1.605; // 160.5% efficiency
  281. const consumablesCost = buildingDailyCost(buildings[building], prices) * Math.round(Math.max(1, numBuildings));
  282. totalConsumablesCost += consumablesCost;
  283. buildingRow.prepend(document.createTextNode(
  284. `${formatFixed(numBuildings, 1)}x${building} (${formatWhole(consumablesCost)}/d)`));
  285. section.append(buildingRow);
  286. for (const planet of buildingPlanets[building] ?? [])
  287. planets.add(planet);
  288. }
  289. const importDetails = element('details');
  290. importDetails.append(element('summary', {textContent: 'imports'}));
  291. for (const [mat, amount] of Object.entries(imports)) {
  292. if (recipes[mat] && buildings[recipes[mat].building_ticker].expertise == expertise)
  293. continue;
  294. let onSite = 0;
  295. for (const planet of planets)
  296. onSite += storage.planetItems[planet][mat] ?? 0;
  297. const offSite = (storage.allItems[mat] ?? 0) - onSite;
  298. const importDetail = element('div', {
  299. textContent: `${formatAmount(amount)}x${mat} (${formatAmount(onSite)} on-site, ${formatAmount(offSite)} off-site)`});
  300. if (onSite >= amount * 2)
  301. importDetail.style.color = '#777';
  302. else {
  303. const shouldBring = amount - onSite;
  304. if (shouldBring > 0)
  305. importDetail.style.color = `color-mix(in xyz, #0aa ${Math.min(offSite / shouldBring, 1) * 100}%, #f80)`;
  306. }
  307. importDetails.append(importDetail);
  308. }
  309. section.append(importDetails);
  310. const exportDetails = element('details');
  311. exportDetails.append(element('summary', {textContent: 'exports'}));
  312. for (const [expertise, mats] of Object.entries(exportTo)) {
  313. const exportToRow = element('div', {textContent: expertise.toLocaleLowerCase() + ': '});
  314. exportToRow.textContent += Object.entries(mats).map(([mat, amount]) => `${amount}x${mat}`).join(' ');
  315. exportDetails.append(exportToRow);
  316. }
  317. section.append(exportDetails);
  318. }
  319. section.append(element('h4', {textContent: `total consumables cost: ${formatWhole(totalConsumablesCost)}/day,
  320. ${formatWhole(totalConsumablesCost * daysPerBundle)}/bundle`}));
  321. return section;
  322. }
  323. function renderProductionBuildingMat(expertise: string, mat: string, amount: number, storage: Storage,
  324. matInputs: Record<string, {upstreamMat: string, amount: number}[]>,
  325. matConsumers: Record<string, {downstreamMat: string, expertise: string, amount: number}[]>,
  326. imports: Record<string, number>, exportTo: Record<string, Record<string, number>>): HTMLElement {
  327. const inStorage = storage.allItems[mat] ?? 0;
  328. const wrapper = element('span');
  329. const amountText = element('span', {textContent: `${formatAmount(amount)}x${mat}`});
  330. wrapper.append(amountText);
  331. const storageText = element('span', {textContent: ` (${formatAmount(inStorage)})`});
  332. wrapper.append(storageText);
  333. const percent = Math.min(inStorage / (amount * 2), 1);
  334. storageText.style.color = `color-mix(in xyz, #0aa ${percent * 100}%, #f80)`;
  335. if (percent >= 1)
  336. amountText.style.color = '#777';
  337. else {
  338. const produceable = Object.values(matInputs[mat]).every((input) => storage.allItems[input.upstreamMat] ?? 0 >= input.amount);
  339. amountText.style.color = produceable ? '#0aa' : '#f80';
  340. }
  341. let tooltip = '';
  342. const inputs = matInputs[mat];
  343. if (inputs) {
  344. tooltip += inputs.map((i) => `${formatAmount(i.amount)}x${i.upstreamMat} (${storage.allItems[i.upstreamMat] ?? 0}) → ` +
  345. `${formatAmount(amount)}x${mat}`).join('\n') + '\n';
  346. for (const input of inputs)
  347. imports[input.upstreamMat] = (imports[input.upstreamMat] ?? 0) + input.amount;
  348. }
  349. const consumers = matConsumers[mat];
  350. if (consumers) {
  351. tooltip += consumers
  352. .map((c) => `${formatAmount(c.amount)}x${mat} → ${c.downstreamMat} (${c.expertise.toLocaleLowerCase()})`)
  353. .join('\n');
  354. for (const consumer of consumers) {
  355. if (consumer.expertise == expertise) // we aren't shipping it anywhere
  356. continue;
  357. if (!exportTo[consumer.expertise])
  358. exportTo[consumer.expertise] = {};
  359. exportTo[consumer.expertise][mat] = (exportTo[consumer.expertise][mat] ?? 0) + consumer.amount;
  360. }
  361. }
  362. amountText.dataset.tooltip = tooltip;
  363. return wrapper;
  364. }
  365. async function fetchPrices(): Promise<Record<string, RawPrice>> {
  366. const allPrices: RawPrice[] = await cachedFetchJSON('https://refined-prun.github.io/refined-prices/all.json');
  367. const prices = Object.fromEntries(allPrices.filter((price) => price.ExchangeCode === cx)
  368. .map((price) => [price.MaterialTicker, price]));
  369. if (prices['AFP'].Ask === null)
  370. prices['AFP'] = {MaterialTicker: 'AFP', ExchangeCode: cx, Ask: 30000, AverageTraded30D: null, VWAP30D: 30000, Supply: 24};
  371. return prices;
  372. }
  373. async function fetchSites(): Promise<Record<string, Set<string>>> {
  374. if (!apiKey.value)
  375. return {};
  376. const userSites: PUNUserSite[] = await fetch('https://api.punoted.net/v1/sites/?include_buildings=true',
  377. {headers: {'X-Data-Token': apiKey.value}}).then((r) => r.json());
  378. const buildingPlanets: Record<string, Set<string>> = {};
  379. for (const user of userSites)
  380. for (const site of user.Sites)
  381. for (const building of site.Buildings) {
  382. if (!buildingPlanets[building.BuildingTicker])
  383. buildingPlanets[building.BuildingTicker] = new Set();
  384. buildingPlanets[building.BuildingTicker].add(site.PlanetName);
  385. }
  386. return buildingPlanets;
  387. }
  388. async function fetchStorage(): Promise<Storage> {
  389. if (!apiKey.value)
  390. return {allItems: {}, planetItems: {}};
  391. const userStores: PUNUserStore[] = await fetch('https://api.punoted.net/v1/storages/',
  392. {headers: {'X-Data-Token': apiKey.value}}).then((r) => r.json());
  393. const allItems: Record<string, number> = {};
  394. const planetItems: Record<string, Record<string, number>> = {};
  395. for (const user of userStores)
  396. for (const storage of user.Storages)
  397. for (const item of storage.StorageItems) {
  398. allItems[item.MaterialTicker] = (allItems[item.MaterialTicker] ?? 0) + item.MaterialAmount;
  399. const planetStorage = planetItems[storage.Location] ??= {};
  400. planetStorage[item.MaterialTicker] = (planetStorage[item.MaterialTicker] ?? 0) + item.MaterialAmount;
  401. }
  402. return {allItems, planetItems};
  403. }
  404. function element<K extends keyof HTMLElementTagNameMap>(tagName: K,
  405. properties: Partial<HTMLElementTagNameMap[K]> = {}): HTMLElementTagNameMap[K] {
  406. const node = document.createElement(tagName);
  407. Object.assign(node, properties);
  408. return node;
  409. }
  410. function formatAmount(n: number): string {
  411. return n.toLocaleString(undefined, {maximumFractionDigits: 3});
  412. }
  413. function formatFixed(n: number, digits: number): string {
  414. return n.toLocaleString(undefined, {
  415. minimumFractionDigits: digits,
  416. maximumFractionDigits: digits,
  417. });
  418. }
  419. function formatWhole(n: number): string {
  420. return n.toLocaleString(undefined, {maximumFractionDigits: 0});
  421. }
  422. interface AnalysisNode {
  423. ticker: string
  424. amount: number
  425. inStorage: number
  426. acquisition: string
  427. children: AnalysisNode[]
  428. cost: number
  429. }
  430. interface Recipe {
  431. recipe_name: string
  432. building_ticker: string
  433. inputs: RecipeMat[]
  434. outputs: RecipeMat[]
  435. time_ms: number
  436. }
  437. interface RecipeMat {
  438. material_ticker: string
  439. material_amount: number
  440. }
  441. interface Material {
  442. ticker: string
  443. category_name: string
  444. }
  445. interface RawPrice {
  446. MaterialTicker: string
  447. ExchangeCode: string
  448. Ask: number | null
  449. AverageTraded30D: number | null
  450. VWAP30D: number | null
  451. Supply: number
  452. }
  453. interface Building {
  454. building_ticker: string
  455. expertise: string
  456. pioneers: number
  457. settlers: number
  458. technicians: number
  459. engineers: number
  460. scientists: number
  461. }
  462. interface PUNUserStore {
  463. Storages: Array<{
  464. Location: string
  465. StorageItems: Array<{
  466. MaterialTicker: string
  467. MaterialAmount: number
  468. }>
  469. }>
  470. }
  471. interface PUNUserSite {
  472. Sites: Array<{
  473. PlanetName: string
  474. Buildings: Array<{BuildingTicker: string}>
  475. }>
  476. }
  477. type Production = Record<string, Record<string, number>>;
  478. type Storage = {allItems: Record<string, number>, planetItems: Record<string, Record<string, number>>};