From 64584401935738cd4c5039d98d288ffe80639bd5 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Thu, 23 Dec 2021 09:11:08 -0500 Subject: [PATCH 01/31] Fix #2021: Handle sleeves xp in stats overview --- src/PersonObjects/formulas/skill.ts | 18 +++++++++++++++++- src/ui/React/StatsProgressBar.tsx | 10 ++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/PersonObjects/formulas/skill.ts b/src/PersonObjects/formulas/skill.ts index 2aa52bff4..c320cc526 100644 --- a/src/PersonObjects/formulas/skill.ts +++ b/src/PersonObjects/formulas/skill.ts @@ -17,6 +17,17 @@ export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress { if (nextExperience < 0) nextExperience = 0; const normalize = (value: number): number => ((value - baseExperience) * 100) / (nextExperience - baseExperience); + let progress = (nextExperience - baseExperience !== 0) ? normalize(exp) : 99.99; + + // Clamp progress: When sleeves are working out, the player gets way too much progress + if (progress < 0) progress = 0 + if (progress > 100) progress = 100; + + // Clamp floating point imprecisions + let currentExperience = exp - baseExperience; + let remainingExperience = nextExperience - exp; + if (currentExperience < 0) currentExperience = 0; + if (remainingExperience < 0) remainingExperience = 0; return { currentSkill, @@ -24,7 +35,9 @@ export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress { baseExperience, experience: exp, nextExperience, - progress: (nextExperience - baseExperience !== 0) ? normalize(exp) : 99.99 + currentExperience, + remainingExperience, + progress } } @@ -34,6 +47,8 @@ export interface ISkillProgress { baseExperience: number; experience: number; nextExperience: number; + currentExperience: number; + remainingExperience: number; progress: number; } @@ -41,6 +56,7 @@ export function getEmptySkillProgress(): ISkillProgress { return { currentSkill: 0, nextSkill: 0, baseExperience: 0, experience: 0, nextExperience: 0, + currentExperience: 0, remainingExperience: 0, progress: 0, }; } diff --git a/src/ui/React/StatsProgressBar.tsx b/src/ui/React/StatsProgressBar.tsx index 085d5afca..1e583a7d5 100644 --- a/src/ui/React/StatsProgressBar.tsx +++ b/src/ui/React/StatsProgressBar.tsx @@ -9,6 +9,7 @@ interface IProgressProps { min: number; max: number; current: number; + remaining: number; progress: number; color?: React.CSSProperties["color"]; } @@ -18,14 +19,14 @@ interface IStatsOverviewCellProps { color?: React.CSSProperties["color"]; } -export function StatsProgressBar({ min, max, current, progress, color }: IProgressProps): React.ReactElement { +export function StatsProgressBar({ min, max, current, remaining, progress, color }: IProgressProps): React.ReactElement { const tooltip = ( Progress:  - {numeralWrapper.formatExp(current - min)} / {numeralWrapper.formatExp(max - min)} + {numeralWrapper.formatExp(current)} / {numeralWrapper.formatExp(max - min)}
Remaining:  - {numeralWrapper.formatExp(max - current)} ({progress.toFixed(2)}%) + {numeralWrapper.formatExp(remaining)} ({progress.toFixed(2)}%)
); @@ -58,7 +59,8 @@ export function StatsProgressOverviewCell({ progress: skill, color }: IStatsOver From 4861ac4153b8273fdfea42614841c5bcb940a6f7 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 23 Dec 2021 19:15:22 +0000 Subject: [PATCH 02/31] Fixes penalty message for quitting work early. --- src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index b85dee8e7..3508a77fb 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -654,6 +654,8 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str this.workRepGained *= this.cancelationPenalty(); } + const penaltyString = this.cancelationPenalty() === 0.5 ? "half" : "three-quarters"; + const company = Companies[this.companyName]; company.playerReputation += this.workRepGained; @@ -680,7 +682,7 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str <> You worked a short shift of {convertTimeMsToTimeElapsedString(this.timeWorked)}

- Since you cancelled your work early, you only gained half of the reputation you earned.
+ Since you cancelled your work early, you only gained {penaltyString} of the reputation you earned.

{content} From 12ba68a375ed77d0ff9bf40c5a96ab9e80f38dec Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 23 Dec 2021 19:15:39 +0000 Subject: [PATCH 03/31] XP gain summaries now only show non-zero xp gains. --- .../Player/PlayerObjectGeneralMethods.tsx | 12 +-- src/ui/WorkInProgressRoot.tsx | 84 ++++++++----------- 2 files changed, 42 insertions(+), 54 deletions(-) diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 3508a77fb..e3723daea 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -667,12 +667,12 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str
reputation for the company
- {numeralWrapper.formatExp(this.workHackExpGained)} hacking exp
- {numeralWrapper.formatExp(this.workStrExpGained)} strength exp
- {numeralWrapper.formatExp(this.workDefExpGained)} defense exp
- {numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp
- {numeralWrapper.formatExp(this.workAgiExpGained)} agility exp
- {numeralWrapper.formatExp(this.workChaExpGained)} charisma exp + {this.workHackExpGained > 0 && <>{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp
} + {this.workStrExpGained > 0 && <>{numeralWrapper.formatExp(this.workStrExpGained)} strength exp
} + {this.workDefExpGained > 0 && <>{numeralWrapper.formatExp(this.workDefExpGained)} defense exp
} + {this.workDexExpGained > 0 && <>{numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp
} + {this.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(this.workAgiExpGained)} agility exp
} + {this.workChaExpGained > 0 && <>{numeralWrapper.formatExp(this.workChaExpGained)} charisma exp
}
); diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index ef4d4b8f4..58b45ca09 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -62,20 +62,14 @@ export function WorkInProgressRoot(): React.ReactElement { ( ) reputation for this faction

- {numeralWrapper.formatExp(player.workHackExpGained)} ( - {numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp
+ {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ({numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp
}
- {numeralWrapper.formatExp(player.workStrExpGained)} ( - {numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp
- {numeralWrapper.formatExp(player.workDefExpGained)} ( - {numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp
- {numeralWrapper.formatExp(player.workDexExpGained)} ( - {numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp
- {numeralWrapper.formatExp(player.workAgiExpGained)} ( - {numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp
+ {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ({numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp
} + {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ({numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp
} + {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ({numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp
} + {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ({numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp
}
- {numeralWrapper.formatExp(player.workChaExpGained)} ( - {numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp
+ {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ({numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp
}
You will automatically finish after working for 20 hours. You can cancel earlier if you wish.
@@ -123,18 +117,12 @@ export function WorkInProgressRoot(): React.ReactElement {

You have gained:
- {numeralWrapper.formatExp(player.workHackExpGained)} ( - {numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp
- {numeralWrapper.formatExp(player.workStrExpGained)} ( - {numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp
- {numeralWrapper.formatExp(player.workDefExpGained)} ( - {numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp
- {numeralWrapper.formatExp(player.workDexExpGained)} ( - {numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp
- {numeralWrapper.formatExp(player.workAgiExpGained)} ( - {numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp
- {numeralWrapper.formatExp(player.workChaExpGained)} ( - {numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp
+ {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ({numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp
} + {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ({numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp
} + {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ({numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp
} + {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ({numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp
} + {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ({numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp
} + {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ({numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp
} You may cancel at any time @@ -185,26 +173,26 @@ export function WorkInProgressRoot(): React.ReactElement { ( ) reputation for this company

- {numeralWrapper.formatExp(player.workHackExpGained)} ( + {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ( {`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`} - ) hacking exp
+ ) hacking exp
}
- {numeralWrapper.formatExp(player.workStrExpGained)} ( + {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ( {`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`} - ) strength exp
- {numeralWrapper.formatExp(player.workDefExpGained)} ( + ) strength exp
} + {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ( {`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`} - ) defense exp
- {numeralWrapper.formatExp(player.workDexExpGained)} ( + ) defense exp
} + {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ( {`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`} - ) dexterity exp
- {numeralWrapper.formatExp(player.workAgiExpGained)} ( + ) dexterity exp
} + {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ( {`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`} - ) agility exp
+ ) agility exp
}
- {numeralWrapper.formatExp(player.workChaExpGained)} ( + {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ( {`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`} - ) charisma exp
+ ) charisma exp
}
You will automatically finish after working for 8 hours. You can cancel earlier if you wish, but you will only gain {penaltyString} of the reputation you've earned so far. @@ -256,26 +244,26 @@ export function WorkInProgressRoot(): React.ReactElement { ) reputation for this company

- {numeralWrapper.formatExp(player.workHackExpGained)} ( + {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ( {`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`} - ) hacking exp
+ ) hacking exp
}
- {numeralWrapper.formatExp(player.workStrExpGained)} ( + {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ( {`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`} - ) strength exp
- {numeralWrapper.formatExp(player.workDefExpGained)} ( + ) strength exp
} + {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ( {`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`} - ) defense exp
- {numeralWrapper.formatExp(player.workDexExpGained)} ( + ) defense exp
} + {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ( {`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`} - ) dexterity exp
- {numeralWrapper.formatExp(player.workAgiExpGained)} ( + ) dexterity exp
} + {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ( {`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`} - ) agility exp
+ ) agility exp
}
- {numeralWrapper.formatExp(player.workChaExpGained)} ( + {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ( {`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`} - ) charisma exp
+ ) charisma exp
}
You will automatically finish after working for 8 hours. You can cancel earlier if you wish, and there will be no penalty because this is a part-time job. From 3eedd9df889027fcc93fd7e62f97ce87a443f2d3 Mon Sep 17 00:00:00 2001 From: Hedrauta Date: Fri, 24 Dec 2021 00:23:38 +0100 Subject: [PATCH 04/31] empty host = current host --- src/ScriptEditor/NetscriptDefinitions.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index d125e2c8e..4ea848098 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4690,11 +4690,12 @@ export interface NS extends Singularity { * Kills all running scripts on the specified server. This function returns true * if any scripts were killed, and false otherwise. In other words, it will return * true if there are any scripts running on the target server. + * If no host is defined, it will kill all scripts, where the script is running. * * @param host - IP or hostname of the server on which to kill all scripts. * @returns True if any scripts were killed, and false otherwise. */ - killall(host: string): boolean; + killall(host?: string): boolean; /** * Terminates the current script immediately. From deb6d6cc0a755d5523c9db73397a8ad6f396e43c Mon Sep 17 00:00:00 2001 From: maxtimum Date: Thu, 23 Dec 2021 17:39:45 -0800 Subject: [PATCH 05/31] add option to pass grep pattern to ps --- src/Terminal/commands/ps.ts | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Terminal/commands/ps.ts b/src/Terminal/commands/ps.ts index e62f3fe3a..cf122193f 100644 --- a/src/Terminal/commands/ps.ts +++ b/src/Terminal/commands/ps.ts @@ -10,16 +10,32 @@ export function ps( server: BaseServer, args: (string | number | boolean)[], ): void { - if (args.length !== 0) { - terminal.error("Incorrect usage of ps command. Usage: ps"); + if (args.length === 1 || args.length === 2 || args.length > 3) { + terminal.error("Incorrect usage of ps command. Usage: ps [| grep ]"); return; } - for (let i = 0; i < server.runningScripts.length; i++) { - const rsObj = server.runningScripts[i]; - let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; - for (let j = 0; j < rsObj.args.length; ++j) { - res += " " + rsObj.args[j].toString(); + if(args[0] === '|' && args[1] === 'grep'){ + const pattern = new RegExp(`${args[2].toString()}`) + const matching = server.runningScripts.filter((x) => pattern.test(x.filename)) + for(let i = 0; i < matching.length; i++){ + const rsObj = matching[i]; + let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; + for (let j = 0; j < rsObj.args.length; ++j) { + res += " " + rsObj.args[j].toString(); + } + terminal.print(res); } - terminal.print(res); + }else if(args.length === 0){ + for (let i = 0; i < server.runningScripts.length; i++) { + const rsObj = server.runningScripts[i]; + let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; + for (let j = 0; j < rsObj.args.length; ++j) { + res += " " + rsObj.args[j].toString(); + } + terminal.print(res); + } + }else{ + terminal.error("Incorrect usage of ps command. Usage: ps [| grep ]"); + return; } } From 13e68ba48e82787badee4bb3a31f905c4526f2bf Mon Sep 17 00:00:00 2001 From: maxtimum Date: Thu, 23 Dec 2021 17:43:52 -0800 Subject: [PATCH 06/31] update documentation for ps --- doc/source/basicgameplay/terminal.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/basicgameplay/terminal.rst b/doc/source/basicgameplay/terminal.rst index e6aba8767..14285f913 100644 --- a/doc/source/basicgameplay/terminal.rst +++ b/doc/source/basicgameplay/terminal.rst @@ -432,7 +432,10 @@ empty file will be created. ps ^^ + $ ps [| grep pattern] + Prints all scripts that are currently running on the current server. +The :code:`| grep pattern` option will only output running scripts where the name matches the provided pattern. rm ^^ From 2d949c076b0b63a98b58db07f00a3148962ae550 Mon Sep 17 00:00:00 2001 From: theit8514 Date: Thu, 23 Dec 2021 21:29:53 -0500 Subject: [PATCH 07/31] Fix mv overwriting script files --- src/Terminal/commands/mv.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Terminal/commands/mv.ts b/src/Terminal/commands/mv.ts index 449f92cc8..9276f4bdb 100644 --- a/src/Terminal/commands/mv.ts +++ b/src/Terminal/commands/mv.ts @@ -53,7 +53,7 @@ export function mv( // Also, you can't convert between different file types if (isScriptFilename(source)) { const script = srcFile as Script; - if (!isScriptFilename(dest)) { + if (!isScriptFilename(destPath)) { terminal.error(`Source and destination files must have the same type`); return; } @@ -66,7 +66,7 @@ export function mv( if (destFile != null) { // Already exists, will be overwritten, so we'll delete it - const status = server.removeFile(dest); + const status = server.removeFile(destPath); if (!status.res) { terminal.error(`Something went wrong...please contact game dev (probably a bug)`); return; From f28ddd3b3fa78e1de82acaa497ce3006d823f6f8 Mon Sep 17 00:00:00 2001 From: maxtimum Date: Thu, 23 Dec 2021 21:39:34 -0800 Subject: [PATCH 08/31] update docs for -g flag --- doc/source/basicgameplay/terminal.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/basicgameplay/terminal.rst b/doc/source/basicgameplay/terminal.rst index 14285f913..638ab3320 100644 --- a/doc/source/basicgameplay/terminal.rst +++ b/doc/source/basicgameplay/terminal.rst @@ -432,10 +432,10 @@ empty file will be created. ps ^^ - $ ps [| grep pattern] + $ ps [-g pattern] Prints all scripts that are currently running on the current server. -The :code:`| grep pattern` option will only output running scripts where the name matches the provided pattern. +The :code:`-g pattern` option will only output running scripts where the name matches the provided pattern. rm ^^ From 07b00bc37744fe539bd83a1abe55fd35b51b07e3 Mon Sep 17 00:00:00 2001 From: maxtimum Date: Thu, 23 Dec 2021 22:31:07 -0800 Subject: [PATCH 09/31] add -g, --grep flags to ps command, documentation --- doc/source/basicgameplay/terminal.rst | 4 ++-- src/Terminal/commands/ps.ts | 29 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/doc/source/basicgameplay/terminal.rst b/doc/source/basicgameplay/terminal.rst index 638ab3320..1ee640f24 100644 --- a/doc/source/basicgameplay/terminal.rst +++ b/doc/source/basicgameplay/terminal.rst @@ -432,10 +432,10 @@ empty file will be created. ps ^^ - $ ps [-g pattern] + $ ps [-g, --grep pattern] Prints all scripts that are currently running on the current server. -The :code:`-g pattern` option will only output running scripts where the name matches the provided pattern. +The :code:`-g, --grep pattern` option will only output running scripts where the name matches the provided pattern. rm ^^ diff --git a/src/Terminal/commands/ps.ts b/src/Terminal/commands/ps.ts index cf122193f..695d9a71d 100644 --- a/src/Terminal/commands/ps.ts +++ b/src/Terminal/commands/ps.ts @@ -2,6 +2,7 @@ import { ITerminal } from "../ITerminal"; import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; +import * as libarg from "arg" export function ps( terminal: ITerminal, @@ -10,14 +11,24 @@ export function ps( server: BaseServer, args: (string | number | boolean)[], ): void { - if (args.length === 1 || args.length === 2 || args.length > 3) { - terminal.error("Incorrect usage of ps command. Usage: ps [| grep ]"); + let flags; + try{ + flags = libarg({ + '--grep': String, + '-g': '--grep' + }, + { argv: args } + ) + }catch(e){ + // catch passing only -g / --grep with no string to use as the search + terminal.error("Incorrect usage of ps command. Usage: ps [-g, --grep pattern]"); return; } - if(args[0] === '|' && args[1] === 'grep'){ - const pattern = new RegExp(`${args[2].toString()}`) - const matching = server.runningScripts.filter((x) => pattern.test(x.filename)) - for(let i = 0; i < matching.length; i++){ + const pattern = flags['--grep'] + if (pattern) { + const re = new RegExp(pattern.toString()) + const matching = server.runningScripts.filter((x) => re.test(x.filename)) + for (let i = 0; i < matching.length; i++) { const rsObj = matching[i]; let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; for (let j = 0; j < rsObj.args.length; ++j) { @@ -25,7 +36,8 @@ export function ps( } terminal.print(res); } - }else if(args.length === 0){ + } + if(args.length === 0){ for (let i = 0; i < server.runningScripts.length; i++) { const rsObj = server.runningScripts[i]; let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; @@ -34,8 +46,5 @@ export function ps( } terminal.print(res); } - }else{ - terminal.error("Incorrect usage of ps command. Usage: ps [| grep ]"); - return; } } From 072653674e582071e4fb26f52b8b44ff9d478c50 Mon Sep 17 00:00:00 2001 From: Xynrati <84252507+Xynrati@users.noreply.github.com> Date: Fri, 24 Dec 2021 06:11:45 -0800 Subject: [PATCH 10/31] Removing old comment about removed parameter Because "no it don't" --- markdown/bitburner.ns.gethacktime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/bitburner.ns.gethacktime.md b/markdown/bitburner.ns.gethacktime.md index f0b518f7d..34d6450f3 100644 --- a/markdown/bitburner.ns.gethacktime.md +++ b/markdown/bitburner.ns.gethacktime.md @@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the hack Netscrip RAM cost: 0.05 GB -Returns the amount of time in milliseconds it takes to execute the hack Netscript function on the target server. The function takes in an optional hackLvl parameter that can be specified to see what the hack time would be at different hacking levels. +Returns the amount of time in milliseconds it takes to execute the hack Netscript function on the target server. From 3b8bdb7449065a8c58d19612264ab8f79cd0df2f Mon Sep 17 00:00:00 2001 From: Locria Cyber Date: Fri, 24 Dec 2021 22:32:03 +0800 Subject: [PATCH 11/31] Add peer dependencies for material-ui-color --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 1c0ec4dfe..747b5d943 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", + "@material-ui/core": "^4.12.3", "@microsoft/api-documenter": "^7.13.65", "@microsoft/api-extractor": "^7.18.17", "@monaco-editor/react": "^4.2.2", @@ -37,9 +38,11 @@ "jquery": "^3.5.0", "jszip": "^3.7.0", "material-ui-color": "^1.2.0", + "material-ui-popup-state": "^1.5.3", "monaco-editor": "^0.27.0", "notistack": "^2.0.2", "numeral": "2.0.6", + "prop-types": "^15.8.0", "raw-loader": "^4.0.2", "react": "^17.0.2", "react-beautiful-dnd": "^13.1.0", From 23683d3482fdb9e798baa71e5a67ba39792a7a50 Mon Sep 17 00:00:00 2001 From: Anton Mironov Date: Fri, 24 Dec 2021 17:32:51 +0100 Subject: [PATCH 12/31] Fixes CorporationInfo.state Before: CorporationInfo.state was returning "[Object object]". After: CorporationInfo.state returns an actual state like START, PURCHASE, PRODUCTION, SALE, EXPORT --- src/NetscriptFunctions/Corporation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 5e477db39..67bb16e76 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -496,7 +496,7 @@ export function NetscriptCorporation( shareSaleCooldown: corporation.shareSaleCooldown, issuedShares: corporation.issuedShares, sharePrice: corporation.sharePrice, - state: corporation.state + "", + state: corporation.state.getState(), }; }, }; From 3dd818cb7b1ffc9c0422aaa5be298116d90546a9 Mon Sep 17 00:00:00 2001 From: Anton Mironov Date: Fri, 24 Dec 2021 17:35:23 +0100 Subject: [PATCH 13/31] Updating doc for CorporationInfo.state Now includes a list of possible values. --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 4ea848098..74e581f22 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -6128,7 +6128,7 @@ interface CorporationInfo { issuedShares: number; /** Price of the shares */ sharePrice: number; - /** State of the corporation, like PRODUCTION or EXPORT */ + /** State of the corporation. Possible states are START, PURCHASE, PRODUCTION, SALE, EXPORT. */ state: string; } From a16cb745c5f48121f92739769d43fd50f480b9a4 Mon Sep 17 00:00:00 2001 From: MageKing17 Date: Fri, 24 Dec 2021 19:34:34 -0800 Subject: [PATCH 14/31] Get rid of console spam in NetscriptFunctions.ts This was filling up the console and making it hard to debug anything other than `exec` calls. --- src/NetscriptFunctions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 83a4335ac..cae6f3dc4 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -952,7 +952,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { return runScriptFromScript("run", scriptServer, scriptname, args, workerScript, threads); }, exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any { - console.log(`${scriptname} ${hostname} ${threads} ${JSON.stringify(args)}`); updateDynamicRam("exec", getRamCost("exec")); if (scriptname === undefined || hostname === undefined) { throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); From eb137455f5544ab9e680aa67f0d3ff2eb0c2accf Mon Sep 17 00:00:00 2001 From: MageKing17 Date: Fri, 24 Dec 2021 21:22:46 -0800 Subject: [PATCH 15/31] Allow shortcuts to work while doing unfocused work. A lot of people thought keyboard shortcuts weren't working because the code to make them stop working was only checking if the player was working without checking if the player was also focused. If doing unfocused work, there's no reason not to allow keyboard shortcuts to keep working. --- src/Sidebar/ui/SidebarRoot.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sidebar/ui/SidebarRoot.tsx b/src/Sidebar/ui/SidebarRoot.tsx index a974fbba9..132758e92 100644 --- a/src/Sidebar/ui/SidebarRoot.tsx +++ b/src/Sidebar/ui/SidebarRoot.tsx @@ -273,7 +273,7 @@ export function SidebarRoot(props: IProps): React.ReactElement { // Alt-o - Options function handleShortcuts(this: Document, event: KeyboardEvent): any { if (Settings.DisableHotkeys) return; - if (props.player.isWorking || redPillFlag) return; + if ((props.player.isWorking && props.player.focus) || redPillFlag) return; if (event.keyCode == KEY.T && event.altKey) { event.preventDefault(); clickTerminal(); From 73adc71965171eb8c007a1decc6b10131c92aeb5 Mon Sep 17 00:00:00 2001 From: Frank-py <85338377+Frank-py@users.noreply.github.com> Date: Sat, 25 Dec 2021 23:11:21 +0100 Subject: [PATCH 16/31] Updated Terminal.tsx to add keypress event. Added keypress event to delete the word after input by pressing "alt" + "d". --- src/Terminal/ui/TerminalInput.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Terminal/ui/TerminalInput.tsx b/src/Terminal/ui/TerminalInput.tsx index 6a6dd4027..dc0a4ab86 100644 --- a/src/Terminal/ui/TerminalInput.tsx +++ b/src/Terminal/ui/TerminalInput.tsx @@ -350,7 +350,12 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React event.preventDefault(); modifyInput("deletewordbefore"); } - + + if (event.keyCode === KEY.D && event.altKey) { + event.preventDefault(); + modifyInput("deletewordafter"); + } + if (event.keyCode === KEY.U && event.ctrlKey) { event.preventDefault(); modifyInput("clearbefore"); @@ -360,9 +365,6 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React event.preventDefault(); modifyInput("clearafter"); } - - // TODO AFTER THIS: - // alt + d deletes word after cursor } } From a4eddb46916134e5e7259b4adb853d9e9d9b8cc4 Mon Sep 17 00:00:00 2001 From: Frank-py <85338377+Frank-py@users.noreply.github.com> Date: Sat, 25 Dec 2021 23:18:49 +0100 Subject: [PATCH 17/31] Fixed typo in CONTRIBUTING.md file. Changed naviguate to navigate. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41c22e38d..ecf90a90c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,7 +118,7 @@ Inside the root of the repo run `npm install` to install all the dependencies `npm run start:dev` to launch the game in dev mode. -After that you can open any browser and naviguate to `localhost:8000` and play the game. +After that you can open any browser and navigate to `localhost:8000` and play the game. Saving a file will reload the game automatically. #### Submitting a Pull Request From 6a9f6c05ecc8efd79c1add10dbd5b53b8dea9c04 Mon Sep 17 00:00:00 2001 From: Robert Klebes Date: Sun, 26 Dec 2021 14:14:37 -0500 Subject: [PATCH 18/31] Update parseAliasDeclaration to match single quote - Matches foo="bar" and foo='bar' - Does not match foo="bar' or foo='bar" --- src/Alias.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Alias.ts b/src/Alias.ts index b80aed6a3..238c531e0 100644 --- a/src/Alias.ts +++ b/src/Alias.ts @@ -36,7 +36,7 @@ export function printAliases(): void { // Returns true if successful, false otherwise export function parseAliasDeclaration(dec: string, global = false): boolean { - const re = /^([\w|!|%|,|@|-]+)="(.+)"$/; + const re = /^([\w|!|%|,|@|-]+)=(("(.+)")|('(.+)'))$/; const matches = dec.match(re); if (matches == null || matches.length != 3) { return false; From 1087db9f330084bebbce284218ff261872bc98ac Mon Sep 17 00:00:00 2001 From: ReeseJones Date: Sun, 26 Dec 2021 14:35:46 -0800 Subject: [PATCH 19/31] changed setting to selling in getSaleGain --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 4ea848098..d89991040 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -1045,7 +1045,7 @@ export interface TIX { getPurchaseCost(sym: string, shares: number, posType: string): number; /** - * Calculate profit of setting stocks. + * Calculate profit of selling stocks. * @remarks * RAM cost: 2 GB * Calculates and returns how much you would gain from selling a given number of shares of a stock. From 169d3e6c77461b7653c7b375d4bd7be7d7f4d9ae Mon Sep 17 00:00:00 2001 From: theit8514 Date: Sun, 26 Dec 2021 17:33:15 -0500 Subject: [PATCH 20/31] Add title attribute to log title bar --- src/ui/React/LogBoxManager.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index c864c1be0..f30c8c4a9 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -140,10 +140,10 @@ function LogWindow(props: IProps): React.ReactElement { rerender(); } - function title(): string { + function title(full = false): string { const maxLength = 30; const t = `${script.filename} ${script.args.map((x: any): string => `${x}`).join(" ")}`; - if (t.length <= maxLength) { + if (full || t.length <= maxLength) { return t; } return t.slice(0, maxLength - 3) + "..."; @@ -185,7 +185,7 @@ function LogWindow(props: IProps): React.ReactElement { }} > - + {title()} From 5607561c50f8f684d1833f3a8c97985ec486ad6c Mon Sep 17 00:00:00 2001 From: theit8514 Date: Sun, 26 Dec 2021 17:38:25 -0500 Subject: [PATCH 21/31] Add minimize button to log windows --- src/ui/React/LogBoxManager.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index f30c8c4a9..806b5f399 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -77,6 +77,16 @@ interface IProps { const useStyles = makeStyles((theme: Theme) => createStyles({ + title: { + "&.is-minimized + *": { + border: "none", + margin: 0, + "max-height": 0, + padding: 0, + "pointer-events": "none", + visibility: "hidden" + }, + }, logs: { overflowY: "scroll", overflowX: "hidden", @@ -107,6 +117,7 @@ function LogWindow(props: IProps): React.ReactElement { const classes = useStyles(); const container = useRef(null); const setRerender = useState(false)[1]; + const [minimized, setMinimized] = useState(false); function rerender(): void { setRerender((old) => !old); } @@ -149,6 +160,10 @@ function LogWindow(props: IProps): React.ReactElement { return t.slice(0, maxLength - 3) + "..."; } + function minimize(): void { + setMinimized(!minimized); + } + function lineClass(s: string): string { if (s.match(/(^\[[^\]]+\] )?ERROR/) || s.match(/(^\[[^\]]+\] )?FAIL/)) { return classes.error; @@ -180,6 +195,7 @@ function LogWindow(props: IProps): React.ReactElement { >
{!workerScripts.has(script.pid) && } {workerScripts.has(script.pid) && } + From e3a9f9edab35d56afa3f5eac18bbaf0303c44199 Mon Sep 17 00:00:00 2001 From: Jared Jolton <2PacIsAlive@users.noreply.github.com> Date: Sun, 26 Dec 2021 20:21:35 -0700 Subject: [PATCH 22/31] Fix "Terminal capacity" option description typo --- src/ui/React/GameOptionsRoot.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index fac1faa4c..24443de42 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -292,7 +292,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { - The maximum number of entries that can be written to a the terminal. Setting this too high can cause + The maximum number of entries that can be written to the terminal. Setting this too high can cause the game to use a lot of memory. } From 58dd450acabb8d94b42fe1adeede7afc10a9a7e0 Mon Sep 17 00:00:00 2001 From: Ash Clark Date: Mon, 27 Dec 2021 11:47:02 -0500 Subject: [PATCH 23/31] Fix two typos in `help` command text --- src/Terminal/HelpText.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Terminal/HelpText.ts b/src/Terminal/HelpText.ts index 3f143645a..e0ef5a4d0 100644 --- a/src/Terminal/HelpText.ts +++ b/src/Terminal/HelpText.ts @@ -80,7 +80,7 @@ export const HelpTexts: IMap = { " ", ], analyze: [ - "analze", + "analyze", " ", "Prints details and statistics about the current server. The information that is printed includes basic ", "server details such as the hostname, whether the player has root access, what ports are opened/closed, and also ", @@ -191,7 +191,7 @@ export const HelpTexts: IMap = { free: [ "free", " ", - "Display's the memory usage on the current machine. Print the amount of RAM that is available on the current server as well as ", + "Displays the memory usage on the current machine. Print the amount of RAM that is available on the current server as well as ", "how much of it is being used.", ], grow: [ From 33e4e310998088176b3457240ed389327adabaa9 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 28 Dec 2021 00:54:35 +0000 Subject: [PATCH 24/31] Fixes scp and mem helptext. --- src/Terminal/HelpText.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Terminal/HelpText.ts b/src/Terminal/HelpText.ts index 3f143645a..3468fe4d9 100644 --- a/src/Terminal/HelpText.ts +++ b/src/Terminal/HelpText.ts @@ -27,7 +27,7 @@ export const TerminalHelpText: string[] = [ "killall Stops all running scripts on the current machine", "ls [dir] [| grep pattern] Displays all files on the machine", "lscpu Displays the number of CPU cores on the machine", - "mem [script] [-t] [n] Displays the amount of RAM required to run the script", + "mem [script] [-t n] Displays the amount of RAM required to run the script", "mv [src] [dest] Move/rename a text or script file", "nano [file ...] Text editor - Open up and edit one or more scripts or text files", "ps Display all scripts that are currently running", @@ -35,7 +35,7 @@ export const TerminalHelpText: string[] = [ "run [name] [-t n] [--tail] [args...] Execute a program or script", "scan Prints all immediately-available network connections", "scan-analyze [d] [-a] Prints info for all servers up to d nodes away", - "scp [file] [server] Copies a file to a destination server", + "scp [file ...] [server] Copies a file to a destination server", "sudov Shows whether you have root access on this computer", "tail [script] [args...] Displays dynamic logs for the specified script", "top Displays all running scripts and their RAM usage", @@ -360,12 +360,17 @@ export const HelpTexts: IMap = { "-a flag at the end of the command if you would like to enable that.", ], scp: [ - "scp [filename] [target server]", + "scp [filename ...] [target server]", " ", - "Copies the specified file from the current server to the target server. ", - "This command only works for script files (.script extension), literature files (.lit extension), ", + "Copies the specified file(s) from the current server to the target server. ", + "This command only works for script files (.script or .js extension), literature files (.lit extension), ", "and text files (.txt extension). ", - "The second argument passed in must be the hostname or IP of the target server.", + "The second argument passed in must be the hostname or IP of the target server. Examples:", + " ", + "scp foo.script n00dles", + " ", + "scp foo.script bar.script n00dles", + " ", ], sudov: ["sudov", " ", "Prints whether or not you have root access to the current machine"], From 8aae2c9b7fd1b3bee59193009412d04ef0051499 Mon Sep 17 00:00:00 2001 From: Hedrauta Date: Tue, 28 Dec 2021 03:54:04 +0100 Subject: [PATCH 25/31] fix typo for #2206 --- src/NetscriptWorker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index 82dd53c17..c4f4f7832 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -81,7 +81,7 @@ function startNetscript2Script(workerScript: WorkerScript): Promise Date: Tue, 28 Dec 2021 02:11:41 -0500 Subject: [PATCH 26/31] Add buy all option to buy terminal command --- src/DarkWeb/DarkWeb.tsx | 32 ++++++++++++++++++++++++++++++-- src/Terminal/HelpText.ts | 4 +++- src/Terminal/commands/buy.ts | 5 ++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/DarkWeb/DarkWeb.tsx b/src/DarkWeb/DarkWeb.tsx index a165bdda0..2833d3a11 100644 --- a/src/DarkWeb/DarkWeb.tsx +++ b/src/DarkWeb/DarkWeb.tsx @@ -4,6 +4,7 @@ import { DarkWebItems } from "./DarkWebItems"; import { Player } from "../Player"; import { Terminal } from "../Terminal"; import { SpecialServers } from "../Server/data/SpecialServers"; +import { numeralWrapper } from "../ui/numeralFormat"; import { Money } from "../ui/React/Money"; import { DarkWebItem } from "./DarkWebItem"; @@ -13,8 +14,8 @@ export function checkIfConnectedToDarkweb(): void { if (server !== null && SpecialServers.DarkWeb == server.hostname) { Terminal.print( "You are now connected to the dark web. From the dark web you can purchase illegal items. " + - "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " + - "to purchase an item.", + "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name]' " + + "to purchase an item. Use the 'buy -a' command to purchase unowned all items.", ); } } @@ -87,3 +88,30 @@ export function buyDarkwebItem(itemName: string): void { "You have purchased the " + item.program + " program. The new program can be found on your home computer.", ); } + +export function buyAllDarkwebItems(): void { + const itemsToBuy: DarkWebItem[] = []; + let cost = 0; + + for (const key in DarkWebItems) { + const item = DarkWebItems[key]; + if (!Player.hasProgram(item.program)) { + itemsToBuy.push(item); + cost += item.price; + } + } + + if (itemsToBuy.length === 0) { + Terminal.print("All available programs have been purchased already."); + return; + } + + if (cost > Player.money) { + Terminal.error("Not enough money to purchase remaining programs, " + numeralWrapper.formatMoney(cost) + " required"); + return; + } + + for (const item of itemsToBuy) { + buyDarkwebItem(item.program); + } +} diff --git a/src/Terminal/HelpText.ts b/src/Terminal/HelpText.ts index 3f143645a..ebf46a1fd 100644 --- a/src/Terminal/HelpText.ts +++ b/src/Terminal/HelpText.ts @@ -96,13 +96,15 @@ export const HelpTexts: IMap = { " ", ], buy: [ - "buy [-l / program]", + "buy [-l / -a / program]", " ", "Purchase a program through the Dark Web. Requires a TOR router to use.", " ", "If this command is ran with the '-l' flag, it will display a list of all programs that can be bought through the ", "dark web to the Terminal, as well as their costs.", " ", + "If this command is ran with the '-a' flag, it will attempt to purchase all unowned programs.", + " ", "Otherwise, the name of the program must be passed in as a parameter. This name is NOT case-sensitive.", ], cat: [ diff --git a/src/Terminal/commands/buy.ts b/src/Terminal/commands/buy.ts index 8fda02b7e..56d04ddd6 100644 --- a/src/Terminal/commands/buy.ts +++ b/src/Terminal/commands/buy.ts @@ -2,7 +2,7 @@ import { ITerminal } from "../ITerminal"; import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; -import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb"; +import { listAllDarkwebItems, buyAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb"; import { SpecialServers } from "../../Server/data/SpecialServers"; import { GetServer } from "../../Server/AllServers"; @@ -22,12 +22,15 @@ export function buy( if (args.length != 1) { terminal.print("Incorrect number of arguments. Usage: "); terminal.print("buy -l"); + terminal.print("buy -a"); terminal.print("buy [item name]"); return; } const arg = args[0] + ""; if (arg == "-l" || arg == "-1" || arg == "--list") { listAllDarkwebItems(); + } else if (arg == "-a" || arg == "--all") { + buyAllDarkwebItems(); } else { buyDarkwebItem(arg); } From 8b33f72703fb848efe94c551b6106832deda78f3 Mon Sep 17 00:00:00 2001 From: Alexander Morland Date: Tue, 28 Dec 2021 11:01:22 +0100 Subject: [PATCH 27/31] Fixed typo --- markdown/bitburner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/bitburner.md b/markdown/bitburner.md index 44f735f05..962f2ee1a 100644 --- a/markdown/bitburner.md +++ b/markdown/bitburner.md @@ -18,7 +18,7 @@ | [CharacterInfo](./bitburner.characterinfo.md) | | | [CharacterMult](./bitburner.charactermult.md) | | | [CodingAttemptOptions](./bitburner.codingattemptoptions.md) | Options to affect the behavior of [CodingContract](./bitburner.codingcontract.md) attempt. | -| [CodingContract](./bitburner.codingcontract.md) | Coding Contact API | +| [CodingContract](./bitburner.codingcontract.md) | Coding Contract API | | [Corporation](./bitburner.corporation.md) | Corporation API | | [CorporationInfo](./bitburner.corporationinfo.md) | General info about a corporation | | [CrimeStats](./bitburner.crimestats.md) | Data representing the internal values of a crime. | From 26ab62eea6ebb4b1ab27360362d1aa2b9ca86fc0 Mon Sep 17 00:00:00 2001 From: Xynrati <84252507+Xynrati@users.noreply.github.com> Date: Tue, 28 Dec 2021 08:04:50 -0800 Subject: [PATCH 28/31] More comments to be removed --- src/ScriptEditor/NetscriptDefinitions.d.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 4ea848098..9a60765ed 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -5487,8 +5487,6 @@ export interface NS extends Singularity { * The required time is increased by the security level of the target server and decreased by the player's hacking level. * * @param host - Host of target server. - * @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level. - * @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5). * @returns Returns the amount of time in milliseconds it takes to execute the hack Netscript function. Returns Infinity if called on a Hacknet Server. */ getHackTime(host: string): number; @@ -5503,8 +5501,6 @@ export interface NS extends Singularity { * The required time is increased by the security level of the target server and decreased by the player's hacking level. * * @param host - Host of target server. - * @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level. - * @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5). * @returns Returns the amount of time in milliseconds it takes to execute the grow Netscript function. Returns Infinity if called on a Hacknet Server. */ getGrowTime(host: string): number; @@ -5519,8 +5515,6 @@ export interface NS extends Singularity { * The required time is increased by the security level of the target server and decreased by the player's hacking level. * * @param host - Host of target server. - * @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level. - * @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5). * @returns Returns the amount of time in milliseconds it takes to execute the grow Netscript function. Returns Infinity if called on a Hacknet Server. */ getWeakenTime(host: string): number; From f98968f8b2d2161b9248df51f390e1689873d778 Mon Sep 17 00:00:00 2001 From: Xynrati <84252507+Xynrati@users.noreply.github.com> Date: Tue, 28 Dec 2021 08:07:35 -0800 Subject: [PATCH 29/31] Update bitburner.ns.getgrowtime.md --- markdown/bitburner.ns.getgrowtime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/bitburner.ns.getgrowtime.md b/markdown/bitburner.ns.getgrowtime.md index b62e13fb4..5637cf820 100644 --- a/markdown/bitburner.ns.getgrowtime.md +++ b/markdown/bitburner.ns.getgrowtime.md @@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the grow Netscrip RAM cost: 0.05 GB -Returns the amount of time in milliseconds it takes to execute the grow Netscript function on the target server. The function takes in an optional hackLvl parameter that can be specified to see what the grow time would be at different hacking levels. +Returns the amount of time in milliseconds it takes to execute the grow Netscript function on the target server. From ab5a2a82977fa52dabb381e54ce5d845ce572ee8 Mon Sep 17 00:00:00 2001 From: Xynrati <84252507+Xynrati@users.noreply.github.com> Date: Tue, 28 Dec 2021 08:07:56 -0800 Subject: [PATCH 30/31] Update bitburner.ns.getweakentime.md --- markdown/bitburner.ns.getweakentime.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/bitburner.ns.getweakentime.md b/markdown/bitburner.ns.getweakentime.md index 8b0d8d911..06b69cb95 100644 --- a/markdown/bitburner.ns.getweakentime.md +++ b/markdown/bitburner.ns.getweakentime.md @@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the grow Netscrip RAM cost: 0.05 GB -Returns the amount of time in milliseconds it takes to execute the weaken() Netscript function on the target server. The function takes in an optional hackLvl parameter that can be specified to see what the weaken time would be at different hacking levels. +Returns the amount of time in milliseconds it takes to execute the weaken() Netscript function on the target server. From aaf1ad4ae584f129fe4d18a0d3eaefdb083a04e8 Mon Sep 17 00:00:00 2001 From: Alexander Morland Date: Tue, 28 Dec 2021 17:27:21 +0100 Subject: [PATCH 31/31] Fixed typo needed to fix docs --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 1e46e57c8..8e4044915 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2890,7 +2890,7 @@ export interface Bladeburner { } /** - * Coding Contact API + * Coding Contract API * @public */ export interface CodingContract {