Merge branch 'dev' of github.com:danielyxie/bitburner into dev

This commit is contained in:
Olivier Gagnon 2021-12-29 02:04:28 -05:00
commit 04f2cfe522
25 changed files with 200 additions and 110 deletions

@ -118,7 +118,7 @@ Inside the root of the repo run
`npm install` to install all the dependencies `npm install` to install all the dependencies
`npm run start:dev` to launch the game in dev mode. `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. Saving a file will reload the game automatically.
#### Submitting a Pull Request #### Submitting a Pull Request

@ -432,7 +432,10 @@ empty file will be created.
ps ps
^^ ^^
$ ps [-g, --grep pattern]
Prints all scripts that are currently running on the current server. Prints all scripts that are currently running on the current server.
The :code:`-g, --grep pattern` option will only output running scripts where the name matches the provided pattern.
rm rm
^^ ^^

@ -18,7 +18,7 @@
| [CharacterInfo](./bitburner.characterinfo.md) | | | [CharacterInfo](./bitburner.characterinfo.md) | |
| [CharacterMult](./bitburner.charactermult.md) | | | [CharacterMult](./bitburner.charactermult.md) | |
| [CodingAttemptOptions](./bitburner.codingattemptoptions.md) | Options to affect the behavior of [CodingContract](./bitburner.codingcontract.md) attempt. | | [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 | | [Corporation](./bitburner.corporation.md) | Corporation API |
| [CorporationInfo](./bitburner.corporationinfo.md) | General info about a corporation | | [CorporationInfo](./bitburner.corporationinfo.md) | General info about a corporation |
| [CrimeStats](./bitburner.crimestats.md) | Data representing the internal values of a crime. | | [CrimeStats](./bitburner.crimestats.md) | Data representing the internal values of a crime. |

@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the grow Netscrip
RAM cost: 0.05 GB 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.

@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the hack Netscrip
RAM cost: 0.05 GB 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.

@ -28,5 +28,5 @@ Returns the amount of time in milliseconds it takes to execute the grow Netscrip
RAM cost: 0.05 GB 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.

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"@emotion/react": "^11.4.1", "@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0", "@emotion/styled": "^11.3.0",
"@material-ui/core": "^4.12.3",
"@microsoft/api-documenter": "^7.13.65", "@microsoft/api-documenter": "^7.13.65",
"@microsoft/api-extractor": "^7.18.17", "@microsoft/api-extractor": "^7.18.17",
"@monaco-editor/react": "^4.2.2", "@monaco-editor/react": "^4.2.2",
@ -37,9 +38,11 @@
"jquery": "^3.5.0", "jquery": "^3.5.0",
"jszip": "^3.7.0", "jszip": "^3.7.0",
"material-ui-color": "^1.2.0", "material-ui-color": "^1.2.0",
"material-ui-popup-state": "^1.5.3",
"monaco-editor": "^0.27.0", "monaco-editor": "^0.27.0",
"notistack": "^2.0.2", "notistack": "^2.0.2",
"numeral": "2.0.6", "numeral": "2.0.6",
"prop-types": "^15.8.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"react": "^17.0.2", "react": "^17.0.2",
"react-beautiful-dnd": "^13.1.0", "react-beautiful-dnd": "^13.1.0",

@ -36,7 +36,7 @@ export function printAliases(): void {
// Returns true if successful, false otherwise // Returns true if successful, false otherwise
export function parseAliasDeclaration(dec: string, global = false): boolean { export function parseAliasDeclaration(dec: string, global = false): boolean {
const re = /^([\w|!|%|,|@|-]+)="(.+)"$/; const re = /^([\w|!|%|,|@|-]+)=(("(.+)")|('(.+)'))$/;
const matches = dec.match(re); const matches = dec.match(re);
if (matches == null || matches.length != 3) { if (matches == null || matches.length != 3) {
return false; return false;

@ -4,6 +4,7 @@ import { DarkWebItems } from "./DarkWebItems";
import { Player } from "../Player"; import { Player } from "../Player";
import { Terminal } from "../Terminal"; import { Terminal } from "../Terminal";
import { SpecialServers } from "../Server/data/SpecialServers"; import { SpecialServers } from "../Server/data/SpecialServers";
import { numeralWrapper } from "../ui/numeralFormat";
import { Money } from "../ui/React/Money"; import { Money } from "../ui/React/Money";
import { DarkWebItem } from "./DarkWebItem"; import { DarkWebItem } from "./DarkWebItem";
@ -13,8 +14,8 @@ export function checkIfConnectedToDarkweb(): void {
if (server !== null && SpecialServers.DarkWeb == server.hostname) { if (server !== null && SpecialServers.DarkWeb == server.hostname) {
Terminal.print( Terminal.print(
"You are now connected to the dark web. From the dark web you can purchase illegal items. " + "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] " + "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name]' " +
"to purchase an item.", "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.", "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);
}
}

@ -952,7 +952,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return runScriptFromScript("run", scriptServer, scriptname, args, workerScript, threads); return runScriptFromScript("run", scriptServer, scriptname, args, workerScript, threads);
}, },
exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any { exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any {
console.log(`${scriptname} ${hostname} ${threads} ${JSON.stringify(args)}`);
updateDynamicRam("exec", getRamCost("exec")); updateDynamicRam("exec", getRamCost("exec"));
if (scriptname === undefined || hostname === undefined) { if (scriptname === undefined || hostname === undefined) {
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");

@ -496,7 +496,7 @@ export function NetscriptCorporation(
shareSaleCooldown: corporation.shareSaleCooldown, shareSaleCooldown: corporation.shareSaleCooldown,
issuedShares: corporation.issuedShares, issuedShares: corporation.issuedShares,
sharePrice: corporation.sharePrice, sharePrice: corporation.sharePrice,
state: corporation.state + "", state: corporation.state.getState(),
}; };
}, },
}; };

@ -81,7 +81,7 @@ function startNetscript2Script(workerScript: WorkerScript): Promise<WorkerScript
if (propName === "asleep") return f(...args); // OK for multiple simultaneous calls to sleep. if (propName === "asleep") return f(...args); // OK for multiple simultaneous calls to sleep.
const msg = const msg =
"Concurrent calls to Netscript functions not allowed! " + "Concurrent calls to Netscript functions are not allowed! " +
"Did you forget to await hack(), grow(), or some other " + "Did you forget to await hack(), grow(), or some other " +
"promise-returning function? (Currently running: %s tried to run: %s)"; "promise-returning function? (Currently running: %s tried to run: %s)";
if (runningFn) { if (runningFn) {

@ -654,6 +654,8 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str
this.workRepGained *= this.cancelationPenalty(); this.workRepGained *= this.cancelationPenalty();
} }
const penaltyString = this.cancelationPenalty() === 0.5 ? "half" : "three-quarters";
const company = Companies[this.companyName]; const company = Companies[this.companyName];
company.playerReputation += this.workRepGained; company.playerReputation += this.workRepGained;
@ -665,12 +667,12 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str
<Money money={this.workMoneyGained} /> <Money money={this.workMoneyGained} />
<br /> <br />
<Reputation reputation={this.workRepGained} /> reputation for the company <br /> <Reputation reputation={this.workRepGained} /> reputation for the company <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br /> {this.workHackExpGained > 0 && <>{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br /></>}
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br /> {this.workStrExpGained > 0 && <>{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br /></>}
{numeralWrapper.formatExp(this.workDefExpGained)} defense exp <br /> {this.workDefExpGained > 0 && <>{numeralWrapper.formatExp(this.workDefExpGained)} defense exp <br /></>}
{numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp <br /> {this.workDexExpGained > 0 && <>{numeralWrapper.formatExp(this.workDexExpGained)} dexterity exp <br /></>}
{numeralWrapper.formatExp(this.workAgiExpGained)} agility exp <br /> {this.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(this.workAgiExpGained)} agility exp <br /></>}
{numeralWrapper.formatExp(this.workChaExpGained)} charisma exp {this.workChaExpGained > 0 && <>{numeralWrapper.formatExp(this.workChaExpGained)} charisma exp <br /></>}
<br /> <br />
</> </>
); );
@ -680,7 +682,7 @@ export function finishWork(this: IPlayer, cancelled: boolean, sing = false): str
<> <>
You worked a short shift of {convertTimeMsToTimeElapsedString(this.timeWorked)} <br /> You worked a short shift of {convertTimeMsToTimeElapsedString(this.timeWorked)} <br />
<br /> <br />
Since you cancelled your work early, you only gained half of the reputation you earned. <br /> Since you cancelled your work early, you only gained {penaltyString} of the reputation you earned. <br />
<br /> <br />
{content} {content}
</> </>

@ -17,6 +17,17 @@ export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress {
if (nextExperience < 0) nextExperience = 0; if (nextExperience < 0) nextExperience = 0;
const normalize = (value: number): number => ((value - baseExperience) * 100) / (nextExperience - baseExperience); 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 { return {
currentSkill, currentSkill,
@ -24,7 +35,9 @@ export function calculateSkillProgress(exp: number, mult = 1): ISkillProgress {
baseExperience, baseExperience,
experience: exp, experience: exp,
nextExperience, nextExperience,
progress: (nextExperience - baseExperience !== 0) ? normalize(exp) : 99.99 currentExperience,
remainingExperience,
progress
} }
} }
@ -34,6 +47,8 @@ export interface ISkillProgress {
baseExperience: number; baseExperience: number;
experience: number; experience: number;
nextExperience: number; nextExperience: number;
currentExperience: number;
remainingExperience: number;
progress: number; progress: number;
} }
@ -41,6 +56,7 @@ export function getEmptySkillProgress(): ISkillProgress {
return { return {
currentSkill: 0, nextSkill: 0, currentSkill: 0, nextSkill: 0,
baseExperience: 0, experience: 0, nextExperience: 0, baseExperience: 0, experience: 0, nextExperience: 0,
currentExperience: 0, remainingExperience: 0,
progress: 0, progress: 0,
}; };
} }

@ -1045,7 +1045,7 @@ export interface TIX {
getPurchaseCost(sym: string, shares: number, posType: string): number; getPurchaseCost(sym: string, shares: number, posType: string): number;
/** /**
* Calculate profit of setting stocks. * Calculate profit of selling stocks.
* @remarks * @remarks
* RAM cost: 2 GB * RAM cost: 2 GB
* Calculates and returns how much you would gain from selling a given number of shares of a stock. * Calculates and returns how much you would gain from selling a given number of shares of a stock.
@ -2890,7 +2890,7 @@ export interface Bladeburner {
} }
/** /**
* Coding Contact API * Coding Contract API
* @public * @public
*/ */
export interface CodingContract { export interface CodingContract {
@ -4690,11 +4690,12 @@ export interface NS extends Singularity {
* Kills all running scripts on the specified server. This function returns true * 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 * 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. * 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. * @param host - IP or hostname of the server on which to kill all scripts.
* @returns True if any scripts were killed, and false otherwise. * @returns True if any scripts were killed, and false otherwise.
*/ */
killall(host: string): boolean; killall(host?: string): boolean;
/** /**
* Terminates the current script immediately. * Terminates the current script immediately.
@ -5486,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. * 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 host - Host of target server.
* @param hackLvl - Optional hacking level for the calculation. Defaults to players current hacking level.
* @param intLvl - Optional intelligence level for the calculation. Defaults to players 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. * @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; getHackTime(host: string): number;
@ -5502,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. * 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 host - Host of target server.
* @param hackLvl - Optional hacking level for the calculation. Defaults to players current hacking level.
* @param intLvl - Optional intelligence level for the calculation. Defaults to players 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. * @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; getGrowTime(host: string): number;
@ -5518,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. * 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 host - Host of target server.
* @param hackLvl - Optional hacking level for the calculation. Defaults to players current hacking level.
* @param intLvl - Optional intelligence level for the calculation. Defaults to players 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. * @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; getWeakenTime(host: string): number;
@ -6127,7 +6122,7 @@ interface CorporationInfo {
issuedShares: number; issuedShares: number;
/** Price of the shares */ /** Price of the shares */
sharePrice: number; sharePrice: number;
/** State of the corporation, like PRODUCTION or EXPORT */ /** State of the corporation. Possible states are START, PURCHASE, PRODUCTION, SALE, EXPORT. */
state: string; state: string;
} }

@ -273,7 +273,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
// Alt-o - Options // Alt-o - Options
function handleShortcuts(this: Document, event: KeyboardEvent): any { function handleShortcuts(this: Document, event: KeyboardEvent): any {
if (Settings.DisableHotkeys) return; 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) { if (event.keyCode == KEY.T && event.altKey) {
event.preventDefault(); event.preventDefault();
clickTerminal(); clickTerminal();

@ -27,7 +27,7 @@ export const TerminalHelpText: string[] = [
"killall Stops all running scripts on the current machine", "killall Stops all running scripts on the current machine",
"ls [dir] [| grep pattern] Displays all files on the machine", "ls [dir] [| grep pattern] Displays all files on the machine",
"lscpu Displays the number of CPU cores 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", "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", "nano [file ...] Text editor - Open up and edit one or more scripts or text files",
"ps Display all scripts that are currently running", "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", "run [name] [-t n] [--tail] [args...] Execute a program or script",
"scan Prints all immediately-available network connections", "scan Prints all immediately-available network connections",
"scan-analyze [d] [-a] Prints info for all servers up to <i>d</i> nodes away", "scan-analyze [d] [-a] Prints info for all servers up to <i>d</i> 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", "sudov Shows whether you have root access on this computer",
"tail [script] [args...] Displays dynamic logs for the specified script", "tail [script] [args...] Displays dynamic logs for the specified script",
"top Displays all running scripts and their RAM usage", "top Displays all running scripts and their RAM usage",
@ -80,7 +80,7 @@ export const HelpTexts: IMap<string[]> = {
" ", " ",
], ],
analyze: [ analyze: [
"analze", "analyze",
" ", " ",
"Prints details and statistics about the current server. The information that is printed includes basic ", "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 ", "server details such as the hostname, whether the player has root access, what ports are opened/closed, and also ",
@ -96,13 +96,15 @@ export const HelpTexts: IMap<string[]> = {
" ", " ",
], ],
buy: [ buy: [
"buy [-l / program]", "buy [-l / -a / program]",
" ", " ",
"Purchase a program through the Dark Web. Requires a TOR router to use.", "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 ", "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.", "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.", "Otherwise, the name of the program must be passed in as a parameter. This name is NOT case-sensitive.",
], ],
cat: [ cat: [
@ -191,7 +193,7 @@ export const HelpTexts: IMap<string[]> = {
free: [ free: [
"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.", "how much of it is being used.",
], ],
grow: [ grow: [
@ -360,12 +362,17 @@ export const HelpTexts: IMap<string[]> = {
"-a flag at the end of the command if you would like to enable that.", "-a flag at the end of the command if you would like to enable that.",
], ],
scp: [ scp: [
"scp [filename] [target server]", "scp [filename ...] [target server]",
" ", " ",
"Copies the specified file from the current server to the target server. ", "Copies the specified file(s) from the current server to the target server. ",
"This command only works for script files (.script extension), literature files (.lit extension), ", "This command only works for script files (.script or .js extension), literature files (.lit extension), ",
"and text files (.txt 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"], sudov: ["sudov", " ", "Prints whether or not you have root access to the current machine"],

@ -2,7 +2,7 @@ import { ITerminal } from "../ITerminal";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer"; 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 { SpecialServers } from "../../Server/data/SpecialServers";
import { GetServer } from "../../Server/AllServers"; import { GetServer } from "../../Server/AllServers";
@ -22,12 +22,15 @@ export function buy(
if (args.length != 1) { if (args.length != 1) {
terminal.print("Incorrect number of arguments. Usage: "); terminal.print("Incorrect number of arguments. Usage: ");
terminal.print("buy -l"); terminal.print("buy -l");
terminal.print("buy -a");
terminal.print("buy [item name]"); terminal.print("buy [item name]");
return; return;
} }
const arg = args[0] + ""; const arg = args[0] + "";
if (arg == "-l" || arg == "-1" || arg == "--list") { if (arg == "-l" || arg == "-1" || arg == "--list") {
listAllDarkwebItems(); listAllDarkwebItems();
} else if (arg == "-a" || arg == "--all") {
buyAllDarkwebItems();
} else { } else {
buyDarkwebItem(arg); buyDarkwebItem(arg);
} }

@ -53,7 +53,7 @@ export function mv(
// Also, you can't convert between different file types // Also, you can't convert between different file types
if (isScriptFilename(source)) { if (isScriptFilename(source)) {
const script = srcFile as Script; const script = srcFile as Script;
if (!isScriptFilename(dest)) { if (!isScriptFilename(destPath)) {
terminal.error(`Source and destination files must have the same type`); terminal.error(`Source and destination files must have the same type`);
return; return;
} }
@ -66,7 +66,7 @@ export function mv(
if (destFile != null) { if (destFile != null) {
// Already exists, will be overwritten, so we'll delete it // Already exists, will be overwritten, so we'll delete it
const status = server.removeFile(dest); const status = server.removeFile(destPath);
if (!status.res) { if (!status.res) {
terminal.error(`Something went wrong...please contact game dev (probably a bug)`); terminal.error(`Something went wrong...please contact game dev (probably a bug)`);
return; return;

@ -2,6 +2,7 @@ import { ITerminal } from "../ITerminal";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer"; import { BaseServer } from "../../Server/BaseServer";
import * as libarg from "arg"
export function ps( export function ps(
terminal: ITerminal, terminal: ITerminal,
@ -10,16 +11,40 @@ export function ps(
server: BaseServer, server: BaseServer,
args: (string | number | boolean)[], args: (string | number | boolean)[],
): void { ): void {
if (args.length !== 0) { let flags;
terminal.error("Incorrect usage of ps command. Usage: ps"); 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; return;
} }
for (let i = 0; i < server.runningScripts.length; i++) { const pattern = flags['--grep']
const rsObj = server.runningScripts[i]; if (pattern) {
let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`; const re = new RegExp(pattern.toString())
for (let j = 0; j < rsObj.args.length; ++j) { const matching = server.runningScripts.filter((x) => re.test(x.filename))
res += " " + rsObj.args[j].toString(); 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);
}
}
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);
} }
terminal.print(res);
} }
} }

@ -350,7 +350,12 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
event.preventDefault(); event.preventDefault();
modifyInput("deletewordbefore"); modifyInput("deletewordbefore");
} }
if (event.keyCode === KEY.D && event.altKey) {
event.preventDefault();
modifyInput("deletewordafter");
}
if (event.keyCode === KEY.U && event.ctrlKey) { if (event.keyCode === KEY.U && event.ctrlKey) {
event.preventDefault(); event.preventDefault();
modifyInput("clearbefore"); modifyInput("clearbefore");
@ -360,9 +365,6 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
event.preventDefault(); event.preventDefault();
modifyInput("clearafter"); modifyInput("clearafter");
} }
// TODO AFTER THIS:
// alt + d deletes word after cursor
} }
} }

@ -292,7 +292,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
<Tooltip <Tooltip
title={ title={
<Typography> <Typography>
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. the game to use a lot of memory.
</Typography> </Typography>
} }

@ -77,6 +77,16 @@ interface IProps {
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
title: {
"&.is-minimized + *": {
border: "none",
margin: 0,
"max-height": 0,
padding: 0,
"pointer-events": "none",
visibility: "hidden"
},
},
logs: { logs: {
overflowY: "scroll", overflowY: "scroll",
overflowX: "hidden", overflowX: "hidden",
@ -107,6 +117,7 @@ function LogWindow(props: IProps): React.ReactElement {
const classes = useStyles(); const classes = useStyles();
const container = useRef<HTMLDivElement>(null); const container = useRef<HTMLDivElement>(null);
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];
const [minimized, setMinimized] = useState(false);
function rerender(): void { function rerender(): void {
setRerender((old) => !old); setRerender((old) => !old);
} }
@ -140,15 +151,19 @@ function LogWindow(props: IProps): React.ReactElement {
rerender(); rerender();
} }
function title(): string { function title(full = false): string {
const maxLength = 30; const maxLength = 30;
const t = `${script.filename} ${script.args.map((x: any): string => `${x}`).join(" ")}`; 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;
} }
return t.slice(0, maxLength - 3) + "..."; return t.slice(0, maxLength - 3) + "...";
} }
function minimize(): void {
setMinimized(!minimized);
}
function lineClass(s: string): string { function lineClass(s: string): string {
if (s.match(/(^\[[^\]]+\] )?ERROR/) || s.match(/(^\[[^\]]+\] )?FAIL/)) { if (s.match(/(^\[[^\]]+\] )?ERROR/) || s.match(/(^\[[^\]]+\] )?FAIL/)) {
return classes.error; return classes.error;
@ -180,18 +195,20 @@ function LogWindow(props: IProps): React.ReactElement {
> >
<div onMouseDown={updateLayer}> <div onMouseDown={updateLayer}>
<Paper <Paper
className={classes.title + " " + (minimized ? 'is-minimized' : '')}
style={{ style={{
cursor: "grab", cursor: "grab",
}} }}
> >
<Box className="drag" display="flex" alignItems="center"> <Box className="drag" display="flex" alignItems="center">
<Typography color="primary" variant="h6"> <Typography color="primary" variant="h6" title={title(true)}>
{title()} {title()}
</Typography> </Typography>
<Box position="absolute" right={0}> <Box position="absolute" right={0}>
{!workerScripts.has(script.pid) && <Button onClick={run}>Run</Button>} {!workerScripts.has(script.pid) && <Button onClick={run}>Run</Button>}
{workerScripts.has(script.pid) && <Button onClick={kill}>Kill</Button>} {workerScripts.has(script.pid) && <Button onClick={kill}>Kill</Button>}
<Button onClick={minimize}>{minimized ? "\u{1F5D6}" : "\u{1F5D5}"}</Button>
<Button onClick={props.onClose}>Close</Button> <Button onClick={props.onClose}>Close</Button>
</Box> </Box>
</Box> </Box>

@ -9,6 +9,7 @@ interface IProgressProps {
min: number; min: number;
max: number; max: number;
current: number; current: number;
remaining: number;
progress: number; progress: number;
color?: React.CSSProperties["color"]; color?: React.CSSProperties["color"];
} }
@ -18,14 +19,14 @@ interface IStatsOverviewCellProps {
color?: React.CSSProperties["color"]; 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 = ( const tooltip = (
<Typography sx={{ textAlign: 'right' }}> <Typography sx={{ textAlign: 'right' }}>
<strong>Progress:</strong>&nbsp; <strong>Progress:</strong>&nbsp;
{numeralWrapper.formatExp(current - min)} / {numeralWrapper.formatExp(max - min)} {numeralWrapper.formatExp(current)} / {numeralWrapper.formatExp(max - min)}
<br /> <br />
<strong>Remaining:</strong>&nbsp; <strong>Remaining:</strong>&nbsp;
{numeralWrapper.formatExp(max - current)} ({progress.toFixed(2)}%) {numeralWrapper.formatExp(remaining)} ({progress.toFixed(2)}%)
</Typography> </Typography>
); );
@ -58,7 +59,8 @@ export function StatsProgressOverviewCell({ progress: skill, color }: IStatsOver
<StatsProgressBar <StatsProgressBar
min={skill.baseExperience} min={skill.baseExperience}
max={skill.nextExperience} max={skill.nextExperience}
current={skill.experience} current={skill.currentExperience}
remaining={skill.remainingExperience}
progress={skill.progress} progress={skill.progress}
color={color} color={color}
/> />

@ -62,20 +62,14 @@ export function WorkInProgressRoot(): React.ReactElement {
<Reputation reputation={player.workRepGained} /> ( <Reputation reputation={player.workRepGained} /> (
<ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} />) reputation for this faction <br /> <ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} />) reputation for this faction <br />
<br /> <br />
{numeralWrapper.formatExp(player.workHackExpGained)} ( {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ({numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br /></>}
{numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br />
<br /> <br />
{numeralWrapper.formatExp(player.workStrExpGained)} ( {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ({numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br /></>}
{numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br /> {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ({numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGained)} ( {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ({numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp <br /> {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ({numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp <br /></>}
{numeralWrapper.formatExp(player.workDexExpGained)} (
{numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp <br />
{numeralWrapper.formatExp(player.workAgiExpGained)} (
{numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp <br />
<br /> <br />
{numeralWrapper.formatExp(player.workChaExpGained)} ( {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ({numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp <br /></>}
{numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp <br />
<br /> <br />
You will automatically finish after working for 20 hours. You can cancel earlier if you wish. You will automatically finish after working for 20 hours. You can cancel earlier if you wish.
<br /> <br />
@ -123,18 +117,12 @@ export function WorkInProgressRoot(): React.ReactElement {
<br /> <br />
<br /> <br />
You have gained: <br /> You have gained: <br />
{numeralWrapper.formatExp(player.workHackExpGained)} ( {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} ({numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br /></>}
{numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br /> {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} ({numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br /></>}
{numeralWrapper.formatExp(player.workStrExpGained)} ( {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} ({numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp <br /></>}
{numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br /> {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} ({numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGained)} ( {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} ({numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec) defense exp <br /> {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} ({numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp <br /></>}
{numeralWrapper.formatExp(player.workDexExpGained)} (
{numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec) dexterity exp <br />
{numeralWrapper.formatExp(player.workAgiExpGained)} (
{numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec) agility exp <br />
{numeralWrapper.formatExp(player.workChaExpGained)} (
{numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec) charisma exp <br />
You may cancel at any time You may cancel at any time
</Typography> </Typography>
</Grid> </Grid>
@ -185,26 +173,26 @@ export function WorkInProgressRoot(): React.ReactElement {
<Reputation reputation={player.workRepGained} /> ( <Reputation reputation={player.workRepGained} /> (
<ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} />) reputation for this company <br /> <ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} />) reputation for this company <br />
<br /> <br />
{numeralWrapper.formatExp(player.workHackExpGained)} ( {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} (
{`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`}
) hacking exp <br /> ) hacking exp <br /></>}
<br /> <br />
{numeralWrapper.formatExp(player.workStrExpGained)} ( {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} (
{`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`}
) strength exp <br /> ) strength exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGained)} ( {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} (
{`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`}
) defense exp <br /> ) defense exp <br /></>}
{numeralWrapper.formatExp(player.workDexExpGained)} ( {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} (
{`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`}
) dexterity exp <br /> ) dexterity exp <br /></>}
{numeralWrapper.formatExp(player.workAgiExpGained)} ( {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} (
{`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`}
) agility exp <br /> ) agility exp <br /></>}
<br /> <br />
{numeralWrapper.formatExp(player.workChaExpGained)} ( {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} (
{`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`}
) charisma exp <br /> ) charisma exp <br /></>}
<br /> <br />
You will automatically finish after working for 8 hours. You can cancel earlier if you wish, but you will 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. only gain {penaltyString} of the reputation you've earned so far.
@ -256,26 +244,26 @@ export function WorkInProgressRoot(): React.ReactElement {
<ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} /> <ReputationRate reputation={player.workRepGainRate * CYCLES_PER_SEC} />
) reputation for this company <br /> ) reputation for this company <br />
<br /> <br />
{numeralWrapper.formatExp(player.workHackExpGained)} ( {player.workHackExpGained > 0 && <>{numeralWrapper.formatExp(player.workHackExpGained)} (
{`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workHackExpGainRate * CYCLES_PER_SEC)} / sec`}
) hacking exp <br /> ) hacking exp <br /></>}
<br /> <br />
{numeralWrapper.formatExp(player.workStrExpGained)} ( {player.workStrExpGained > 0 && <>{numeralWrapper.formatExp(player.workStrExpGained)} (
{`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workStrExpGainRate * CYCLES_PER_SEC)} / sec`}
) strength exp <br /> ) strength exp <br /></>}
{numeralWrapper.formatExp(player.workDefExpGained)} ( {player.workDefExpGained > 0 && <>{numeralWrapper.formatExp(player.workDefExpGained)} (
{`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workDefExpGainRate * CYCLES_PER_SEC)} / sec`}
) defense exp <br /> ) defense exp <br /></>}
{numeralWrapper.formatExp(player.workDexExpGained)} ( {player.workDexExpGained > 0 && <>{numeralWrapper.formatExp(player.workDexExpGained)} (
{`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workDexExpGainRate * CYCLES_PER_SEC)} / sec`}
) dexterity exp <br /> ) dexterity exp <br /></>}
{numeralWrapper.formatExp(player.workAgiExpGained)} ( {player.workAgiExpGained > 0 && <>{numeralWrapper.formatExp(player.workAgiExpGained)} (
{`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workAgiExpGainRate * CYCLES_PER_SEC)} / sec`}
) agility exp <br /> ) agility exp <br /></>}
<br /> <br />
{numeralWrapper.formatExp(player.workChaExpGained)} ( {player.workChaExpGained > 0 && <>{numeralWrapper.formatExp(player.workChaExpGained)} (
{`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`} {`${numeralWrapper.formatExp(player.workChaExpGainRate * CYCLES_PER_SEC)} / sec`}
) charisma exp <br /> ) charisma exp <br /></>}
<br /> <br />
You will automatically finish after working for 8 hours. You can cancel earlier if you wish, and there will 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. be no penalty because this is a part-time job.