mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
commit
ddb86ebfba
@ -106,6 +106,21 @@ Fork and clone the repo
|
|||||||
# Makes sure you always start from `danielyxie/dev` to avoid merge conflicts.
|
# Makes sure you always start from `danielyxie/dev` to avoid merge conflicts.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Running locally.
|
||||||
|
|
||||||
|
Install
|
||||||
|
|
||||||
|
- `npm` (maybe via `nvm`)
|
||||||
|
- Github Desktop (windows only)
|
||||||
|
- Visual Studio code (optional)
|
||||||
|
|
||||||
|
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.
|
||||||
|
Saving a file will reload the game automatically.
|
||||||
|
|
||||||
#### Submitting a Pull Request
|
#### Submitting a Pull Request
|
||||||
|
|
||||||
When submitting a pull request with your code contributions, please abide by
|
When submitting a pull request with your code contributions, please abide by
|
||||||
|
64
dist/vendor.bundle.js
vendored
64
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
35
doc/source/netscript/advancedfunctions/inject_html.rst
Normal file
35
doc/source/netscript/advancedfunctions/inject_html.rst
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
Injecting HTML in the game
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Bitburner uses React and Material-UI to render everything. Modifying the UI is possible but
|
||||||
|
not officially supported.
|
||||||
|
|
||||||
|
To automatically enter commands in the terminal (only works if looking at the terminal):
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
// Acquire a reference to the terminal text field
|
||||||
|
const terminalInput = document.getElementById("terminal-input");
|
||||||
|
|
||||||
|
// Set the value to the command you want to run.
|
||||||
|
terminalInput.value="home;connect n00dles;home;connect n00dles;home;";
|
||||||
|
|
||||||
|
// Get a reference to the React event handler.
|
||||||
|
const handler = Object.keys(terminalInput)[1];
|
||||||
|
|
||||||
|
// Perform an onChange event to set some internal values.
|
||||||
|
terminalInput[handler].onChange({target:terminalInput});
|
||||||
|
|
||||||
|
// Simulate an enter press
|
||||||
|
terminalInput[handler].onKeyDown({keyCode:13,preventDefault:()=>null});
|
||||||
|
|
||||||
|
|
||||||
|
To add lines to the terminal (only works if looking at the terminal):
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
// Acquire a reference to the terminal list of lines.
|
||||||
|
const list = document.getElementById("generic-react-container").querySelector("ul");
|
||||||
|
|
||||||
|
// Inject some HTML.
|
||||||
|
list.insertAdjacentHTML('beforeend',`<li><p color=lime>whatever custom html</p></li>`)
|
@ -11,3 +11,5 @@ they contain spoilers for the game.
|
|||||||
getBitNodeMultipliers() <advancedfunctions/getBitNodeMultipliers>
|
getBitNodeMultipliers() <advancedfunctions/getBitNodeMultipliers>
|
||||||
getServer() <advancedfunctions/getServer>
|
getServer() <advancedfunctions/getServer>
|
||||||
autocomplete() <advancedfunctions/autocomplete>
|
autocomplete() <advancedfunctions/autocomplete>
|
||||||
|
atExit() <advancedfunctions/atExit>
|
||||||
|
Injecting HTML <advancedfunctions/inject_html.rst>
|
||||||
|
@ -17,7 +17,7 @@ getInformation() Netscript Function
|
|||||||
maxHp: max hp of the sleeve,
|
maxHp: max hp of the sleeve,
|
||||||
jobs: jobs available to the sleeve,
|
jobs: jobs available to the sleeve,
|
||||||
jobTitle: job titles available to the sleeve,
|
jobTitle: job titles available to the sleeve,
|
||||||
tor: does this sleeve have access to the tor router,
|
|
||||||
mult: {
|
mult: {
|
||||||
agility: agility multiplier,
|
agility: agility multiplier,
|
||||||
agilityExp: agility exp multiplier,
|
agilityExp: agility exp multiplier,
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -17,7 +17,6 @@
|
|||||||
"@mui/material": "^5.0.3",
|
"@mui/material": "^5.0.3",
|
||||||
"@mui/styles": "^5.0.1",
|
"@mui/styles": "^5.0.1",
|
||||||
"@types/escodegen": "^0.0.7",
|
"@types/escodegen": "^0.0.7",
|
||||||
"@types/js-beautify": "^1.13.2",
|
|
||||||
"@types/numeral": "0.0.25",
|
"@types/numeral": "0.0.25",
|
||||||
"@types/react": "^17.0.21",
|
"@types/react": "^17.0.21",
|
||||||
"@types/react-dom": "^17.0.9",
|
"@types/react-dom": "^17.0.9",
|
||||||
@ -64,7 +63,6 @@
|
|||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"http-server": "^13.0.1",
|
"http-server": "^13.0.1",
|
||||||
"jest": "^27.1.0",
|
"jest": "^27.1.0",
|
||||||
"js-beautify": "^1.5.10",
|
|
||||||
"jsdom": "^15.0.0",
|
"jsdom": "^15.0.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mini-css-extract-plugin": "^0.4.1",
|
"mini-css-extract-plugin": "^0.4.1",
|
||||||
|
@ -206,7 +206,7 @@ export class Action implements IAction {
|
|||||||
const city = inst.getCurrentCity();
|
const city = inst.getCurrentCity();
|
||||||
if (city.chaos > BladeburnerConstants.ChaosThreshold) {
|
if (city.chaos > BladeburnerConstants.ChaosThreshold) {
|
||||||
const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold);
|
const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold);
|
||||||
const mult = Math.pow(diff, 0.1);
|
const mult = Math.pow(diff, 0.5);
|
||||||
return mult;
|
return mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1513,8 +1513,12 @@ export class Bladeburner implements IBladeburner {
|
|||||||
if (this.logging.general) {
|
if (this.logging.general) {
|
||||||
this.log(`Incited violence in the synthoid communities.`);
|
this.log(`Incited violence in the synthoid communities.`);
|
||||||
}
|
}
|
||||||
const city = this.cities[this.city];
|
for (const cityName of Object.keys(this.cities)) {
|
||||||
city.chaos = (city.chaos + 100) * 2;
|
const city = this.cities[cityName];
|
||||||
|
city.chaos += 10;
|
||||||
|
city.chaos += city.chaos / (Math.log(city.chaos) / Math.log(10));
|
||||||
|
}
|
||||||
|
|
||||||
this.startAction(player, this.action);
|
this.startAction(player, this.action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ export class Operation extends Action {
|
|||||||
const city = inst.getCurrentCity();
|
const city = inst.getCurrentCity();
|
||||||
if (city.chaos > BladeburnerConstants.ChaosThreshold) {
|
if (city.chaos > BladeburnerConstants.ChaosThreshold) {
|
||||||
const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold);
|
const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold);
|
||||||
const mult = Math.pow(diff, 0.1);
|
const mult = Math.pow(diff, 0.5);
|
||||||
return mult;
|
return mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
|
|||||||
<Typography>This industry uses the following equation for it's production: </Typography>
|
<Typography>This industry uses the following equation for it's production: </Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography>
|
<Typography>
|
||||||
<IndustryProductEquation division={division} />
|
<IndustryProductEquation key={division.name} division={division} />
|
||||||
</Typography>
|
</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -13,6 +13,8 @@ import TableBody from "@mui/material/TableBody";
|
|||||||
import { Table, TableCell } from "../../ui/React/Table";
|
import { Table, TableCell } from "../../ui/React/Table";
|
||||||
import TableRow from "@mui/material/TableRow";
|
import TableRow from "@mui/material/TableRow";
|
||||||
|
|
||||||
|
export const InvitationsSeen: string[] = [];
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
player: IPlayer;
|
player: IPlayer;
|
||||||
router: IRouter;
|
router: IRouter;
|
||||||
@ -27,6 +29,14 @@ export function FactionsRoot(props: IProps): React.ReactElement {
|
|||||||
const id = setInterval(rerender, 200);
|
const id = setInterval(rerender, 200);
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
props.player.factionInvitations.forEach((faction) => {
|
||||||
|
if (InvitationsSeen.includes(faction)) return;
|
||||||
|
InvitationsSeen.push(faction);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
function openFaction(faction: Faction): void {
|
function openFaction(faction: Faction): void {
|
||||||
props.router.toFaction(faction);
|
props.router.toFaction(faction);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ import { createRandomIp } from "../utils/IPAddress";
|
|||||||
|
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface IConstructorParams {
|
interface IConstructorParams {
|
||||||
adminRights?: boolean;
|
adminRights?: boolean;
|
||||||
hostname: string;
|
hostname: string;
|
||||||
@ -93,6 +95,7 @@ export class HacknetServer extends BaseServer implements IHacknetNode {
|
|||||||
upgradeCore(levels: number, prodMult: number): void {
|
upgradeCore(levels: number, prodMult: number): void {
|
||||||
this.cores = Math.min(HacknetServerConstants.MaxCores, Math.round(this.cores + levels));
|
this.cores = Math.min(HacknetServerConstants.MaxCores, Math.round(this.cores + levels));
|
||||||
this.updateHashRate(prodMult);
|
this.updateHashRate(prodMult);
|
||||||
|
this.cpuCores=this.cores;
|
||||||
}
|
}
|
||||||
|
|
||||||
upgradeLevel(levels: number, prodMult: number): void {
|
upgradeLevel(levels: number, prodMult: number): void {
|
||||||
|
@ -21,6 +21,7 @@ import { LocationName } from "../data/LocationNames";
|
|||||||
import { use } from "../../ui/Context";
|
import { use } from "../../ui/Context";
|
||||||
|
|
||||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||||
|
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
loc: Location;
|
loc: Location;
|
||||||
@ -75,7 +76,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function renderNoodleBar(): React.ReactElement {
|
function renderNoodleBar(): React.ReactElement {
|
||||||
function EatNoodles(): void {
|
function EatNoodles(): void {
|
||||||
dialogBoxCreate(<>You ate some delicious noodles and feel refreshed.</>);
|
SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Button onClick={EatNoodles}>Eat noodles</Button>;
|
return <Button onClick={EatNoodles}>Eat noodles</Button>;
|
||||||
@ -111,7 +112,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function renderCotMG(): React.ReactElement {
|
function renderCotMG(): React.ReactElement {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const symbol = <Typography sx={{lineHeight: '1em',whiteSpace: 'pre'}}>
|
const symbol = <Typography sx={{ lineHeight: '1em', whiteSpace: 'pre' }}>
|
||||||
{" `` "}<br />
|
{" `` "}<br />
|
||||||
{" -odmmNmds: "}<br />
|
{" -odmmNmds: "}<br />
|
||||||
{" `hNmo:..-omNh. "}<br />
|
{" `hNmo:..-omNh. "}<br />
|
||||||
|
27
src/Netscript/RecentScripts.ts
Normal file
27
src/Netscript/RecentScripts.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { RunningScript } from "src/Script/RunningScript";
|
||||||
|
import { WorkerScript } from "./WorkerScript";
|
||||||
|
|
||||||
|
export const recentScripts: RecentScript[] = [];
|
||||||
|
|
||||||
|
export function AddRecentScript(workerScript: WorkerScript): void {
|
||||||
|
if (recentScripts.find((r) => r.pid === workerScript.pid)) return;
|
||||||
|
recentScripts.push({
|
||||||
|
filename: workerScript.name,
|
||||||
|
args: workerScript.args,
|
||||||
|
pid: workerScript.pid,
|
||||||
|
timestamp: new Date(),
|
||||||
|
|
||||||
|
runningScript: workerScript.scriptRef,
|
||||||
|
});
|
||||||
|
while (recentScripts.length > 50) {
|
||||||
|
recentScripts.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RecentScript {
|
||||||
|
filename: string;
|
||||||
|
args: string[];
|
||||||
|
pid: number;
|
||||||
|
timestamp: Date;
|
||||||
|
runningScript: RunningScript;
|
||||||
|
}
|
@ -11,6 +11,7 @@ import { GetServer } from "../Server/AllServers";
|
|||||||
|
|
||||||
import { compareArrays } from "../utils/helpers/compareArrays";
|
import { compareArrays } from "../utils/helpers/compareArrays";
|
||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
|
import { AddRecentScript } from "./RecentScripts";
|
||||||
|
|
||||||
export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
|
export function killWorkerScript(runningScriptObj: RunningScript, hostname: string, rerenderUi?: boolean): boolean;
|
||||||
export function killWorkerScript(workerScript: WorkerScript): boolean;
|
export function killWorkerScript(workerScript: WorkerScript): boolean;
|
||||||
@ -66,8 +67,6 @@ function killWorkerScriptByPid(pid: number, rerenderUi = true): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||||
workerScript.env.stopFlag = true;
|
|
||||||
killNetscriptDelay(workerScript);
|
|
||||||
if (typeof workerScript.atExit === "function") {
|
if (typeof workerScript.atExit === "function") {
|
||||||
try {
|
try {
|
||||||
workerScript.atExit();
|
workerScript.atExit();
|
||||||
@ -78,6 +77,8 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
|||||||
}
|
}
|
||||||
workerScript.atExit = undefined;
|
workerScript.atExit = undefined;
|
||||||
}
|
}
|
||||||
|
workerScript.env.stopFlag = true;
|
||||||
|
killNetscriptDelay(workerScript);
|
||||||
removeWorkerScript(workerScript, rerenderUi);
|
removeWorkerScript(workerScript, rerenderUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,11 +86,10 @@ function stopAndCleanUpWorkerScript(workerScript: WorkerScript, rerenderUi = tru
|
|||||||
* Helper function that removes the script being killed from the global pool.
|
* Helper function that removes the script being killed from the global pool.
|
||||||
* Also handles other cleanup-time operations
|
* Also handles other cleanup-time operations
|
||||||
*
|
*
|
||||||
* @param {WorkerScript | number} - Identifier for WorkerScript. Either the object itself, or
|
* @param {WorkerScript} - Identifier for WorkerScript. Either the object itself, or
|
||||||
* its index in the global workerScripts array
|
* its index in the global workerScripts array
|
||||||
*/
|
*/
|
||||||
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void {
|
||||||
if (workerScript instanceof WorkerScript) {
|
|
||||||
const ip = workerScript.hostname;
|
const ip = workerScript.hostname;
|
||||||
const name = workerScript.name;
|
const name = workerScript.name;
|
||||||
|
|
||||||
@ -119,15 +119,11 @@ function removeWorkerScript(workerScript: WorkerScript, rerenderUi = true): void
|
|||||||
console.warn(`removeWorkerScript() called with WorkerScript that wasn't in the global map:`);
|
console.warn(`removeWorkerScript() called with WorkerScript that wasn't in the global map:`);
|
||||||
console.warn(workerScript);
|
console.warn(workerScript);
|
||||||
}
|
}
|
||||||
|
AddRecentScript(workerScript);
|
||||||
|
|
||||||
if (rerenderUi) {
|
if (rerenderUi) {
|
||||||
WorkerScriptStartStopEventEmitter.emit();
|
WorkerScriptStartStopEventEmitter.emit();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.error(`Invalid argument passed into removeWorkerScript():`);
|
|
||||||
console.error(workerScript);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): s
|
|||||||
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
|
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "|" + server.hostname + "|" + workerScript.name + "|" + msg;
|
return "|DELIMITER|" + server.hostname + "|DELIMITER|" + workerScript.name + "|DELIMITER|" + msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveNetscriptRequestedThreads(
|
export function resolveNetscriptRequestedThreads(
|
||||||
@ -50,7 +50,7 @@ export function isScriptErrorMessage(msg: string): boolean {
|
|||||||
if (!isString(msg)) {
|
if (!isString(msg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const splitMsg = msg.split("|");
|
const splitMsg = msg.split("|DELIMITER|");
|
||||||
if (splitMsg.length != 4) {
|
if (splitMsg.length != 4) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -539,7 +539,7 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
|
|||||||
return;
|
return;
|
||||||
} else if (w instanceof WorkerScript) {
|
} else if (w instanceof WorkerScript) {
|
||||||
if (isScriptErrorMessage(w.errorMessage)) {
|
if (isScriptErrorMessage(w.errorMessage)) {
|
||||||
const errorTextArray = w.errorMessage.split("|");
|
const errorTextArray = w.errorMessage.split("|DELIMITER|");
|
||||||
if (errorTextArray.length != 4) {
|
if (errorTextArray.length != 4) {
|
||||||
console.error("ERROR: Something wrong with Error text in evaluator...");
|
console.error("ERROR: Something wrong with Error text in evaluator...");
|
||||||
console.error("Error text: " + w.errorMessage);
|
console.error("Error text: " + w.errorMessage);
|
||||||
|
@ -59,6 +59,7 @@ import { Money } from "../../ui/React/Money";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { serverMetadata } from "../../Server/data/servers";
|
import { serverMetadata } from "../../Server/data/servers";
|
||||||
|
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||||
|
|
||||||
export function init(this: IPlayer): void {
|
export function init(this: IPlayer): void {
|
||||||
/* Initialize Player's home computer */
|
/* Initialize Player's home computer */
|
||||||
@ -1697,13 +1698,7 @@ export function regenerateHp(this: IPlayer, amt: number): void {
|
|||||||
export function hospitalize(this: IPlayer): number {
|
export function hospitalize(this: IPlayer): number {
|
||||||
const cost = getHospitalizationCost(this);
|
const cost = getHospitalizationCost(this);
|
||||||
if (Settings.SuppressHospitalizationPopup === false) {
|
if (Settings.SuppressHospitalizationPopup === false) {
|
||||||
dialogBoxCreate(
|
SnackbarEvents.emit(`You've been Hospitalized for ${numeralWrapper.formatMoney(cost)}`, "warning");
|
||||||
<>
|
|
||||||
You were in critical condition! You were taken to the hospital where luckily they were able to save your life.
|
|
||||||
You were charged
|
|
||||||
<Money money={cost} />
|
|
||||||
</>,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loseMoney(cost);
|
this.loseMoney(cost);
|
||||||
|
@ -122,7 +122,7 @@ const tasks: {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
"Commit Crime": (): ITaskDetails => {
|
"Commit Crime": (): ITaskDetails => {
|
||||||
return { first: Object.keys(Crimes), second: () => ["------"] };
|
return { first: Object.values(Crimes).map((crime) => crime.name), second: () => ["------"] };
|
||||||
},
|
},
|
||||||
"Take University Course": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
|
"Take University Course": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
|
||||||
let universities: string[] = [];
|
let universities: string[] = [];
|
||||||
|
@ -27,11 +27,13 @@ import { Terminal } from "./Terminal";
|
|||||||
import { dialogBoxCreate } from "./ui/React/DialogBox";
|
import { dialogBoxCreate } from "./ui/React/DialogBox";
|
||||||
|
|
||||||
import Decimal from "decimal.js";
|
import Decimal from "decimal.js";
|
||||||
|
import { ProgramsSeen } from "./Programs/ui/ProgramsRoot";
|
||||||
|
import { InvitationsSeen } from "./Faction/ui/FactionsRoot";
|
||||||
|
|
||||||
const BitNode8StartingMoney = 250e6;
|
const BitNode8StartingMoney = 250e6;
|
||||||
|
|
||||||
// Prestige by purchasing augmentation
|
// Prestige by purchasing augmentation
|
||||||
function prestigeAugmentation(): void {
|
export function prestigeAugmentation(): void {
|
||||||
initBitNodeMultipliers(Player);
|
initBitNodeMultipliers(Player);
|
||||||
|
|
||||||
const maintainMembership = Player.factions.filter(function (faction) {
|
const maintainMembership = Player.factions.filter(function (faction) {
|
||||||
@ -138,10 +140,12 @@ function prestigeAugmentation(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetPidCounter();
|
resetPidCounter();
|
||||||
|
ProgramsSeen.splice(0, ProgramsSeen.length);
|
||||||
|
InvitationsSeen.splice(0, InvitationsSeen.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prestige by destroying Bit Node and gaining a Source File
|
// Prestige by destroying Bit Node and gaining a Source File
|
||||||
function prestigeSourceFile(flume: boolean): void {
|
export function prestigeSourceFile(flume: boolean): void {
|
||||||
initBitNodeMultipliers(Player);
|
initBitNodeMultipliers(Player);
|
||||||
updateSourceFileFlags(Player);
|
updateSourceFileFlags(Player);
|
||||||
|
|
||||||
@ -265,5 +269,3 @@ function prestigeSourceFile(flume: boolean): void {
|
|||||||
|
|
||||||
resetPidCounter();
|
resetPidCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { prestigeAugmentation, prestigeSourceFile };
|
|
||||||
|
@ -5,6 +5,8 @@ import { getAvailableCreatePrograms } from "../ProgramHelpers";
|
|||||||
import { Tooltip, Typography } from "@mui/material";
|
import { Tooltip, Typography } from "@mui/material";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
|
|
||||||
|
export const ProgramsSeen: string[] = [];
|
||||||
|
|
||||||
export function ProgramsRoot(): React.ReactElement {
|
export function ProgramsRoot(): React.ReactElement {
|
||||||
const player = use.Player();
|
const player = use.Player();
|
||||||
const router = use.Router();
|
const router = use.Router();
|
||||||
@ -13,6 +15,15 @@ export function ProgramsRoot(): React.ReactElement {
|
|||||||
setRerender((old) => !old);
|
setRerender((old) => !old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const programs = getAvailableCreatePrograms(player);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
programs.forEach((p) => {
|
||||||
|
if (ProgramsSeen.includes(p.name)) return;
|
||||||
|
ProgramsSeen.push(p.name);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(rerender, 200);
|
const id = setInterval(rerender, 200);
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
@ -27,7 +38,7 @@ export function ProgramsRoot(): React.ReactElement {
|
|||||||
time. Your progress will be saved and you can continue later.
|
time. Your progress will be saved and you can continue later.
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{getAvailableCreatePrograms(player).map((program) => {
|
{programs.map((program) => {
|
||||||
const create = program.create;
|
const create = program.create;
|
||||||
if (create === null) return <></>;
|
if (create === null) return <></>;
|
||||||
|
|
||||||
|
@ -3249,7 +3249,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
* hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.1 GB
|
* @ramCost 0.1 GB
|
||||||
* @param {string} host IP or hostname of the target server to hack.
|
* @param {string} host Hostname or IP of the target server to hack.
|
||||||
* @param {object} [opts] Optional parameters for configuring function behavior.
|
* @param {object} [opts] Optional parameters for configuring function behavior.
|
||||||
* @returns {Promise<number>} The amount of money stolen if the hack is successful, and zero otherwise.
|
* @returns {Promise<number>} The amount of money stolen if the hack is successful, and zero otherwise.
|
||||||
*/
|
*/
|
||||||
@ -3274,7 +3274,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* grow("foodnstuff", { threads: 5 }); // Only use 5 threads to grow
|
* grow("foodnstuff", { threads: 5 }); // Only use 5 threads to grow
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.15 GB
|
* @ramCost 0.15 GB
|
||||||
* @param {string} host IP or hostname of the target server to grow.
|
* @param {string} host Hostname or IP of the target server to grow.
|
||||||
* @param {object} [opts] Optional parameters for configuring function behavior.
|
* @param {object} [opts] Optional parameters for configuring function behavior.
|
||||||
* @returns {Promise<number>} The number by which the money on the server was multiplied for the growth.
|
* @returns {Promise<number>} The number by which the money on the server was multiplied for the growth.
|
||||||
*/
|
*/
|
||||||
@ -3295,7 +3295,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
* weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.15 GB
|
* @ramCost 0.15 GB
|
||||||
* @param {string} host IP or hostname of the target server to weaken.
|
* @param {string} host Hostname or IP of the target server to weaken.
|
||||||
* @param {object} [opts] Optional parameters for configuring function behavior.
|
* @param {object} [opts] Optional parameters for configuring function behavior.
|
||||||
* @returns {Promise<number>} The amount by which the target server’s security level was decreased. This is equivalent to 0.05 multiplied by the number of script threads.
|
* @returns {Promise<number>} The amount by which the target server’s security level was decreased. This is equivalent to 0.05 multiplied by the number of script threads.
|
||||||
*/
|
*/
|
||||||
@ -3316,7 +3316,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* //If this function returns 50, this means that if your next {@link hack} call is run on a script with 50 threads, it will steal $1m from the foodnstuff server.
|
* //If this function returns 50, this means that if your next {@link hack} call is run on a script with 50 threads, it will steal $1m from the foodnstuff server.
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 1 GB
|
* @ramCost 1 GB
|
||||||
* @param {string} host IP or hostname of the target server to analyze.
|
* @param {string} host Hostname or IP of the target server to analyze.
|
||||||
* @param {number} hackAmount Amount of money you want to hack from the server.
|
* @param {number} hackAmount Amount of money you want to hack from the server.
|
||||||
* @returns {number} The number of threads needed to {@link hack} the server for hackAmount money.
|
* @returns {number} The number of threads needed to {@link hack} the server for hackAmount money.
|
||||||
*/
|
*/
|
||||||
@ -3334,7 +3334,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you {@link hack} using N threads, then you will steal N% of its total money.
|
* //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you {@link hack} using N threads, then you will steal N% of its total money.
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 1 GB
|
* @ramCost 1 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
* @returns {number} The percentage of money you will steal from the target server with a single hack.
|
* @returns {number} The percentage of money you will steal from the target server with a single hack.
|
||||||
*/
|
*/
|
||||||
hackAnalyzePercent (host: Host): number;
|
hackAnalyzePercent (host: Host): number;
|
||||||
@ -3345,7 +3345,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* This returned value is in decimal form, not percentage.
|
* This returned value is in decimal form, not percentage.
|
||||||
*
|
*
|
||||||
* @ramCost 1 GB
|
* @ramCost 1 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
* @returns {number} The chance you have of successfully hacking the target server.
|
* @returns {number} The chance you have of successfully hacking the target server.
|
||||||
*/
|
*/
|
||||||
hackChance (host: Host): number;
|
hackChance (host: Host): number;
|
||||||
@ -3364,7 +3364,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* //If this returns 100, then this means you need to call {@link grow} 100 times in order to double the money (or once with 100 threads).
|
* //If this returns 100, then this means you need to call {@link grow} 100 times in order to double the money (or once with 100 threads).
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 1 GB
|
* @ramCost 1 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
* @param {number} growthAmount Multiplicative factor by which the server is grown. Decimal form..
|
* @param {number} growthAmount Multiplicative factor by which the server is grown. Decimal form..
|
||||||
* @returns {number} The amount of {@link grow} calls needed to grow the specified server by the specified amount
|
* @returns {number} The amount of {@link grow} calls needed to grow the specified server by the specified amount
|
||||||
*/
|
*/
|
||||||
@ -3462,11 +3462,11 @@ interface NS extends TIX, Singularity {
|
|||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0 GB
|
* @ramCost 0 GB
|
||||||
* @param {string} [fn] Optional. Filename of script to get logs from.
|
* @param {string} [fn] Optional. Filename of script to get logs from.
|
||||||
* @param {string} [ip] Optional. IP or hostname of the server that the script is on.
|
* @param {string} [host] Optional. Hostname or IP of the server that the script is on.
|
||||||
* @param {...string} [args] Arguments to identify which scripts to get logs for.
|
* @param {...string} [args] Arguments to identify which scripts to get logs for.
|
||||||
* @returns {string[]} Returns an string array, where each line is an element in the array. The most recently logged line is at the end of the array.
|
* @returns {string[]} Returns an string array, where each line is an element in the array. The most recently logged line is at the end of the array.
|
||||||
*/
|
*/
|
||||||
getScriptLogs (fn?: Script, ip?: Host, ...args: any[]): string[];
|
getScriptLogs (fn?: Script, host?: Host, ...args: any[]): string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a script’s logs. This is functionally the same as the tail Terminal command.
|
* Opens a script’s logs. This is functionally the same as the tail Terminal command.
|
||||||
@ -3492,10 +3492,11 @@ interface NS extends TIX, Singularity {
|
|||||||
* tail("foo.script", "foodnstuff", 1, "test");
|
* tail("foo.script", "foodnstuff", 1, "test");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0 GB
|
* @ramCost 0 GB
|
||||||
* @param {string} host IP or hostname of the server to scan.
|
* @param {string} [fn] Optional. Filename of the script being tailed. If omitted, the current script is tailed.
|
||||||
* @param {boolean} hostnames Optional boolean specifying whether the function should output hostnames (if true) or IP addresses (if false).
|
* @param {string} [host] Optional. Hostname or IP of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional.
|
||||||
|
* @param {any[]} ...args Arguments for the script being tailed.
|
||||||
*/
|
*/
|
||||||
tail (fn?: Script, ip?: Host, ...args: any[]): void;
|
tail (fn?: Script, host?: Host, ...args: any[]): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing the hostnames or IPs of all servers that are one
|
* Returns an array containing the hostnames or IPs of all servers that are one
|
||||||
@ -3503,7 +3504,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* array are strings.
|
* array are strings.
|
||||||
*
|
*
|
||||||
* @ramCost 0.2 GB
|
* @ramCost 0.2 GB
|
||||||
* @param {string} host IP or hostname of the server to scan.
|
* @param {string} host Hostname or IP of the server to scan.
|
||||||
* @param {boolean} hostnames Optional boolean specifying whether the function should output hostnames (if true) or IP addresses (if false).
|
* @param {boolean} hostnames Optional boolean specifying whether the function should output hostnames (if true) or IP addresses (if false).
|
||||||
* @returns {string[]} Returns an string of hostnames or IP.
|
* @returns {string[]} Returns an string of hostnames or IP.
|
||||||
*/
|
*/
|
||||||
@ -3517,7 +3518,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* nuke("foodnstuff");
|
* nuke("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
nuke (host: Host): void;
|
nuke (host: Host): void;
|
||||||
|
|
||||||
@ -3529,7 +3530,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* brutessh("foodnstuff");
|
* brutessh("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
brutessh (host: Host): void;
|
brutessh (host: Host): void;
|
||||||
|
|
||||||
@ -3541,7 +3542,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* ftpcrack("foodnstuff");
|
* ftpcrack("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
ftpcrack (host: Host): void;
|
ftpcrack (host: Host): void;
|
||||||
|
|
||||||
@ -3553,7 +3554,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* relaysmtp("foodnstuff");
|
* relaysmtp("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
relaysmtp (host: Host): void;
|
relaysmtp (host: Host): void;
|
||||||
|
|
||||||
@ -3565,7 +3566,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* httpworm("foodnstuff");
|
* httpworm("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
httpworm (host: Host): void;
|
httpworm (host: Host): void;
|
||||||
|
|
||||||
@ -3577,7 +3578,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* sqlinject("foodnstuff");
|
* sqlinject("foodnstuff");
|
||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.05 GB
|
* @ramCost 0.05 GB
|
||||||
* @param {string} host IP or hostname of the target server.
|
* @param {string} host Hostname or IP of the target server.
|
||||||
*/
|
*/
|
||||||
sqlinject (host: Host): void;
|
sqlinject (host: Host): void;
|
||||||
|
|
||||||
@ -3652,7 +3653,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 1.3 GB
|
* @ramCost 1.3 GB
|
||||||
* @param {string} script Filename of script to execute.
|
* @param {string} script Filename of script to execute.
|
||||||
* @param {string} host IP or hostname of the \`target server\` on which to execute the script.
|
* @param {string} host Hostname or IP of the \`target server\` on which to execute the script.
|
||||||
* @param {number} [numThreads] Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
* @param {number} [numThreads] Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
||||||
* @param {...string} [args] Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument numThreads must be filled in with a value.
|
* @param {...string} [args] Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument numThreads must be filled in with a value.
|
||||||
* @returns {number} Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns {number} Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
@ -3707,7 +3708,7 @@ interface NS extends TIX, Singularity {
|
|||||||
* \`\`\`
|
* \`\`\`
|
||||||
* @ramCost 0.5 GB
|
* @ramCost 0.5 GB
|
||||||
* @param {string} script Filename of the script to kill
|
* @param {string} script Filename of the script to kill
|
||||||
* @param {string} host IP or hostname of the server on which to kill the script.
|
* @param {string} host Hostname or IP of the server on which to kill the script.
|
||||||
* @param {...string} [args] Arguments to identify which script to kill.
|
* @param {...string} [args] Arguments to identify which script to kill.
|
||||||
* @returns {boolean} True if the script is successfully killed, and false otherwise.
|
* @returns {boolean} True if the script is successfully killed, and false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -3890,6 +3891,16 @@ interface NS extends TIX, Singularity {
|
|||||||
*/
|
*/
|
||||||
getHacknetMultipliers (): HacknetMultipliers;
|
getHacknetMultipliers (): HacknetMultipliers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a server object for the given server. Defaults to the running script's server if host is not specified.
|
||||||
|
*
|
||||||
|
* @ramCost 2 GB
|
||||||
|
* @param {string} [host] Optional. Hostname or IP for the requested server object.
|
||||||
|
* @returns {Server} The requested server object.
|
||||||
|
*/
|
||||||
|
getServer (host?: Host): Server;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of money available on a server.
|
* Returns the amount of money available on a server.
|
||||||
* Running this function on the home computer will return the player’s money.
|
* Running this function on the home computer will return the player’s money.
|
||||||
@ -4128,10 +4139,10 @@ interface NS extends TIX, Singularity {
|
|||||||
* Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
* Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
||||||
*
|
*
|
||||||
* @ramCost 2.25 GB
|
* @ramCost 2.25 GB
|
||||||
* @param {boolean} hostname Specifies whether hostnames or IP addresses should be returned. If it’s true then hostnames will be returned, and if false then IPs will be returned. If this argument is omitted then it is true by default.
|
* @param {boolean} [hostnameMode]. Optional. Defaults to true. Returns hostnames if true, and IPs if false.
|
||||||
* @returns {string[]} Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
* @returns {string[]} Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
||||||
*/
|
*/
|
||||||
getPurchasedServers (hostname?: boolean): Host[];
|
getPurchasedServers (hostnameMode?: boolean): Host[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of servers you can purchase.
|
* Returns the maximum number of servers you can purchase.
|
||||||
|
@ -41,10 +41,12 @@ export function OptionsModal(props: IProps): React.ReactElement {
|
|||||||
<Modal open={props.open} onClose={props.onClose}>
|
<Modal open={props.open} onClose={props.onClose}>
|
||||||
<Box display="flex" flexDirection="row" alignItems="center">
|
<Box display="flex" flexDirection="row" alignItems="center">
|
||||||
<Typography>Theme: </Typography>
|
<Typography>Theme: </Typography>
|
||||||
<Select onChange={(event) => setTheme(event.target.value)} defaultValue={props.options.theme}>
|
<Select onChange={(event) => setTheme(event.target.value)} value={theme}>
|
||||||
<MenuItem value="vs-dark">dark</MenuItem>
|
<MenuItem value="vs-dark">dark</MenuItem>
|
||||||
<MenuItem value="light">light</MenuItem>
|
<MenuItem value="light">light</MenuItem>
|
||||||
<MenuItem value="monokai">monokai</MenuItem>
|
<MenuItem value="monokai">monokai</MenuItem>
|
||||||
|
<MenuItem value="solarized-dark">solarized-dark</MenuItem>
|
||||||
|
<MenuItem value="solarized-light">solarized-light</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import * as monaco from "monaco-editor";
|
|||||||
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
|
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
|
||||||
import { OptionsModal } from "./OptionsModal";
|
import { OptionsModal } from "./OptionsModal";
|
||||||
import { Options } from "./Options";
|
import { Options } from "./Options";
|
||||||
import { js_beautify as beautifyCode } from "js-beautify";
|
|
||||||
import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
|
import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { IRouter } from "../../ui/Router";
|
import { IRouter } from "../../ui/Router";
|
||||||
@ -217,12 +216,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function beautify(): void {
|
function beautify(): void {
|
||||||
if (editorRef.current === null) return;
|
if (editorRef.current === null) return;
|
||||||
const pretty = beautifyCode(code, {
|
editorRef.current.getAction("editor.action.formatDocument").run();
|
||||||
indent_with_tabs: !options.insertSpaces,
|
|
||||||
indent_size: 4,
|
|
||||||
brace_style: "preserve-inline",
|
|
||||||
});
|
|
||||||
editorRef.current.setValue(pretty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFilenameChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
function onFilenameChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||||
|
@ -63,4 +63,159 @@ export async function loadThemes(monaco: { editor: any }): Promise<void> {
|
|||||||
"editor.selectionHighlightBorder": "#222218",
|
"editor.selectionHighlightBorder": "#222218",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
monaco.editor.defineTheme("solarish-dark", {
|
||||||
|
base: "vs-dark",
|
||||||
|
inherit: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
background: "002b36",
|
||||||
|
token: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "586e75",
|
||||||
|
token: "comment",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "00afaf",
|
||||||
|
token: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "number",
|
||||||
|
foreground: "00afaf",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "otherkeyvars",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "268bd2",
|
||||||
|
token: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "859900",
|
||||||
|
token: "keyword",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "storage.type.function.js",
|
||||||
|
foreground: "cb4b16",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "ns",
|
||||||
|
foreground: "cb4b16",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "netscriptfunction",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "otherkeywords",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "type.identifier.js",
|
||||||
|
foreground: "b58900",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "delimiter.square.js",
|
||||||
|
foreground: "0087ff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "delimiter.bracket.js",
|
||||||
|
foreground: "0087ff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "this",
|
||||||
|
foreground: "cb4b16",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
colors: {
|
||||||
|
"editor.foreground": "#839496",
|
||||||
|
"editor.background": "#002b36",
|
||||||
|
"editor.selectionBackground": "#073642",
|
||||||
|
"editor.lineHighlightBackground": "#073642",
|
||||||
|
"editorCursor.foreground": "#819090",
|
||||||
|
"editorWhitespace.foreground": "#073642",
|
||||||
|
"editorIndentGuide.activeBackground": "#9D550FB0",
|
||||||
|
"editor.selectionHighlightBorder": "#222218",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
monaco.editor.defineTheme("solarish-light", {
|
||||||
|
base: "vs",
|
||||||
|
inherit: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
foreground: "657b83",
|
||||||
|
background: "fdf6e3",
|
||||||
|
token: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "586e75",
|
||||||
|
token: "comment",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "2aa198",
|
||||||
|
token: "string",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "number",
|
||||||
|
foreground: "2aa198",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "otherkeyvars",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "268bd2",
|
||||||
|
token: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
foreground: "859900",
|
||||||
|
token: "keyword",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "storage.type.function.js",
|
||||||
|
foreground: "bc4b16",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "ns",
|
||||||
|
foreground: "cb4b16",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "netscriptfunction",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "otherkeywords",
|
||||||
|
foreground: "268bd2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "type.identifier.js",
|
||||||
|
foreground: "b58900",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "delimiter.square.js",
|
||||||
|
foreground: "0087ff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "delimiter.bracket.js",
|
||||||
|
foreground: "0087ff",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
token: "this",
|
||||||
|
foreground: "cb4b16",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
colors: {
|
||||||
|
"editor.foreground": "#657b83",
|
||||||
|
"editor.background": "#fdf6e3",
|
||||||
|
"editor.selectionBackground": "#eee8d5",
|
||||||
|
"editor.lineHighlightBackground": "#eee8d5",
|
||||||
|
"editorCursor.foreground": "#657b83",
|
||||||
|
"editorWhitespace.foreground": "#eee8d5",
|
||||||
|
"editorIndentGuide.activeBackground": "#eee8d5",
|
||||||
|
"editor.selectionHighlightBorder": "#073642",
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ import { Settings } from "../../Settings/Settings";
|
|||||||
import { redPillFlag } from "../../RedPill";
|
import { redPillFlag } from "../../RedPill";
|
||||||
|
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEY } from "../../utils/helpers/keyCodes";
|
||||||
|
import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot";
|
||||||
|
import { InvitationsSeen } from "../../Faction/ui/FactionsRoot";
|
||||||
|
|
||||||
const openedMixin = (theme: Theme): CSSObject => ({
|
const openedMixin = (theme: Theme): CSSObject => ({
|
||||||
width: theme.spacing(31),
|
width: theme.spacing(31),
|
||||||
@ -133,8 +135,8 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
|||||||
const flashTutorial = ITutorial.currStep === iTutorialSteps.WorldDescription;
|
const flashTutorial = ITutorial.currStep === iTutorialSteps.WorldDescription;
|
||||||
|
|
||||||
const augmentationCount = props.player.queuedAugmentations.length;
|
const augmentationCount = props.player.queuedAugmentations.length;
|
||||||
const invitationsCount = props.player.factionInvitations.length;
|
const invitationsCount = props.player.factionInvitations.length - InvitationsSeen.length;
|
||||||
const programCount = getAvailableCreatePrograms(props.player).length;
|
const programCount = getAvailableCreatePrograms(props.player).length - ProgramsSeen.length;
|
||||||
const canCreateProgram =
|
const canCreateProgram =
|
||||||
programCount > 0 ||
|
programCount > 0 ||
|
||||||
props.player.augmentations.length > 0 ||
|
props.player.augmentations.length > 0 ||
|
||||||
|
31
src/ui/ActiveScripts/ActiveScriptsPage.tsx
Normal file
31
src/ui/ActiveScripts/ActiveScriptsPage.tsx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Root React Component for the "Active Scripts" UI page. This page displays
|
||||||
|
* and provides information about all of the player's scripts that are currently running
|
||||||
|
*/
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { ScriptProduction } from "./ScriptProduction";
|
||||||
|
import { ServerAccordions } from "./ServerAccordions";
|
||||||
|
|
||||||
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
|
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
workerScripts: Map<number, WorkerScript>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ActiveScriptsPage(props: IProps): React.ReactElement {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Typography>
|
||||||
|
This page displays a list of all of your scripts that are currently running across every machine. It also
|
||||||
|
provides information about each script's production. The scripts are categorized by the hostname of the servers
|
||||||
|
on which they are running.
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<ScriptProduction />
|
||||||
|
<ServerAccordions {...props} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -3,17 +3,16 @@
|
|||||||
* and provides information about all of the player's scripts that are currently running
|
* and provides information about all of the player's scripts that are currently running
|
||||||
*/
|
*/
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
import Tabs from "@mui/material/Tabs";
|
||||||
|
import Tab from "@mui/material/Tab";
|
||||||
|
|
||||||
import { ScriptProduction } from "./ScriptProduction";
|
import { ActiveScriptsPage } from "./ActiveScriptsPage";
|
||||||
import { ServerAccordions } from "./ServerAccordions";
|
import { RecentScriptsPage } from "./RecentScriptsPage";
|
||||||
|
|
||||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
interface IProps {
|
||||||
|
|
||||||
type IProps = {
|
|
||||||
workerScripts: Map<number, WorkerScript>;
|
workerScripts: Map<number, WorkerScript>;
|
||||||
};
|
}
|
||||||
|
|
||||||
export function ActiveScriptsRoot(props: IProps): React.ReactElement {
|
export function ActiveScriptsRoot(props: IProps): React.ReactElement {
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
@ -26,17 +25,19 @@ export function ActiveScriptsRoot(props: IProps): React.ReactElement {
|
|||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [tab, setTab] = useState<"active" | "recent">("active");
|
||||||
|
function handleChange(event: React.SyntheticEvent, tab: "active" | "recent"): void {
|
||||||
|
setTab(tab);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Typography variant="h4">Active Scripts</Typography>
|
<Tabs variant="fullWidth" value={tab} onChange={handleChange}>
|
||||||
<Typography>
|
<Tab label={"Active"} value={"active"} />
|
||||||
This page displays a list of all of your scripts that are currently running across every machine. It also
|
<Tab label={"Recent"} value={"recent"} />
|
||||||
provides information about each script's production. The scripts are categorized by the hostname of the servers
|
</Tabs>
|
||||||
on which they are running.
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<ScriptProduction />
|
{tab === "active" && <ActiveScriptsPage workerScripts={props.workerScripts} />}
|
||||||
<ServerAccordions {...props} />
|
{tab === "recent" && <RecentScriptsPage />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
165
src/ui/ActiveScripts/RecentScriptAccordion.tsx
Normal file
165
src/ui/ActiveScripts/RecentScriptAccordion.tsx
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
/**
|
||||||
|
* React Component for displaying a single WorkerScript's info as an
|
||||||
|
* Accordion element
|
||||||
|
*/
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
import { numeralWrapper } from "../numeralFormat";
|
||||||
|
|
||||||
|
import Table from "@mui/material/Table";
|
||||||
|
import TableCell from "@mui/material/TableCell";
|
||||||
|
import TableRow from "@mui/material/TableRow";
|
||||||
|
import TableBody from "@mui/material/TableBody";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import ListItemButton from "@mui/material/ListItemButton";
|
||||||
|
import ListItemText from "@mui/material/ListItemText";
|
||||||
|
import makeStyles from "@mui/styles/makeStyles";
|
||||||
|
|
||||||
|
import Collapse from "@mui/material/Collapse";
|
||||||
|
import ExpandLess from "@mui/icons-material/ExpandLess";
|
||||||
|
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||||
|
|
||||||
|
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
|
||||||
|
import { arrayToString } from "../../utils/helpers/arrayToString";
|
||||||
|
import { Money } from "../React/Money";
|
||||||
|
import { MoneyRate } from "../React/MoneyRate";
|
||||||
|
import { RecentScript } from "../..//Netscript/RecentScripts";
|
||||||
|
import { LogBoxEvents } from "../React/LogBoxManager";
|
||||||
|
|
||||||
|
const useStyles = makeStyles({
|
||||||
|
noborder: {
|
||||||
|
borderBottom: "none",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
recentScript: RecentScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RecentScriptAccordion(props: IProps): React.ReactElement {
|
||||||
|
const classes = useStyles();
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
const recentScript = props.recentScript;
|
||||||
|
|
||||||
|
// Calculations for script stats
|
||||||
|
const onlineMps = recentScript.runningScript.onlineMoneyMade / recentScript.runningScript.onlineRunningTime;
|
||||||
|
const onlineEps = recentScript.runningScript.onlineExpGained / recentScript.runningScript.onlineRunningTime;
|
||||||
|
|
||||||
|
function logClickHandler(): void {
|
||||||
|
LogBoxEvents.emit(recentScript.runningScript);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ListItemButton onClick={() => setOpen((old) => !old)} component={Paper}>
|
||||||
|
<ListItemText
|
||||||
|
primary={
|
||||||
|
<Typography>
|
||||||
|
└ {recentScript.filename} (died{" "}
|
||||||
|
{convertTimeMsToTimeElapsedString(new Date().getTime() - recentScript.timestamp.getTime())} ago)
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{open ? <ExpandLess color="primary" /> : <ExpandMore color="primary" />}
|
||||||
|
</ListItemButton>
|
||||||
|
<Collapse in={open} timeout={0} unmountOnExit>
|
||||||
|
<Box mx={6}>
|
||||||
|
<Table padding="none" size="small">
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Threads:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>{numeralWrapper.formatThreads(recentScript.runningScript.threads)}</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder} colSpan={2}>
|
||||||
|
<Typography>└ Args: {arrayToString(recentScript.args)}</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Online Time:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>
|
||||||
|
{convertTimeMsToTimeElapsedString(recentScript.runningScript.onlineRunningTime * 1e3)}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Offline Time:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>
|
||||||
|
{convertTimeMsToTimeElapsedString(recentScript.runningScript.offlineRunningTime * 1e3)}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Total online production:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography>
|
||||||
|
<Money money={recentScript.runningScript.onlineMoneyMade} />
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder} colSpan={1} />
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography>
|
||||||
|
{numeralWrapper.formatExp(recentScript.runningScript.onlineExpGained) + " hacking exp"}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Online production rate:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography>
|
||||||
|
<MoneyRate money={onlineMps} />
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder} colSpan={1} />
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography> {numeralWrapper.formatExp(onlineEps) + " hacking exp / sec"}</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder}>
|
||||||
|
<Typography>└ Total offline production:</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography>
|
||||||
|
<Money money={recentScript.runningScript.offlineMoneyMade} />
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell className={classes.noborder} colSpan={1} />
|
||||||
|
<TableCell className={classes.noborder} align="left">
|
||||||
|
<Typography>
|
||||||
|
{numeralWrapper.formatExp(recentScript.runningScript.offlineExpGained) + " hacking exp"}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
<Button onClick={logClickHandler}>LOG</Button>
|
||||||
|
</Box>
|
||||||
|
</Collapse>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
20
src/ui/ActiveScripts/RecentScriptsPage.tsx
Normal file
20
src/ui/ActiveScripts/RecentScriptsPage.tsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Root React Component for the "Active Scripts" UI page. This page displays
|
||||||
|
* and provides information about all of the player's scripts that are currently running
|
||||||
|
*/
|
||||||
|
import React from "react";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
|
import { recentScripts } from "../../Netscript/RecentScripts";
|
||||||
|
import { RecentScriptAccordion } from "./RecentScriptAccordion";
|
||||||
|
|
||||||
|
export function RecentScriptsPage(): React.ReactElement {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Typography>List of all recently killed scripts.</Typography>
|
||||||
|
{recentScripts.map((r) => (
|
||||||
|
<RecentScriptAccordion key={r.pid} recentScript={r} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -302,7 +302,7 @@ export function refreshTheme(): void {
|
|||||||
border: "1px solid " + Settings.theme.well,
|
border: "1px solid " + Settings.theme.well,
|
||||||
},
|
},
|
||||||
standardSuccess: {
|
standardSuccess: {
|
||||||
color: Settings.theme.primaryLight,
|
color: Settings.theme.primarylight,
|
||||||
},
|
},
|
||||||
standardError: {
|
standardError: {
|
||||||
color: Settings.theme.errorlight,
|
color: Settings.theme.errorlight,
|
||||||
|
@ -222,7 +222,7 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
if (player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
if (player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
player.finishWork(true);
|
player.finishWorkPartTime(true);
|
||||||
router.toJob();
|
router.toJob();
|
||||||
}
|
}
|
||||||
function unfocus(): void {
|
function unfocus(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user