From f28c8f3b5ececd6a493a57c9d837a05a7b6dab7b Mon Sep 17 00:00:00 2001 From: Alain Bryden <2285037+alainbryden@users.noreply.github.com> Date: Fri, 1 Nov 2024 21:03:59 -0300 Subject: [PATCH] Fix #421 - Access shorts immediately in BN 8.1 --- helpers.js | 3 ++- stockmaster.js | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helpers.js b/helpers.js index 23c92208..a413895a 100644 --- a/helpers.js +++ b/helpers.js @@ -541,7 +541,8 @@ export async function getActiveSourceFiles_Custom(ns, fnGetNsDataThroughFile, in if (includeLevelsFromCurrentBitnode) { try { const currentNode = (await fnGetNsDataThroughFile(ns, 'ns.getResetInfo()', '/Temp/reset-info.txt', null, null, null, null, silent)).currentNode; - let effectiveSfLevel = currentNode == 4 ? 3 : 1; // In BN4, we get the perks of SF4.3 + // In some Bitnodes, we get the *effects* of source file level 3 just by being in the bitnode. + let effectiveSfLevel = [4, 8].includes(currentNode) ? 3 : 1; dictSourceFiles[currentNode] = Math.max(effectiveSfLevel, dictSourceFiles[currentNode] || 0); } catch { /* We are expected to be fault-tolerant in low-ram conditions */ } } diff --git a/stockmaster.js b/stockmaster.js index da3a5229..799f001b 100644 --- a/stockmaster.js +++ b/stockmaster.js @@ -10,7 +10,6 @@ let lastLog = ""; // We update faster than the stock-market ticks, but we don't let allStockSymbols = null; // Stores the set of all symbols collected at start let mock = false; // If set to true, will "mock" buy/sell but not actually buy/sell anythingorecast let noisy = false; // If set to true, tprints and announces each time stocks are bought/sold -let dictSourceFiles; // Populated at init, a dictionary of source-files the user has access to, and their level // Pre-4S configuration (influences how we play the stock market before we have 4S data, after which everything's fool-proof) let showMarketSummary = false; // If set to true, will always generate and display the pre-4s forecast table in a separate tail window let minTickHistory; // This much history must be gathered before we will offer a stock forecast. @@ -129,8 +128,8 @@ export async function main(ns) { } while (!success); } - dictSourceFiles = await getActiveSourceFiles(ns); // Find out what source files the user has unlocked - if (!disableShorts && (!(8 in dictSourceFiles) || dictSourceFiles[8] < 2)) { + const effectiveSourceFiles = await getActiveSourceFiles(ns, true); // Find out what source files the user has unlocked + if (!disableShorts && effectiveSourceFiles[8] < 2) { log(ns, "INFO: Shorting stocks has been disabled (you have not yet unlocked access to shorting)"); disableShorts = true; }