|
@@ -7,7 +7,7 @@ const BUY = new Set([
|
|
|
'AIR', 'AU', 'BE', 'BRM', 'BOR', 'BTS', 'CU', 'FAN', 'FC', 'FE', 'HCC', 'HD', 'LDI', 'LI', 'MFK', 'MWF',
|
|
'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',
|
|
'REA', 'RG', 'RGO', 'ROM', 'SFK', 'SI', 'STL', 'TCO', 'TPU',
|
|
|
// import
|
|
// import
|
|
|
- 'AAR', 'AWF', 'CAP', 'CF',
|
|
|
|
|
|
|
+ 'AAR', 'AWF', 'CAP', 'CF', 'RAD',
|
|
|
// skip
|
|
// skip
|
|
|
'LFE', 'LHP', 'MFE', 'SFE', 'SSC',
|
|
'LFE', 'LHP', 'MFE', 'SFE', 'SSC',
|
|
|
])
|
|
])
|
|
@@ -36,14 +36,16 @@ const shipbuilders = [
|
|
|
'TRUEnterprises',
|
|
'TRUEnterprises',
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
-render();
|
|
|
|
|
-
|
|
|
|
|
|
|
+const main = document.querySelector('main.shipbuilding')!;
|
|
|
|
|
+(async () => {
|
|
|
|
|
+ main.innerHTML = 'loading...';
|
|
|
|
|
+ try {
|
|
|
|
|
+ await render();
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ main.innerHTML = e instanceof Error ? e.message : String(e);
|
|
|
|
|
+ }
|
|
|
|
|
+})();
|
|
|
async function render() {
|
|
async function render() {
|
|
|
- const main = document.querySelector('main.shipbuilding');
|
|
|
|
|
- if (!main)
|
|
|
|
|
- throw new Error('missing shipbuilding container');
|
|
|
|
|
- main.innerHTML = '<p>Loading...</p>';
|
|
|
|
|
-
|
|
|
|
|
const [allPrices, recipes, buildingList, knownCompanies, companyProductionById] = await Promise.all([
|
|
const [allPrices, recipes, buildingList, knownCompanies, companyProductionById] = await Promise.all([
|
|
|
cachedFetchJSON('https://refined-prun.github.io/refined-prices/all.json') as Promise<RawPrice[]>,
|
|
cachedFetchJSON('https://refined-prun.github.io/refined-prices/all.json') as Promise<RawPrice[]>,
|
|
|
recipeForMats(),
|
|
recipeForMats(),
|
|
@@ -181,12 +183,12 @@ function analyzeMat(mat: string, amount: number, production: Production, extract
|
|
|
throw new Error(`missing price for ${mat}`);
|
|
throw new Error(`missing price for ${mat}`);
|
|
|
const traded = price.AverageTraded30D ?? 0;
|
|
const traded = price.AverageTraded30D ?? 0;
|
|
|
if (BUY.has(mat)) {
|
|
if (BUY.has(mat)) {
|
|
|
- if (price.Ask == null)
|
|
|
|
|
- throw new Error(`missing ask price for ${mat}`);
|
|
|
|
|
|
|
+ const matPrice = price.VWAP30D ?? price.Ask;
|
|
|
|
|
+ if (matPrice == null) throw new Error(`missing ask price for ${mat}`);
|
|
|
buy[mat] = (buy[mat] ?? 0) + amount;
|
|
buy[mat] = (buy[mat] ?? 0) + amount;
|
|
|
return {
|
|
return {
|
|
|
- cost: price.Ask * amount,
|
|
|
|
|
- node: { text: `${formatAmount(amount)}x${mat} buy: ${formatAmount(price.Ask)}, daily traded ${formatFixed(traded, 1)}`, children: [] },
|
|
|
|
|
|
|
+ cost: matPrice * amount,
|
|
|
|
|
+ node: { text: `${formatAmount(amount)}x${mat} buy: ${formatAmount(matPrice)}, daily traded ${formatFixed(traded, 1)}`, children: [] },
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|