Skip to content

Commit

Permalink
Merge pull request #363 from trcjr/trailing_whitespace_cleanup
Browse files Browse the repository at this point in the history
remove trailing whitespace
  • Loading branch information
alainbryden authored Oct 5, 2024
2 parents d0d0063 + 21e71e6 commit 69fd985
Show file tree
Hide file tree
Showing 31 changed files with 136 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Remote/grow-target.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* Wait until an appointed time and then execute a grow. */
export async function main(ns) {
//args[0: target, 1: desired start time, 2: expected end, 3: expected duration, 4: description, 5: manipulate stock, 6: loop]
Expand Down
2 changes: 1 addition & 1 deletion Remote/hack-target.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* Wait until an appointed time and then execute a hack. */
export async function main(ns) {
//args[0: target, 1: desired start time, 2: expected end, 3: expected duration, 4: description, 5: manipulate stock, 6: disable toast warnings, 7: loop]
Expand Down
2 changes: 1 addition & 1 deletion Remote/manualhack-target.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* Wait until an appointed time and then execute a manual hack. */
export async function main(ns) {
//args[0: target, 1: desired start time, 2: expected end, 3: expected duration, 4: description, 5: manipulate stock (N/A ignored), 6: disable toast warnings, 7: loop]
Expand Down
2 changes: 1 addition & 1 deletion Remote/weak-target.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* Wait until an appointed time and then execute a weaken. */
export async function main(ns) {
//args[0: target, 1: desired start time, 2: expected end, 3: expected duration, 4: description, 5: disable toast warnings, 6: loop]
Expand Down
2 changes: 1 addition & 1 deletion Tasks/backdoor-all-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getNsDataThroughFile, getFilePath, log } from '../helpers.js'

const spawnDelay = 50; // Delay to allow time for `installBackdoor` to start running before a background script connects back to 'home'

/** @param {NS} ns
/** @param {NS} ns
* Scan all servers, backdoor anything that can be backdoored, and leave a file to indicate it's been done
* Requires: SF-4.1 **/
export let main = async ns => {
Expand Down
10 changes: 5 additions & 5 deletions Tasks/contractor.js.solver.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ const codingContractTypesMetadata = [{
{
name: 'Shortest Path in a Grid',
solver: function (data) {
//slightly adapted and simplified to get rid of MinHeap usage, and construct a valid path from potential candidates
//MinHeap replaced by simple array acting as queue (breadth first search)
//slightly adapted and simplified to get rid of MinHeap usage, and construct a valid path from potential candidates
//MinHeap replaced by simple array acting as queue (breadth first search)
const width = data[0].length;
const height = data.length;
const dstY = height - 1;
Expand Down Expand Up @@ -464,7 +464,7 @@ const codingContractTypesMetadata = [{
// }

//Simplified version. d < distance[yN][xN] should never happen for BFS if d != infinity, so we skip changeweight and simplify implementation
//algo always expands shortest path, distance != infinity means a <= lenght path reaches it, only remaining case to solve is infinity
//algo always expands shortest path, distance != infinity means a <= lenght path reaches it, only remaining case to solve is infinity
queue.push([0, 0]);
while (queue.length > 0) {
const [y, x] = queue.shift()
Expand Down Expand Up @@ -641,9 +641,9 @@ const codingContractTypesMetadata = [{
}
build.unshift(overallParity); // now we need the "overall" parity back in it's place
// try fix the actual encoded binary string if there is an error
if (fixIndex > 0 && testArray[0] == false) { // if the overall is false and the sum of calculated values is greater equal 0, fix the corresponding hamming-bit
if (fixIndex > 0 && testArray[0] == false) { // if the overall is false and the sum of calculated values is greater equal 0, fix the corresponding hamming-bit
build[fixIndex] = build[fixIndex] == "0" ? "1" : "0";
} else if (testArray[0] == false) { // otherwise, if the the overallparity is the only wrong, fix that one
} else if (testArray[0] == false) { // otherwise, if the the overallparity is the only wrong, fix that one
overallParity = overallParity == "0" ? "1" : "0";
} else if (testArray[0] == true && testArray.some((truth) => truth == false)) {
return 0; // ERROR: There's some strange going on... 2 bits are altered? How? This should not happen
Expand Down
2 changes: 1 addition & 1 deletion Tasks/crack-host.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* Blindly try to open all ports and crack the specified target, regardless of owned tools. */
export async function main(ns) {
const target = ns.args[0];
Expand Down
2 changes: 1 addition & 1 deletion Tasks/program-manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* the purpose of the program-manager is to buy all the programs
* from the darkweb we can afford so we don't have to do it manually
* or write them ourselves. Like tor-manager, this script dies a natural death
Expand Down
2 changes: 1 addition & 1 deletion Tasks/tor-manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @param {NS} ns
/** @param {NS} ns
* the purpose of tor-manager is to buy the TOR router ASAP
* so that another script can buy the port breakers. This script
* dies a natural death once tor is bought. **/
Expand Down
4 changes: 2 additions & 2 deletions ascend.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const argsSchema = [
// Spawn this script after installing augmentations (Note: Args not supported by the game)
['on-reset-script', null], // By default, will start with `stanek.js` if you have stanek's gift, otherwise `daemon.js`.
['ticks-to-wait-for-additional-purchases', 10], // Don't reset until we've gone this many game ticks without any new purchases being made (10 * 200ms (game tick time) ~= 2 seconds)
['max-wait-time', 60000], // The maximum number of milliseconds we'll wait for external scripts to purchase whatever permanent upgrades they can before we ascend anyway.
['max-wait-time', 60000], // The maximum number of milliseconds we'll wait for external scripts to purchase whatever permanent upgrades they can before we ascend anyway.
['prioritize-home-ram', false], // If set to true, will spend as much money as possible on upgrading home RAM before buying augmentations
/* Deprecated */['prioritize-augmentations', true], // (Legacy flag, now ignored - left for backwards compatibility)
];
Expand All @@ -25,7 +25,7 @@ export function autocomplete(data, args) {
return [];
}

/** @param {NS} ns
/** @param {NS} ns
* This script is meant to do all the things best done when ascending (in a generally ideal order) **/
export async function main(ns) {
const options = getConfiguration(ns, argsSchema);
Expand Down
28 changes: 14 additions & 14 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function startUp(ns) {
log(ns, `WARNING: This script requires SF4 (singularity) functions to assess purchasable augmentations ascend automatically. ` +
`Some functionality will be disabled and you'll have to manage working for factions, purchasing, and installing augmentations yourself.`, true);
} catch (err) {
if (unlockedSFs[4] || 0 == 3) throw err; // No idea why this failed, treat as temporary and allow auto-retry.
if (unlockedSFs[4] || 0 == 3) throw err; // No idea why this failed, treat as temporary and allow auto-retry.
log(ns, `WARNING: You only have SF4 level ${unlockedSFs[4]}. Without level 3, some singularity functions will be ` +
`too expensive to run until you have bought a lot of home RAM.`, true);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ async function checkOnDaedalusStatus(ns, player, stocksValue) {
}

/** Logic run periodically throughout the BN to see if we are ready to complete it.
* @param {NS} ns
* @param {NS} ns
* @param {Player} player */
async function checkIfBnIsComplete(ns, player) {
if (bnCompletionSuppressed) return true;
Expand Down Expand Up @@ -286,15 +286,15 @@ async function getRunningScripts(ns) {
}

/** Helper to get the first instance of a running script by name.
* @param {NS} ns
* @param {NS} ns
* @param {ProcessInfo[]} runningScripts - (optional) Cached list of running scripts to avoid repeating this expensive request
* @param {(value: ProcessInfo, index: number, array: ProcessInfo[]) => unknown} filter - (optional) Filter the list of processes beyond just matching on the script name */
function findScriptHelper(baseScriptName, runningScripts, filter = null) {
return runningScripts.filter(s => s.filename == getFilePath(baseScriptName) && (!filter || filter(s)))[0];
}

/** Helper to kill a running script instance by name
* @param {NS} ns
* @param {NS} ns
* @param {ProcessInfo[]} runningScripts - (optional) Cached list of running scripts to avoid repeating this expensive request
* @param {ProcessInfo} processInfo - (optional) The process to kill, if we've already found it in advance */
async function killScript(ns, baseScriptName, runningScripts = null, processInfo = null) {
Expand All @@ -308,7 +308,7 @@ async function killScript(ns, baseScriptName, runningScripts = null, processInfo
}

/** Logic to ensure scripts are running to progress the BN
* @param {NS} ns
* @param {NS} ns
* @param {Player} player */
async function checkOnRunningScripts(ns, player) {
if (lastScriptsCheck > Date.now() - options['interval-check-scripts']) return;
Expand Down Expand Up @@ -359,7 +359,7 @@ async function checkOnRunningScripts(ns, player) {
}
}

// Determine the arguments we want to run daemon.js with. We will either pass these directly, or through stanek.js if we're running it first.
// Determine the arguments we want to run daemon.js with. We will either pass these directly, or through stanek.js if we're running it first.
const hackThreshold = options['high-hack-threshold']; // If player.skills.hacking level is about 8000, run in "start-tight" mode
const daemonArgs = (player.skills.hacking < hackThreshold) ? [] :
// Launch daemon in "looping" mode if we have sufficient hack level
Expand Down Expand Up @@ -439,7 +439,7 @@ async function checkOnRunningScripts(ns, player) {
}

/** Logic to steal 10b from the casino
* @param {NS} ns
* @param {NS} ns
* @param {Player} player */
async function maybeDoCasino(ns, player) {
if (ranCasino || options['disable-casino']) return;
Expand Down Expand Up @@ -484,7 +484,7 @@ async function maybeDoCasino(ns, player) {
}

/** Retrieves the last faction manager output file, parses, and types it.
* @param {NS} ns
* @param {NS} ns
* @returns {{ affordable_nf_count: number, affordable_augs: [string], owned_count: number, unowned_count: number, total_rep_cost: number, total_aug_cost: number }}
*/
function getFactionManagerOutput(ns) {
Expand All @@ -493,7 +493,7 @@ function getFactionManagerOutput(ns) {
}

/** Logic to detect if it's a good time to install augmentations, and if so, do so
* @param {NS} ns
* @param {NS} ns
* @param {Player} player */
async function maybeInstallAugmentations(ns, player) {
if (!(4 in unlockedSFs)) {
Expand Down Expand Up @@ -587,7 +587,7 @@ async function maybeInstallAugmentations(ns, player) {
}

/** Logic to detect if we are close to a milestone and should postpone installing augmentations until it is hit
* @param {NS} ns
* @param {NS} ns
* @param {Player} player
* @param {{ affordable_nf_count: number, affordable_augs: [string], owned_count: number, unowned_count: number, total_rep_cost: number, total_aug_cost: number }} facmanOutput
*/
Expand Down Expand Up @@ -624,7 +624,7 @@ async function shouldDelayInstall(ns, player, facmanOutput) {
}

/** Consolidated logic for all the times we want to reserve money
* @param {NS} ns
* @param {NS} ns
* @param {Player} player */
function manageReservedMoney(ns, player, stocksValue) {
if (reservedPurchase) return; // Do not mess with money reserved for installing augmentations
Expand All @@ -642,11 +642,11 @@ function manageReservedMoney(ns, player, stocksValue) {
return currentReserve == reserve ? true : ns.write("reserve.txt", reserve, "w"); // Reserve for stocks
// NOTE: After several iterations, I decided that the above is actually best to keep in all scenarios:
// - Casino.js ignores the reserve, so the above takes care of ensuring our casino seed money isn't spent
// - In low-income situations, stockmaster will be our best source of income. We invoke it such that it ignores
// - In low-income situations, stockmaster will be our best source of income. We invoke it such that it ignores
// the global reserve, so this 8B is for stocks only. The 2B remaining is plenty to kickstart the rest.
// - Once high-hack/gang income is achieved, this 8B will not be missed anyway.
// - Once high-hack/gang income is achieved, this 8B will not be missed anyway.
/*
if(!ranCasino) { // In practice,
if(!ranCasino) { // In practice,
ns.write("reserve.txt", 300000, "w"); // Prevent other scripts from spending our casino seed money
return moneyReserved = true;
}
Expand Down
16 changes: 8 additions & 8 deletions bladeburner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const costAdjustments = {
"Evasive Systems": 1.2, // Dex/Agi boost. Mildly deprioritized for same reasoning as above.
"Cloak": 1.5, // Cheap, and stealth ends up with plenty of boost, so we don't need to invest in Cloak as much.
"Hyperdrive": 2, // Improves stats gained, but not Rank gained. Less useful if training outside of BB
"Tracer": 2, // Only boosts Contract success chance, which are relatively easy to begin with.
"Tracer": 2, // Only boosts Contract success chance, which are relatively easy to begin with.
"Cyber's Edge": 5, // Boosts stamina, but contract counts are much more limiting than stamina, so isn't really needed
"Hands of Midas": 10 // Improves money gain. It is assumed that Bladeburner will *not* be a main source of income
};
Expand Down Expand Up @@ -95,7 +95,7 @@ const getBBDict = async (ns, strFunction, elements, ...args) => await getNsDataT
const getBBDictByActionType = async (ns, strFunction, actionType, elements) =>
await getBBDict(ns, `${strFunction}(ns.args[1], %)`, elements, actionType);

/** @param {NS} ns
/** @param {NS} ns
* Gather all one-time bladeburner info using ram-dodging scripts. */
async function gatherBladeburnerInfo(ns) {
skillNames = await getBBInfo(ns, 'getSkillNames()');
Expand Down Expand Up @@ -129,7 +129,7 @@ const getMinKeyValue = (dict, filteredKeys = null) => (filteredKeys || Object.ke
const getMaxKeyValue = (dict, filteredKeys = null) => (filteredKeys || Object.keys(dict)).reduce(([k, max], key) =>
dict[key] > max ? [key, dict[key]] : [k, max], [null, -Number.MAX_VALUE]);

/** @param {NS} ns
/** @param {NS} ns
* The main loop that decides what we should be doing in bladeburner. */
async function mainLoop(ns) {
// Get player's updated rank
Expand Down Expand Up @@ -353,7 +353,7 @@ async function mainLoop(ns) {
currentTaskEndTime = !success ? 0 : Date.now() + expectedDuration + 10; // Pad this a little to ensure we don't interrupt it.
}

/** @param {NS} ns
/** @param {NS} ns
* Helper to switch cities. */
async function switchToCity(ns, city, reason) {
const success = await getBBInfo(ns, `switchCity(ns.args[0])`, city);
Expand All @@ -362,7 +362,7 @@ async function switchToCity(ns, city, reason) {
return success;
}

/** @param {NS} ns
/** @param {NS} ns
* Decides how to spend skill points. */
async function spendSkillPoints(ns) {
while (true) { // Loop until we determine there's nothing left to spend skill points on
Expand Down Expand Up @@ -392,7 +392,7 @@ async function spendSkillPoints(ns) {
}
}

/** @param {NS} ns
/** @param {NS} ns
* Helper to try and join the Bladeburner faction ASAP. */
async function tryJoinFaction(ns, rank) {
if (inFaction) return;
Expand All @@ -405,7 +405,7 @@ async function tryJoinFaction(ns, rank) {

let lastCanWorkCheckIdle = true;

/** @param {NS} ns
/** @param {NS} ns
* Helper to see if we are able to do bladeburner work */
async function canDoBladeburnerWork(ns) {
if (options['ignore-busy-status'] || haveSimulacrum) return true;
Expand All @@ -418,7 +418,7 @@ async function canDoBladeburnerWork(ns) {
return lastCanWorkCheckIdle = false;
}

/** @param {NS} ns
/** @param {NS} ns
* Ensure we're in the Bladeburner division */
async function beingInBladeburner(ns) {
// Ensure we're in the Bladeburner division. If not, wait until we've joined it.
Expand Down
16 changes: 8 additions & 8 deletions casino.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export async function main(ns) {
// Detect if we were kicked out (hopefully this is why the buttons are missing)
if (await checkForKickedOut())
return onCompletion(ns);
// No? Well sometimes "clicking" start game fails. If this is what happened,
// No? Well sometimes "clicking" start game fails. If this is what happened,
// we can suppress the error and start over. If it keeps happening, something else is wrong...
suppressedErrors++; // Once this reahes 4, calls to findRetry above will throw an error on failure.
// In case we lost our start button (e.g. re-rendered as different element), find it again
Expand Down Expand Up @@ -229,22 +229,22 @@ export async function main(ns) {
}
}
catch (error) {
ns.tail(); // Display the tail log if anything goes wrong
ns.tail(); // Display the tail log if anything goes wrong
throw error; // Rethrow
}
}

/** Forces the game to reload (without saving). Great for save scumming.
* WARNING: Doesn't work if the user last ran the game with "Reload and kill all scripts"
* WARNING: Doesn't work if the user last ran the game with "Reload and kill all scripts"
* @param {NS} ns */
async function reload(ns) {
eval("window").onbeforeunload = null; // Disable the unsaved changes warning before reloading
await ns.sleep(options['save-sleep-time']); // Yield execution for an instant incase the game needs to finish a save or something
location.reload(); // Force refresh the page without saving
location.reload(); // Force refresh the page without saving
await ns.sleep(10000); // Keep the script alive to be safe. Presumably the page reloads before this completes.
}

/** @param {NS} ns
/** @param {NS} ns
* Helper to kill all scripts on all other servers, except this one **/
async function killAllOtherScripts(ns, removeRemoteFiles) {
// Kill processes on home (except this one)
Expand All @@ -270,13 +270,13 @@ async function killAllOtherScripts(ns, removeRemoteFiles) {
}
}

/** @param {NS} ns
/** @param {NS} ns
* Run when we can no longer gamble at the casino (presumably because we've been kicked out) **/
function onCompletion(ns) {
ns.write(ran_flag, "True", "w"); // Write an file indicating we think we've been kicked out of the casino.
log(ns, "SUCCESS: We've been kicked out of the casino.", true);

// Run the completion script before shutting down
// Run the completion script before shutting down
let completionScript = options['on-completion-script'];
if (!completionScript) return;
let completionArgs = options['on-completion-script-args'];
Expand Down Expand Up @@ -344,7 +344,7 @@ function shouldHitAdvanced(ns, playerCountElem) {
}
if (player >= 17) return false; // Stay on Hard 17 or higher
if (player >= 13 && dealer <= 6) return false; // Stay if player has 13-16 and dealer shows 6 or less.
if (player == 12 && 4 <= dealer && dealer <= 6) return false; // Stay if player has 12 and dealer has 4 to 6
if (player == 12 && 4 <= dealer && dealer <= 6) return false; // Stay if player has 12 and dealer has 4 to 6
return true;// Otherwise Hit
}
function getDealerCount() {
Expand Down
4 changes: 2 additions & 2 deletions daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export async function main(ns) {
maxTargets = 2;
lowUtilizationIterations = highUtilizationIterations = 0;
allHostNames = [], _allServers = [], psCache = [];
// Get information about the player's current stats (also populates a cache)
// Get information about the player's current stats (also populates a cache)
const playerInfo = await getPlayerInfo(ns);

// Try to get "resetInfo", with a fallback for a failed dynamic call (i.e. low-ram conditions)
Expand Down Expand Up @@ -1916,7 +1916,7 @@ class Tool {
this.isThreadSpreadingAllowed = toolConfig.threadSpreadingAllowed === true;
this.cost = toolCost;
}
/** @param {Server} server
/** @param {Server} server
* @returns {boolean} true if the server has this tool and enough ram to run it. */
canRun(server) {
return doesFileExist(server.ns, this.name, server.name) && server.ramAvailable() >= this.cost;
Expand Down
2 changes: 1 addition & 1 deletion dump-ns-namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function autocomplete(data, args) {
];
}

/** Intended to help me explore the NS namespace by dumping properties and function results.
/** Intended to help me explore the NS namespace by dumping properties and function results.
* @param {NS} ns */
export async function main(ns) {
const obj = ns.args.length > 0 ? ns[ns.args[0]] : ns;
Expand Down
Loading

0 comments on commit 69fd985

Please sign in to comment.