Skip to content

Commit

Permalink
Fix #421 - Access shorts immediately in BN 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbryden committed Nov 2, 2024
1 parent c512046 commit f28c8f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ }
}
Expand Down
5 changes: 2 additions & 3 deletions stockmaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f28c8f3

Please sign in to comment.