Merge pull request #2691 from danielyxie/dev

v1.4
This commit is contained in:
hydroflame 2022-01-18 15:33:10 -05:00 committed by GitHub
commit b636b07416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
110 changed files with 1126 additions and 512 deletions

@ -51,5 +51,5 @@ jobs:
cache: 'npm' cache: 'npm'
- name: Install npm dependencies - name: Install npm dependencies
run: npm ci run: npm ci
- name: Run linter - name: Run tests
run: npm run test run: npm run test

63
dist/bitburner.d.ts vendored

@ -1093,6 +1093,16 @@ export declare interface Fragment {
limit: number; limit: number;
} }
/**
* Game Information
* @internal
*/
export declare interface GameInfo {
version: string;
commit: string;
platform: string;
}
/** /**
* Gang API * Gang API
* @remarks * @remarks
@ -3442,9 +3452,9 @@ export declare interface NS extends Singularity {
* @remarks * @remarks
* RAM cost: 0.1 GB * RAM cost: 0.1 GB
* *
* Returns the servers instrinsic growth parameter. This growth * Returns the servers intrinsic growth parameter. This growth
* parameter is a number between 0 and 100 that represents how * parameter is a number typically between 0 and 100 that represents
* quickly the servers money grows. This parameter affects the * how quickly the servers money grows. This parameter affects the
* percentage by which the servers money is increased when using the * percentage by which the servers money is increased when using the
* grow function. A higher growth parameter will result in a * grow function. A higher growth parameter will result in a
* higher percentage increase from grow. * higher percentage increase from grow.
@ -4333,6 +4343,20 @@ export declare interface NS extends Singularity {
* ``` * ```
*/ */
flags(schema: [string, string | number | boolean | string[]][]): any; flags(schema: [string, string | number | boolean | string[]][]): any;
/**
* Share your computer with your factions. Increasing your rep gain for a short duration.
* @remarks
* RAM cost: 2.4 GB
*/
share(): Promise<void>;
/**
* Calculate your share power.
* @remarks
* RAM cost: 0.2 GB
*/
getSharePower(): number;
} }
/** /**
@ -5827,7 +5851,7 @@ export declare interface Stanek {
/** /**
* List possible fragments. * List possible fragments.
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns List of possible fragments. * @returns List of possible fragments.
*/ */
@ -5836,7 +5860,7 @@ export declare interface Stanek {
/** /**
* List of fragments in Stanek's Gift. * List of fragments in Stanek's Gift.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @returns List of active fragments placed on Stanek's Gift. * @returns List of active fragments placed on Stanek's Gift.
*/ */
@ -5845,14 +5869,14 @@ export declare interface Stanek {
/** /**
* Clear the board of all fragments. * Clear the board of all fragments.
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
clear(): void; clear(): void;
/** /**
* Check if fragment can be placed at specified location. * Check if fragment can be placed at specified location.
* @remarks * @remarks
* RAM cost: cost: 0.5 GB * RAM cost: 0.5 GB
* *
* @param rootX - rootX Root X against which to align the top left of the fragment. * @param rootX - rootX Root X against which to align the top left of the fragment.
* @param rootY - rootY Root Y against which to align the top left of the fragment. * @param rootY - rootY Root Y against which to align the top left of the fragment.
@ -5864,7 +5888,7 @@ export declare interface Stanek {
/** /**
* Place fragment on Stanek's Gift. * Place fragment on Stanek's Gift.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -5876,7 +5900,7 @@ export declare interface Stanek {
/** /**
* Get placed fragment at location. * Get placed fragment at location.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -5887,7 +5911,7 @@ export declare interface Stanek {
/** /**
* Remove fragment at location. * Remove fragment at location.
* @remarks * @remarks
* RAM cost: cost: 0.15 GB * RAM cost: 0.15 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -6292,7 +6316,7 @@ export declare interface UserInterface {
/** /**
* Get the current theme * Get the current theme
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns An object containing the theme's colors * @returns An object containing the theme's colors
*/ */
@ -6301,7 +6325,7 @@ export declare interface UserInterface {
/** /**
* Sets the current theme * Sets the current theme
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* @example * @example
* Usage example (NS2) * Usage example (NS2)
* ```ts * ```ts
@ -6315,14 +6339,14 @@ export declare interface UserInterface {
/** /**
* Resets the player's theme to the default values * Resets the player's theme to the default values
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
resetTheme(): void; resetTheme(): void;
/** /**
* Get the current styles * Get the current styles
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns An object containing the player's styles * @returns An object containing the player's styles
*/ */
@ -6331,7 +6355,7 @@ export declare interface UserInterface {
/** /**
* Sets the current styles * Sets the current styles
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* @example * @example
* Usage example (NS2) * Usage example (NS2)
* ```ts * ```ts
@ -6345,9 +6369,16 @@ export declare interface UserInterface {
/** /**
* Resets the player's styles to the default values * Resets the player's styles to the default values
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
resetStyles(): void; resetStyles(): void;
/**
* Gets the current game information (version, commit, ...)
* @remarks
* RAM cost: 0 GB
*/
getGameInfo(): GameInfo;
} }
/** /**

36
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -17315,7 +17315,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!NS#getServerGrowth:member(1)", "canonicalReference": "bitburner!NS#getServerGrowth:member(1)",
"docComment": "/**\n * Get a server growth parameter.\n *\n * @remarks\n *\n * RAM cost: 0.1 GB\n *\n * Returns the servers instrinsic “growth parameter”. This growth parameter is a number between 0 and 100 that represents how quickly the servers money grows. This parameter affects the percentage by which the servers money is increased when using the grow function. A higher growth parameter will result in a higher percentage increase from grow.\n *\n * @param host - Host of target server.\n *\n * @returns Parameter that affects the percentage by which the servers money is increased when using the grow function.\n */\n", "docComment": "/**\n * Get a server growth parameter.\n *\n * @remarks\n *\n * RAM cost: 0.1 GB\n *\n * Returns the servers intrinsic “growth parameter”. This growth parameter is a number typically between 0 and 100 that represents how quickly the servers money grows. This parameter affects the percentage by which the servers money is increased when using the grow function. A higher growth parameter will result in a higher percentage increase from grow.\n *\n * @param host - Host of target server.\n *\n * @returns Parameter that affects the percentage by which the servers money is increased when using the grow function.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -17752,6 +17752,34 @@
], ],
"name": "getServerUsedRam" "name": "getServerUsedRam"
}, },
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#getSharePower:member(1)",
"docComment": "/**\n * Calculate your share power.\n *\n * @remarks\n *\n * RAM cost: 0.2 GB\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "getSharePower(): "
},
{
"kind": "Content",
"text": "number"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "getSharePower"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!NS#getTimeSinceLastAug:member(1)", "canonicalReference": "bitburner!NS#getTimeSinceLastAug:member(1)",
@ -19759,6 +19787,39 @@
], ],
"name": "serverExists" "name": "serverExists"
}, },
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!NS#share:member(1)",
"docComment": "/**\n * Share your computer with your factions. Increasing your rep gain for a short duration.\n *\n * @remarks\n *\n * RAM cost: 2.4 GB\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "share(): "
},
{
"kind": "Reference",
"text": "Promise",
"canonicalReference": "!Promise:interface"
},
{
"kind": "Content",
"text": "<void>"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 3
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "share"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!NS#sleep:member(1)", "canonicalReference": "bitburner!NS#sleep:member(1)",
@ -29586,7 +29647,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#activeFragments:member(1)", "canonicalReference": "bitburner!Stanek#activeFragments:member(1)",
"docComment": "/**\n * List of fragments in Stanek's Gift.\n *\n * @remarks\n *\n * RAM cost: cost: 5 GB\n *\n * @returns List of active fragments placed on Stanek's Gift.\n */\n", "docComment": "/**\n * List of fragments in Stanek's Gift.\n *\n * @remarks\n *\n * RAM cost: 5 GB\n *\n * @returns List of active fragments placed on Stanek's Gift.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -29619,7 +29680,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#canPlace:member(1)", "canonicalReference": "bitburner!Stanek#canPlace:member(1)",
"docComment": "/**\n * Check if fragment can be placed at specified location.\n *\n * @remarks\n *\n * RAM cost: cost: 0.5 GB\n *\n * @param rootX - rootX Root X against which to align the top left of the fragment.\n *\n * @param rootY - rootY Root Y against which to align the top left of the fragment.\n *\n * @param rotation - rotation A number from 0 to 3, the mount of 90 degree turn to take.\n *\n * @param fragmentId - fragmentId ID of the fragment to place.\n *\n * @returns true if the fragment can be placed at that position. false otherwise.\n */\n", "docComment": "/**\n * Check if fragment can be placed at specified location.\n *\n * @remarks\n *\n * RAM cost: 0.5 GB\n *\n * @param rootX - rootX Root X against which to align the top left of the fragment.\n *\n * @param rootY - rootY Root Y against which to align the top left of the fragment.\n *\n * @param rotation - rotation A number from 0 to 3, the mount of 90 degree turn to take.\n *\n * @param fragmentId - fragmentId ID of the fragment to place.\n *\n * @returns true if the fragment can be placed at that position. false otherwise.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -29772,7 +29833,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#clear:member(1)", "canonicalReference": "bitburner!Stanek#clear:member(1)",
"docComment": "/**\n * Clear the board of all fragments.\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n */\n", "docComment": "/**\n * Clear the board of all fragments.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -29800,7 +29861,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#fragmentDefinitions:member(1)", "canonicalReference": "bitburner!Stanek#fragmentDefinitions:member(1)",
"docComment": "/**\n * List possible fragments.\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n *\n * @returns List of possible fragments.\n */\n", "docComment": "/**\n * List possible fragments.\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * @returns List of possible fragments.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -29833,7 +29894,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#get:member(1)", "canonicalReference": "bitburner!Stanek#get:member(1)",
"docComment": "/**\n * Get placed fragment at location.\n *\n * @remarks\n *\n * RAM cost: cost: 5 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @returns The fragment at [rootX, rootY], if any.\n */\n", "docComment": "/**\n * Get placed fragment at location.\n *\n * @remarks\n *\n * RAM cost: 5 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @returns The fragment at [rootX, rootY], if any.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -29925,7 +29986,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#place:member(1)", "canonicalReference": "bitburner!Stanek#place:member(1)",
"docComment": "/**\n * Place fragment on Stanek's Gift.\n *\n * @remarks\n *\n * RAM cost: cost: 5 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @param rotation - A number from 0 to 3, the mount of 90 degree turn to take.\n *\n * @param fragmentId - ID of the fragment to place.\n *\n * @returns true if the fragment can be placed at that position. false otherwise.\n */\n", "docComment": "/**\n * Place fragment on Stanek's Gift.\n *\n * @remarks\n *\n * RAM cost: 5 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @param rotation - A number from 0 to 3, the mount of 90 degree turn to take.\n *\n * @param fragmentId - ID of the fragment to place.\n *\n * @returns true if the fragment can be placed at that position. false otherwise.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -30014,7 +30075,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Stanek#remove:member(1)", "canonicalReference": "bitburner!Stanek#remove:member(1)",
"docComment": "/**\n * Remove fragment at location.\n *\n * @remarks\n *\n * RAM cost: cost: 0.15 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @returns The fragment at [rootX, rootY], if any.\n */\n", "docComment": "/**\n * Remove fragment at location.\n *\n * @remarks\n *\n * RAM cost: 0.15 GB\n *\n * @param rootX - X against which to align the top left of the fragment.\n *\n * @param rootY - Y against which to align the top left of the fragment.\n *\n * @returns The fragment at [rootX, rootY], if any.\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31328,10 +31389,39 @@
"releaseTag": "Public", "releaseTag": "Public",
"name": "UserInterface", "name": "UserInterface",
"members": [ "members": [
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#getGameInfo:member(1)",
"docComment": "/**\n * Gets the current game information (version, commit, ...)\n *\n * @remarks\n *\n * RAM cost: 0 GB\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "getGameInfo(): "
},
{
"kind": "Reference",
"text": "GameInfo",
"canonicalReference": "bitburner!GameInfo:interface"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "getGameInfo"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#getStyles:member(1)", "canonicalReference": "bitburner!UserInterface#getStyles:member(1)",
"docComment": "/**\n * Get the current styles\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n *\n * @returns An object containing the player's styles\n */\n", "docComment": "/**\n * Get the current styles\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * @returns An object containing the player's styles\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31360,7 +31450,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#getTheme:member(1)", "canonicalReference": "bitburner!UserInterface#getTheme:member(1)",
"docComment": "/**\n * Get the current theme\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n *\n * @returns An object containing the theme's colors\n */\n", "docComment": "/**\n * Get the current theme\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * @returns An object containing the theme's colors\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31389,7 +31479,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#resetStyles:member(1)", "canonicalReference": "bitburner!UserInterface#resetStyles:member(1)",
"docComment": "/**\n * Resets the player's styles to the default values\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n */\n", "docComment": "/**\n * Resets the player's styles to the default values\n *\n * @remarks\n *\n * RAM cost: 0 GB\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31417,7 +31507,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#resetTheme:member(1)", "canonicalReference": "bitburner!UserInterface#resetTheme:member(1)",
"docComment": "/**\n * Resets the player's theme to the default values\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n */\n", "docComment": "/**\n * Resets the player's theme to the default values\n *\n * @remarks\n *\n * RAM cost: 0 GB\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31445,7 +31535,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#setStyles:member(1)", "canonicalReference": "bitburner!UserInterface#setStyles:member(1)",
"docComment": "/**\n * Sets the current styles\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n *\n * @example\n *\n * Usage example (NS2)\n * ```ts\n * const styles = ns.ui.getStyles();\n * styles.fontFamily = 'Comic Sans Ms';\n * ns.ui.setStyles(styles);\n * ```\n *\n */\n", "docComment": "/**\n * Sets the current styles\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * @example\n *\n * Usage example (NS2)\n * ```ts\n * const styles = ns.ui.getStyles();\n * styles.fontFamily = 'Comic Sans Ms';\n * ns.ui.setStyles(styles);\n * ```\n *\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
@ -31490,7 +31580,7 @@
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!UserInterface#setTheme:member(1)", "canonicalReference": "bitburner!UserInterface#setTheme:member(1)",
"docComment": "/**\n * Sets the current theme\n *\n * @remarks\n *\n * RAM cost: cost: 0 GB\n *\n * @example\n *\n * Usage example (NS2)\n * ```ts\n * const theme = ns.ui.getTheme();\n * theme.primary = '#ff5500';\n * ns.ui.setTheme(theme);\n * ```\n *\n */\n", "docComment": "/**\n * Sets the current theme\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * @example\n *\n * Usage example (NS2)\n * ```ts\n * const theme = ns.ui.getTheme();\n * theme.primary = '#ff5500';\n * ns.ui.setTheme(theme);\n * ```\n *\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -28,5 +28,5 @@ Parameter that affects the percentage by which the servers money is increased
RAM cost: 0.1 GB RAM cost: 0.1 GB
Returns the servers instrinsic “growth parameter”. This growth parameter is a number between 0 and 100 that represents how quickly the servers money grows. This parameter affects the percentage by which the servers money is increased when using the grow function. A higher growth parameter will result in a higher percentage increase from grow. Returns the servers intrinsic “growth parameter”. This growth parameter is a number typically between 0 and 100 that represents how quickly the servers money grows. This parameter affects the percentage by which the servers money is increased when using the grow function. A higher growth parameter will result in a higher percentage increase from grow.

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [getSharePower](./bitburner.ns.getsharepower.md)
## NS.getSharePower() method
Calculate your share power.
<b>Signature:</b>
```typescript
getSharePower(): number;
```
<b>Returns:</b>
number
## Remarks
RAM cost: 0.2 GB

@ -107,6 +107,7 @@ export async function main(ns) {
| [getServerRequiredHackingLevel(host)](./bitburner.ns.getserverrequiredhackinglevel.md) | Returns the required hacking level of the target server. | | [getServerRequiredHackingLevel(host)](./bitburner.ns.getserverrequiredhackinglevel.md) | Returns the required hacking level of the target server. |
| [getServerSecurityLevel(host)](./bitburner.ns.getserversecuritylevel.md) | Get server security level. | | [getServerSecurityLevel(host)](./bitburner.ns.getserversecuritylevel.md) | Get server security level. |
| [getServerUsedRam(host)](./bitburner.ns.getserverusedram.md) | Get the used RAM on a server. | | [getServerUsedRam(host)](./bitburner.ns.getserverusedram.md) | Get the used RAM on a server. |
| [getSharePower()](./bitburner.ns.getsharepower.md) | Calculate your share power. |
| [getTimeSinceLastAug()](./bitburner.ns.gettimesincelastaug.md) | Returns the amount of time in milliseconds that have passed since you last installed Augmentations. | | [getTimeSinceLastAug()](./bitburner.ns.gettimesincelastaug.md) | Returns the amount of time in milliseconds that have passed since you last installed Augmentations. |
| [getWeakenTime(host)](./bitburner.ns.getweakentime.md) | Get the execution time of a weaken() call. | | [getWeakenTime(host)](./bitburner.ns.getweakentime.md) | Get the execution time of a weaken() call. |
| [grow(host, opts)](./bitburner.ns.grow.md) | Spoof money in a servers bank account, increasing the amount available. | | [grow(host, opts)](./bitburner.ns.grow.md) | Spoof money in a servers bank account, increasing the amount available. |
@ -144,6 +145,7 @@ export async function main(ns) {
| [scriptKill(script, host)](./bitburner.ns.scriptkill.md) | Kill all scripts with a filename. | | [scriptKill(script, host)](./bitburner.ns.scriptkill.md) | Kill all scripts with a filename. |
| [scriptRunning(script, host)](./bitburner.ns.scriptrunning.md) | Check if any script with a filename is running. | | [scriptRunning(script, host)](./bitburner.ns.scriptrunning.md) | Check if any script with a filename is running. |
| [serverExists(host)](./bitburner.ns.serverexists.md) | Returns a boolean denoting whether or not the specified server exists. | | [serverExists(host)](./bitburner.ns.serverexists.md) | Returns a boolean denoting whether or not the specified server exists. |
| [share()](./bitburner.ns.share.md) | Share your computer with your factions. Increasing your rep gain for a short duration. |
| [sleep(millis)](./bitburner.ns.sleep.md) | Suspends the script for n milliseconds. | | [sleep(millis)](./bitburner.ns.sleep.md) | Suspends the script for n milliseconds. |
| [spawn(script, numThreads, args)](./bitburner.ns.spawn.md) | Terminate current script and start another in 10s. | | [spawn(script, numThreads, args)](./bitburner.ns.spawn.md) | Terminate current script and start another in 10s. |
| [sprintf(format, args)](./bitburner.ns.sprintf.md) | Format a string. | | [sprintf(format, args)](./bitburner.ns.sprintf.md) | Format a string. |

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [share](./bitburner.ns.share.md)
## NS.share() method
Share your computer with your factions. Increasing your rep gain for a short duration.
<b>Signature:</b>
```typescript
share(): Promise<void>;
```
<b>Returns:</b>
Promise&lt;void&gt;
## Remarks
RAM cost: 2.4 GB

@ -19,5 +19,5 @@ List of active fragments placed on Stanek's Gift.
## Remarks ## Remarks
RAM cost: cost: 5 GB RAM cost: 5 GB

@ -29,5 +29,5 @@ true if the fragment can be placed at that position. false otherwise.
## Remarks ## Remarks
RAM cost: cost: 0.5 GB RAM cost: 0.5 GB

@ -17,5 +17,5 @@ void
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -19,5 +19,5 @@ List of possible fragments.
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -27,5 +27,5 @@ The fragment at \[rootX, rootY\], if any.
## Remarks ## Remarks
RAM cost: cost: 5 GB RAM cost: 5 GB

@ -29,5 +29,5 @@ true if the fragment can be placed at that position. false otherwise.
## Remarks ## Remarks
RAM cost: cost: 5 GB RAM cost: 5 GB

@ -27,5 +27,5 @@ The fragment at \[rootX, rootY\], if any.
## Remarks ## Remarks
RAM cost: cost: 0.15 GB RAM cost: 0.15 GB

@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [UserInterface](./bitburner.userinterface.md) &gt; [getGameInfo](./bitburner.userinterface.getgameinfo.md)
## UserInterface.getGameInfo() method
Gets the current game information (version, commit, ...)
<b>Signature:</b>
```typescript
getGameInfo(): GameInfo;
```
<b>Returns:</b>
GameInfo
## Remarks
RAM cost: 0 GB

@ -19,5 +19,5 @@ An object containing the player's styles
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -19,5 +19,5 @@ An object containing the theme's colors
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -16,6 +16,7 @@ interface UserInterface
| Method | Description | | Method | Description |
| --- | --- | | --- | --- |
| [getGameInfo()](./bitburner.userinterface.getgameinfo.md) | Gets the current game information (version, commit, ...) |
| [getStyles()](./bitburner.userinterface.getstyles.md) | Get the current styles | | [getStyles()](./bitburner.userinterface.getstyles.md) | Get the current styles |
| [getTheme()](./bitburner.userinterface.gettheme.md) | Get the current theme | | [getTheme()](./bitburner.userinterface.gettheme.md) | Get the current theme |
| [resetStyles()](./bitburner.userinterface.resetstyles.md) | Resets the player's styles to the default values | | [resetStyles()](./bitburner.userinterface.resetstyles.md) | Resets the player's styles to the default values |

@ -17,5 +17,5 @@ void
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -17,5 +17,5 @@ void
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB

@ -24,7 +24,7 @@ void
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB
## Example ## Example

@ -24,7 +24,7 @@ void
## Remarks ## Remarks
RAM cost: cost: 0 GB RAM cost: 0 GB
## Example ## Example

@ -380,7 +380,7 @@ export const achievements: IMap<Achievement> = {
}, },
TRAVEL: { TRAVEL: {
...achievementData["TRAVEL"], ...achievementData["TRAVEL"],
Icon: "travel", Icon: "TRAVEL",
Condition: () => Player.city !== CityName.Sector12, Condition: () => Player.city !== CityName.Sector12,
}, },
WORKOUT: { WORKOUT: {
@ -553,7 +553,9 @@ export const achievements: IMap<Achievement> = {
...achievementData["MAX_CACHE"], ...achievementData["MAX_CACHE"],
Icon: "HASHNETCAP", Icon: "HASHNETCAP",
Visible: () => hasAccessToSF(Player, 9), Visible: () => hasAccessToSF(Player, 9),
Condition: () => hasHacknetServers(Player) && Player.hashManager.hashes === Player.hashManager.capacity, Condition: () => hasHacknetServers(Player) &&
Player.hashManager.hashes === Player.hashManager.capacity &&
Player.hashManager.capacity > 0,
}, },
SLEEVE_8: { SLEEVE_8: {
...achievementData["SLEEVE_8"], ...achievementData["SLEEVE_8"],

@ -22,12 +22,12 @@ export function loadGlobalAliases(saveString: string): void {
// Prints all aliases to terminal // Prints all aliases to terminal
export function printAliases(): void { export function printAliases(): void {
for (const name in Aliases) { for (const name of Object.keys(Aliases)) {
if (Aliases.hasOwnProperty(name)) { if (Aliases.hasOwnProperty(name)) {
Terminal.print("alias " + name + "=" + Aliases[name]); Terminal.print("alias " + name + "=" + Aliases[name]);
} }
} }
for (const name in GlobalAliases) { for (const name of Object.keys(GlobalAliases)) {
if (GlobalAliases.hasOwnProperty(name)) { if (GlobalAliases.hasOwnProperty(name)) {
Terminal.print("global alias " + name + "=" + GlobalAliases[name]); Terminal.print("global alias " + name + "=" + GlobalAliases[name]);
} }

@ -526,7 +526,7 @@ export class Augmentation {
// Adds this Augmentation to all Factions // Adds this Augmentation to all Factions
addToAllFactions(): void { addToAllFactions(): void {
for (const fac in Factions) { for (const fac of Object.keys(Factions)) {
if (Factions.hasOwnProperty(fac)) { if (Factions.hasOwnProperty(fac)) {
const facObj: Faction | null = Factions[fac]; const facObj: Faction | null = Factions[fac];
if (facObj == null) { if (facObj == null) {

@ -112,7 +112,7 @@ function getRandomBonus(): any {
} }
function initAugmentations(): void { function initAugmentations(): void {
for (const name in Factions) { for (const name of Object.keys(Factions)) {
if (Factions.hasOwnProperty(name)) { if (Factions.hasOwnProperty(name)) {
Factions[name].augmentations = []; Factions[name].augmentations = [];
} }
@ -2498,7 +2498,7 @@ function initAugmentations(): void {
CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]], CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]],
Player.queuedAugmentations.length, Player.queuedAugmentations.length,
); );
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
Augmentations[name].baseCost *= mult; Augmentations[name].baseCost *= mult;
} }
@ -2525,7 +2525,7 @@ function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void
const augObj = Augmentations[aug.name]; const augObj = Augmentations[aug.name];
// Apply multipliers // Apply multipliers
for (const mult in augObj.mults) { for (const mult of Object.keys(augObj.mults)) {
const v = Player.getMult(mult) * augObj.mults[mult]; const v = Player.getMult(mult) * augObj.mults[mult];
Player.setMult(mult, v); Player.setMult(mult, v);
} }

@ -17,7 +17,7 @@ function calculateAugmentedStats(): any {
const augP: any = {}; const augP: any = {};
for (const aug of Player.queuedAugmentations) { for (const aug of Player.queuedAugmentations) {
const augObj = Augmentations[aug.name]; const augObj = Augmentations[aug.name];
for (const mult in augObj.mults) { for (const mult of Object.keys(augObj.mults)) {
const v = augP[mult] ? augP[mult] : 1; const v = augP[mult] ? augP[mult] : 1;
augP[mult] = v * augObj.mults[mult]; augP[mult] = v * augObj.mults[mult];
} }

@ -578,7 +578,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
if (p.bitNodeN == null) { if (p.bitNodeN == null) {
p.bitNodeN = 1; p.bitNodeN = 1;
} }
for (const mult in BitNodeMultipliers) { for (const mult of Object.keys(BitNodeMultipliers)) {
if (BitNodeMultipliers.hasOwnProperty(mult)) { if (BitNodeMultipliers.hasOwnProperty(mult)) {
BitNodeMultipliers[mult] = 1; BitNodeMultipliers[mult] = 1;
} }

@ -117,7 +117,7 @@ export class Action implements IAction {
// Check to make sure weights are summed properly // Check to make sure weights are summed properly
let sum = 0; let sum = 0;
for (const weight in this.weights) { for (const weight of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(weight)) { if (this.weights.hasOwnProperty(weight)) {
sum += this.weights[weight]; sum += this.weights[weight];
} }
@ -131,7 +131,7 @@ export class Action implements IAction {
); );
} }
for (const decay in this.decays) { for (const decay of Object.keys(this.decays)) {
if (this.decays.hasOwnProperty(decay)) { if (this.decays.hasOwnProperty(decay)) {
if (this.decays[decay] > 1) { if (this.decays[decay] > 1) {
throw new Error( throw new Error(
@ -240,7 +240,7 @@ export class Action implements IAction {
} }
let difficulty = this.getDifficulty(); let difficulty = this.getDifficulty();
let competence = 0; let competence = 0;
for (const stat in this.weights) { for (const stat of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(stat)) { if (this.weights.hasOwnProperty(stat)) {
const playerStatLvl = Player.queryStatFromString(stat); const playerStatLvl = Player.queryStatFromString(stat);
const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1); const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);

@ -135,7 +135,7 @@ export class Bladeburner implements IBladeburner {
// Can't start a BlackOp if you haven't done the one before it // Can't start a BlackOp if you haven't done the one before it
const blackops = []; const blackops = [];
for (const nm in BlackOperations) { for (const nm of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(nm)) { if (BlackOperations.hasOwnProperty(nm)) {
blackops.push(nm); blackops.push(nm);
} }
@ -1074,7 +1074,7 @@ export class Bladeburner implements IBladeburner {
updateSkillMultipliers(): void { updateSkillMultipliers(): void {
this.resetSkillMultipliers(); this.resetSkillMultipliers();
for (const skillName in this.skills) { for (const skillName of Object.keys(this.skills)) {
if (this.skills.hasOwnProperty(skillName)) { if (this.skills.hasOwnProperty(skillName)) {
const skill = Skills[skillName]; const skill = Skills[skillName];
if (skill == null) { if (skill == null) {

@ -12,7 +12,7 @@ interface IProps {
export function BlackOpList(props: IProps): React.ReactElement { export function BlackOpList(props: IProps): React.ReactElement {
let blackops: BlackOperation[] = []; let blackops: BlackOperation[] = [];
for (const blackopName in BlackOperations) { for (const blackopName of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(blackopName)) { if (BlackOperations.hasOwnProperty(blackopName)) {
blackops.push(BlackOperations[blackopName]); blackops.push(BlackOperations[blackopName]);
} }

@ -12,7 +12,7 @@ interface IProps {
export function GeneralActionList(props: IProps): React.ReactElement { export function GeneralActionList(props: IProps): React.ReactElement {
const actions: Action[] = []; const actions: Action[] = [];
for (const name in GeneralActions) { for (const name of Object.keys(GeneralActions)) {
if (GeneralActions.hasOwnProperty(name)) { if (GeneralActions.hasOwnProperty(name)) {
actions.push(GeneralActions[name]); actions.push(GeneralActions[name]);
} }

@ -157,7 +157,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
function step(): void { function step(): void {
let stoppedOne = false; let stoppedOne = false;
const copy = index.slice(); const copy = index.slice();
for (const i in copy) { for (let i = 0; i < copy.length; i++) {
if (copy[i] === locks[i] && !stoppedOne) continue; if (copy[i] === locks[i] && !stoppedOne) continue;
copy[i] = (copy[i] + 1) % symbols.length; copy[i] = (copy[i] + 1) % symbols.length;
stoppedOne = true; stoppedOne = true;

@ -26,7 +26,7 @@ export function initCompanies(): void {
}); });
// Reset data // Reset data
for (const companyName in Companies) { for (const companyName of Object.keys(Companies)) {
const company = Companies[companyName]; const company = Companies[companyName];
const oldCompany = oldCompanies[companyName]; const oldCompany = oldCompanies[companyName];
if (!(oldCompany instanceof Company)) { if (!(oldCompany instanceof Company)) {

@ -111,8 +111,8 @@ export const CONSTANTS: {
TotalNumBitNodes: number; TotalNumBitNodes: number;
LatestUpdate: string; LatestUpdate: string;
} = { } = {
VersionString: "1.3.0", VersionString: "1.4.0",
VersionNumber: 9, VersionNumber: 10,
// Speed (in ms) at which the main loop is updated // Speed (in ms) at which the main loop is updated
_idleSpeed: 200, _idleSpeed: 200,
@ -273,89 +273,22 @@ export const CONSTANTS: {
TotalNumBitNodes: 24, TotalNumBitNodes: 24,
LatestUpdate: ` LatestUpdate: `
v1.3.0 - 2022-01-04 Cleaning up v1.4.0 - 2022-01-18 Sharing is caring
------------------------------- -------------------------------------
** External IDE integration ** ** Computer sharing **
* The Steam version has a webserver that allows integration with external IDEs. * A new mechanic has been added, it's is invoked by calling the new function 'share'.
A VSCode extension is available on the market place. (The documentation for the ext. isn't This mechanic helps you farm reputation faster.
written yet)
** Source-Files ** ** gang **
* SF4 has been reworked. * Installing augs means losing a little bit of ascension multipliers.
* New SF -1.
** UI ** ** There's more but I'm going to write it later. **
* Fix some edge case with skill bat tooltips (@MartinFournier)
* Made some background match theme color (@Kejikus)
* Fix problem with script editor height not adjusting correctly (@billyvg)
* Fix some formatting issues with Bladeburner (@MartinFournier, @nickofolas)
* Fix some functions like 'alert' format messages better (@MageKing17)
* Many community themes added.
* New script editor theme (@Hedrauta, @Dexalt142)
* Improvements to tail windows (@theit8514)
* Training is more consise (@mikomyazaki)
* Fix Investopedia not displaying properly (@JotaroS)
* Remove alpha from theme editor (@MartinFournier)
* Fix corporation tooltip not displaying properly (@MartinFournier)
* Add tooltip on backdoored location names (@MartinFournier)
* Allow toasts to be dismissed by clicking them (@nickofolas)
* Darkweb item listing now shows what you own. (@hexnaught)
** Bug fix **
* Fix unit tests (@MartinFournier)
* Fixed issue with 'cat' and 'read' not finding foldered files (@Nick-Colclasure)
* Buying on the dark web will remove incomplete exe (@hexnaught)
* Fix bug that would cause the game to crash trying to go to a job without a job (@hexnaught)
* purchaseServer validation (@nickofolas)
* Script Editor focuses code when changing tab (@MartinFournier)
* Fix script editor for .txt files (@65-7a)
* Fix 'buy' command not displaying correctly. (@hexnaught)
* Fix hackAnalyzeThread returning NaN (@mikomyazaki)
* Electron handles exceptions better (@MageKing17)
* Electron will handle 'unresponsive' event and present the opportunity to reload the game with no scripts (@MartinFournier)
* Fix 'cp' between folders (@theit8514)
* Fix throwing null/undefined errors (@nickofolas)
* Allow shortcuts to work when unfocused (@MageKing17)
* Fix some dependency issue (@locriacyber)
* Fix corporation state returning an object instead of a string (@antonvmironov)
* Fix 'mv' overwriting files (@theit8514)
* Fix joesguns not being influenced by hack/grow (@dou867, @MartinFournier)
* Added warning when opening external links. (@MartinFournier)
* Prevent applying for positions that aren't offered (@TheMas3212)
* Import has validation (@MartinFournier)
** Misc. ** ** Misc. **
* Added vim mode to script editor (@billyvg) * Nerf noodle bar.
* Clean up script editor code (@Rez855)
* 'cat' works on scripts (@65-7a)
* Add wordWrap for Monaco (@MartinFournier)
* Include map bundles in electron for easier debugging (@MartinFournier)
* Fix importing very large files (@MartinFournier)
* Cache program blob, reducing ram usage of the game (@theit8514)
* Dev menu can set server to $0 (@mikomyazaki)
* 'backdoor' allows direct connect (@mikomyazaki)
* Github workflow work (@MartinFournier)
* workForFaction / workForCompany have a new parameter (@theit8514)
* Alias accept single quotes (@sporkwitch, @FaintSpeaker)
* Add grep options to 'ps' (@maxtimum)
* Added buy all option to 'buy' (@anthonydroberts)
* Added more shortcuts to terminal input (@Frank-py)
* Refactor some port code (@ErzengelLichtes)
* Settings to control GiB vs GB (@ErzengelLichtes)
* Add electron option to export save game (@MartinFournier)
* Electron improvements (@MartinFournier)
* Expose some notifications functions to electron (@MartinFournier)
* Documentation (@MartinFournier, @cyn, @millennIumAMbiguity, @2PacIsAlive,
@TheCoderJT, @hexnaught, @sschmidTU, @FOLLGAD, @Hedrauta, @Xynrati,
@mikomyazaki, @Icehawk78, @aaronransley, @TheMas3212, @Hedrauta, @alkemann,
@ReeseJones, @amclark42, @thadguidry, @jasonhaxstuff, @pan-kuleczka, @jhollowe,
@ApatheticsAnonymous, @erplsf, @daanflore, @nickofolas, @Kebap, @smolgumball,
@woody-lam-cwl)
`, `,
}; };

@ -307,7 +307,7 @@ export class Corporation {
if (upgN === 1) { if (upgN === 1) {
for (let i = 0; i < this.divisions.length; ++i) { for (let i = 0; i < this.divisions.length; ++i) {
const industry = this.divisions[i]; const industry = this.divisions[i];
for (const city in industry.warehouses) { for (const city of Object.keys(industry.warehouses)) {
const warehouse = industry.warehouses[city]; const warehouse = industry.warehouses[city];
if (warehouse === 0) continue; if (warehouse === 0) continue;
if (industry.warehouses.hasOwnProperty(city) && warehouse instanceof Warehouse) { if (industry.warehouses.hasOwnProperty(city) && warehouse instanceof Warehouse) {

@ -378,7 +378,7 @@ export class Industry implements IIndustry {
updateWarehouseSizeUsed(warehouse: Warehouse): void { updateWarehouseSizeUsed(warehouse: Warehouse): void {
warehouse.updateMaterialSizeUsed(); warehouse.updateMaterialSizeUsed();
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) { if (this.products.hasOwnProperty(prodName)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
@ -414,7 +414,7 @@ export class Industry implements IIndustry {
// Process offices (and the employees in them) // Process offices (and the employees in them)
let employeeSalary = 0; let employeeSalary = 0;
for (const officeLoc in this.offices) { for (const officeLoc of Object.keys(this.offices)) {
const office = this.offices[officeLoc]; const office = this.offices[officeLoc];
if (office === 0) continue; if (office === 0) continue;
if (office instanceof OfficeSpace) { if (office instanceof OfficeSpace) {
@ -470,7 +470,7 @@ export class Industry implements IIndustry {
if (this.warehouses[CorporationConstants.Cities[i]] instanceof Warehouse) { if (this.warehouses[CorporationConstants.Cities[i]] instanceof Warehouse) {
const wh = this.warehouses[CorporationConstants.Cities[i]]; const wh = this.warehouses[CorporationConstants.Cities[i]];
if (wh === 0) continue; if (wh === 0) continue;
for (const name in reqMats) { for (const name of Object.keys(reqMats)) {
if (reqMats.hasOwnProperty(name)) { if (reqMats.hasOwnProperty(name)) {
wh.materials[name].processMarket(); wh.materials[name].processMarket();
} }
@ -493,7 +493,7 @@ export class Industry implements IIndustry {
// Process change in demand and competition for this industry's products // Process change in demand and competition for this industry's products
processProductMarket(marketCycles = 1): void { processProductMarket(marketCycles = 1): void {
// Demand gradually decreases, and competition gradually increases // Demand gradually decreases, and competition gradually increases
for (const name in this.products) { for (const name of Object.keys(this.products)) {
if (this.products.hasOwnProperty(name)) { if (this.products.hasOwnProperty(name)) {
const product = this.products[name]; const product = this.products[name];
if (product === undefined) continue; if (product === undefined) continue;
@ -531,7 +531,7 @@ export class Industry implements IIndustry {
} }
const warehouse = this.warehouses[city]; const warehouse = this.warehouses[city];
if (warehouse === 0) continue; if (warehouse === 0) continue;
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
mat.imp = 0; mat.imp = 0;
@ -552,7 +552,7 @@ export class Industry implements IIndustry {
switch (this.state) { switch (this.state) {
case "PURCHASE": { case "PURCHASE": {
/* Process purchase of materials */ /* Process purchase of materials */
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue; if (!warehouse.materials.hasOwnProperty(matName)) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
let buyAmt = 0; let buyAmt = 0;
@ -574,7 +574,7 @@ export class Industry implements IIndustry {
// smart supply // smart supply
const smartBuy: { [key: string]: number | undefined } = {}; const smartBuy: { [key: string]: number | undefined } = {};
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue; if (!warehouse.materials.hasOwnProperty(matName)) continue;
if (!warehouse.smartSupplyEnabled || !Object.keys(this.reqMats).includes(matName)) continue; if (!warehouse.smartSupplyEnabled || !Object.keys(this.reqMats).includes(matName)) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
@ -591,7 +591,7 @@ export class Industry implements IIndustry {
// Find which material were trying to create the least amount of product with. // Find which material were trying to create the least amount of product with.
let worseAmt = 1e99; let worseAmt = 1e99;
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
const reqMat = this.reqMats[matName]; const reqMat = this.reqMats[matName];
@ -601,7 +601,7 @@ export class Industry implements IIndustry {
} }
// Align all the materials to the smallest amount. // Align all the materials to the smallest amount.
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const reqMat = this.reqMats[matName]; const reqMat = this.reqMats[matName];
if (reqMat === undefined) throw new Error(`reqMat "${matName}" is undefined`); if (reqMat === undefined) throw new Error(`reqMat "${matName}" is undefined`);
smartBuy[matName] = worseAmt * reqMat; smartBuy[matName] = worseAmt * reqMat;
@ -609,7 +609,7 @@ export class Industry implements IIndustry {
// Calculate the total size of all things were trying to buy // Calculate the total size of all things were trying to buy
let totalSize = 0; let totalSize = 0;
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
totalSize += buyAmt * MaterialSizes[matName]; totalSize += buyAmt * MaterialSizes[matName];
@ -618,7 +618,7 @@ export class Industry implements IIndustry {
// Shrink to the size of available space. // Shrink to the size of available space.
const freeSpace = warehouse.size - warehouse.sizeUsed; const freeSpace = warehouse.size - warehouse.sizeUsed;
if (totalSize > freeSpace) { if (totalSize > freeSpace) {
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
smartBuy[matName] = Math.floor((buyAmt * freeSpace) / totalSize); smartBuy[matName] = Math.floor((buyAmt * freeSpace) / totalSize);
@ -626,7 +626,7 @@ export class Industry implements IIndustry {
} }
// Use the materials already in the warehouse if the option is on. // Use the materials already in the warehouse if the option is on.
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
if (!warehouse.smartSupplyUseLeftovers[matName]) continue; if (!warehouse.smartSupplyUseLeftovers[matName]) continue;
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
@ -635,7 +635,7 @@ export class Industry implements IIndustry {
} }
// buy them // buy them
for (const matName in smartBuy) { for (const matName of Object.keys(smartBuy)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
const buyAmt = smartBuy[matName]; const buyAmt = smartBuy[matName];
if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`); if (buyAmt === undefined) throw new Error(`Somehow smartbuy matname is undefined`);
@ -672,7 +672,7 @@ export class Industry implements IIndustry {
for (let tmp = 0; tmp < this.prodMats.length; ++tmp) { for (let tmp = 0; tmp < this.prodMats.length; ++tmp) {
totalMatSize += MaterialSizes[this.prodMats[tmp]]; totalMatSize += MaterialSizes[this.prodMats[tmp]];
} }
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
const normQty = this.reqMats[reqMatName]; const normQty = this.reqMats[reqMatName];
if (normQty === undefined) continue; if (normQty === undefined) continue;
totalMatSize -= MaterialSizes[reqMatName] * normQty; totalMatSize -= MaterialSizes[reqMatName] * normQty;
@ -692,7 +692,7 @@ export class Industry implements IIndustry {
// Make sure we have enough resource to make our materials // Make sure we have enough resource to make our materials
let producableFrac = 1; let producableFrac = 1;
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
if (this.reqMats.hasOwnProperty(reqMatName)) { if (this.reqMats.hasOwnProperty(reqMatName)) {
const reqMat = this.reqMats[reqMatName]; const reqMat = this.reqMats[reqMatName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
@ -709,7 +709,7 @@ export class Industry implements IIndustry {
// Make our materials if they are producable // Make our materials if they are producable
if (producableFrac > 0 && prod > 0) { if (producableFrac > 0 && prod > 0) {
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
const reqMat = this.reqMats[reqMatName]; const reqMat = this.reqMats[reqMatName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
const reqMatQtyNeeded = reqMat * prod * producableFrac; const reqMatQtyNeeded = reqMat * prod * producableFrac;
@ -726,7 +726,7 @@ export class Industry implements IIndustry {
Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3; Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3;
} }
} else { } else {
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
if (this.reqMats.hasOwnProperty(reqMatName)) { if (this.reqMats.hasOwnProperty(reqMatName)) {
warehouse.materials[reqMatName].prd = 0; warehouse.materials[reqMatName].prd = 0;
} }
@ -742,7 +742,7 @@ export class Industry implements IIndustry {
//If this doesn't produce any materials, then it only creates //If this doesn't produce any materials, then it only creates
//Products. Creating products will consume materials. The //Products. Creating products will consume materials. The
//Production of all consumed materials must be set to 0 //Production of all consumed materials must be set to 0
for (const reqMatName in this.reqMats) { for (const reqMatName of Object.keys(this.reqMats)) {
warehouse.materials[reqMatName].prd = 0; warehouse.materials[reqMatName].prd = 0;
} }
} }
@ -750,7 +750,7 @@ export class Industry implements IIndustry {
case "SALE": case "SALE":
/* Process sale of materials */ /* Process sale of materials */
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
if (mat.sCost < 0 || mat.sllman[0] === false) { if (mat.sCost < 0 || mat.sllman[0] === false) {
@ -881,7 +881,7 @@ export class Industry implements IIndustry {
break; break;
case "EXPORT": case "EXPORT":
for (const matName in warehouse.materials) { for (const matName of Object.keys(warehouse.materials)) {
if (warehouse.materials.hasOwnProperty(matName)) { if (warehouse.materials.hasOwnProperty(matName)) {
const mat = warehouse.materials[matName]; const mat = warehouse.materials[matName];
mat.totalExp = 0; //Reset export mat.totalExp = 0; //Reset export
@ -993,7 +993,7 @@ export class Industry implements IIndustry {
//Create products //Create products
if (this.state === "PRODUCTION") { if (this.state === "PRODUCTION") {
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
if (!prod.fin) { if (!prod.fin) {
@ -1025,7 +1025,7 @@ export class Industry implements IIndustry {
} }
//Produce Products //Produce Products
for (const prodName in this.products) { for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) { if (this.products.hasOwnProperty(prodName)) {
const prod = this.products[prodName]; const prod = this.products[prodName];
if (prod instanceof Product && prod.fin) { if (prod instanceof Product && prod.fin) {
@ -1067,7 +1067,7 @@ export class Industry implements IIndustry {
//Calculate net change in warehouse storage making the Products will cost //Calculate net change in warehouse storage making the Products will cost
let netStorageSize = product.siz; let netStorageSize = product.siz;
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const normQty = product.reqMats[reqMatName]; const normQty = product.reqMats[reqMatName];
netStorageSize -= MaterialSizes[reqMatName] * normQty; netStorageSize -= MaterialSizes[reqMatName] * normQty;
@ -1084,7 +1084,7 @@ export class Industry implements IIndustry {
//Make sure we have enough resources to make our Products //Make sure we have enough resources to make our Products
let producableFrac = 1; let producableFrac = 1;
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const req = product.reqMats[reqMatName] * prod; const req = product.reqMats[reqMatName] * prod;
if (warehouse.materials[reqMatName].qty < req) { if (warehouse.materials[reqMatName].qty < req) {
@ -1095,7 +1095,7 @@ export class Industry implements IIndustry {
//Make our Products if they are producable //Make our Products if they are producable
if (producableFrac > 0 && prod > 0) { if (producableFrac > 0 && prod > 0) {
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
const reqMatQtyNeeded = product.reqMats[reqMatName] * prod * producableFrac; const reqMatQtyNeeded = product.reqMats[reqMatName] * prod * producableFrac;
warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; warehouse.materials[reqMatName].qty -= reqMatQtyNeeded;
@ -1114,7 +1114,7 @@ export class Industry implements IIndustry {
case "SALE": { case "SALE": {
//Process sale of Products //Process sale of Products
product.pCost = 0; //Estimated production cost product.pCost = 0; //Estimated production cost
for (const reqMatName in product.reqMats) { for (const reqMatName of Object.keys(product.reqMats)) {
if (product.reqMats.hasOwnProperty(reqMatName)) { if (product.reqMats.hasOwnProperty(reqMatName)) {
product.pCost += product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost; product.pCost += product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost;
} }
@ -1250,7 +1250,7 @@ export class Industry implements IIndustry {
} }
discontinueProduct(product: Product): void { discontinueProduct(product: Product): void {
for (const productName in this.products) { for (const productName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(productName)) { if (this.products.hasOwnProperty(productName)) {
if (product === this.products[productName]) { if (product === this.products[productName]) {
delete this.products[productName]; delete this.products[productName];
@ -1354,7 +1354,7 @@ export class Industry implements IIndustry {
// Since ResearchTree data isnt saved, we'll update the Research Tree data // Since ResearchTree data isnt saved, we'll update the Research Tree data
// based on the stored 'researched' property in the Industry object // based on the stored 'researched' property in the Industry object
if (Object.keys(researchTree.researched).length !== Object.keys(this.researched).length) { if (Object.keys(researchTree.researched).length !== Object.keys(this.researched).length) {
for (const research in this.researched) { for (const research of Object.keys(this.researched)) {
researchTree.research(research); researchTree.research(research);
} }
} }

@ -103,7 +103,7 @@ export class OfficeSpace {
calculateEmployeeProductivity(corporation: ICorporation, industry: IIndustry): void { calculateEmployeeProductivity(corporation: ICorporation, industry: IIndustry): void {
//Reset //Reset
for (const name in this.employeeProd) { for (const name of Object.keys(this.employeeProd)) {
this.employeeProd[name] = 0; this.employeeProd[name] = 0;
} }

@ -198,7 +198,7 @@ export class Product {
//Calculate the product's required materials //Calculate the product's required materials
//For now, just set it to be the same as the requirements to make materials //For now, just set it to be the same as the requirements to make materials
for (const matName in industry.reqMats) { for (const matName of Object.keys(industry.reqMats)) {
if (industry.reqMats.hasOwnProperty(matName)) { if (industry.reqMats.hasOwnProperty(matName)) {
const reqMat = industry.reqMats[matName]; const reqMat = industry.reqMats[matName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
@ -209,7 +209,7 @@ export class Product {
//Calculate the product's size //Calculate the product's size
//For now, just set it to be the same size as the requirements to make materials //For now, just set it to be the same size as the requirements to make materials
this.siz = 0; this.siz = 0;
for (const matName in industry.reqMats) { for (const matName of Object.keys(industry.reqMats)) {
const reqMat = industry.reqMats[matName]; const reqMat = industry.reqMats[matName];
if (reqMat === undefined) continue; if (reqMat === undefined) continue;
this.siz += MaterialSizes[matName] * reqMat; this.siz += MaterialSizes[matName] * reqMat;

@ -85,7 +85,7 @@ export class Warehouse {
// Re-calculate how much space is being used by this Warehouse // Re-calculate how much space is being used by this Warehouse
updateMaterialSizeUsed(): void { updateMaterialSizeUsed(): void {
this.sizeUsed = 0; this.sizeUsed = 0;
for (const matName in this.materials) { for (const matName of Object.keys(this.materials)) {
const mat = this.materials[matName]; const mat = this.materials[matName];
if (MaterialSizes.hasOwnProperty(matName)) { if (MaterialSizes.hasOwnProperty(matName)) {
this.sizeUsed += mat.qty * MaterialSizes[matName]; this.sizeUsed += mat.qty * MaterialSizes[matName];

@ -215,7 +215,7 @@ function Upgrades(props: { office: OfficeSpace; rerender: () => void }): React.R
const corp = useCorporation(); const corp = useCorporation();
const division = useDivision(); const division = useDivision();
const upgrades = []; const upgrades = [];
for (const index in IndustryUpgrades) { for (const index of Object.keys(IndustryUpgrades)) {
const upgrade = IndustryUpgrades[index]; const upgrade = IndustryUpgrades[index];
// AutoBrew research disables the Coffee upgrade // AutoBrew research disables the Coffee upgrade

@ -81,7 +81,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
// Create React components for materials // Create React components for materials
const mats = []; const mats = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
if (!(props.warehouse.materials[matName] instanceof Material)) continue; if (!(props.warehouse.materials[matName] instanceof Material)) continue;
// Only create UI for materials that are relevant for the industry // Only create UI for materials that are relevant for the industry
if (!isRelevantMaterial(matName, division)) continue; if (!isRelevantMaterial(matName, division)) continue;
@ -99,7 +99,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
// Create React components for products // Create React components for products
const products = []; const products = [];
if (division.makesProducts && Object.keys(division.products).length > 0) { if (division.makesProducts && Object.keys(division.products).length > 0) {
for (const productName in division.products) { for (const productName of Object.keys(division.products)) {
const product = division.products[productName]; const product = division.products[productName];
if (!(product instanceof Product)) continue; if (!(product instanceof Product)) continue;
products.push( products.push(
@ -109,14 +109,14 @@ function WarehouseRoot(props: IProps): React.ReactElement {
} }
const breakdownItems: JSX.Element[] = []; const breakdownItems: JSX.Element[] = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
const mat = props.warehouse.materials[matName]; const mat = props.warehouse.materials[matName];
if (!MaterialSizes.hasOwnProperty(matName)) continue; if (!MaterialSizes.hasOwnProperty(matName)) continue;
if (mat.qty === 0) continue; if (mat.qty === 0) continue;
breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}</>); breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}</>);
} }
for (const prodName in division.products) { for (const prodName of Object.keys(division.products)) {
const prod = division.products[prodName]; const prod = division.products[prodName];
if (prod === undefined) continue; if (prod === undefined) continue;
breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}</>); breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}</>);

@ -60,7 +60,7 @@ export function SmartSupplyModal(props: IProps): React.ReactElement {
// Create React components for materials // Create React components for materials
const mats = []; const mats = [];
for (const matName in props.warehouse.materials) { for (const matName of Object.keys(props.warehouse.materials)) {
if (!(props.warehouse.materials[matName] instanceof Material)) continue; if (!(props.warehouse.materials[matName] instanceof Material)) continue;
if (!Object.keys(division.reqMats).includes(matName)) continue; if (!Object.keys(division.reqMats).includes(matName)) continue;
mats.push(<Leftover key={matName} warehouse={props.warehouse} matName={matName} />); mats.push(<Leftover key={matName} warehouse={props.warehouse} matName={matName} />);

@ -7,7 +7,7 @@ import { dialogBoxCreate } from "../ui/React/DialogBox";
export function determineCrimeSuccess(p: IPlayer, type: string): boolean { export function determineCrimeSuccess(p: IPlayer, type: string): boolean {
let chance = 0; let chance = 0;
let found = false; let found = false;
for (const i in Crimes) { for (const i of Object.keys(Crimes)) {
const crime = Crimes[i]; const crime = Crimes[i];
if (crime.type == type) { if (crime.type == type) {
chance = crime.successRate(p); chance = crime.successRate(p);

@ -21,7 +21,7 @@ export function checkIfConnectedToDarkweb(): void {
} }
export function listAllDarkwebItems(): void { export function listAllDarkwebItems(): void {
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const item = DarkWebItems[key]; const item = DarkWebItems[key];
const cost = Player.getHomeComputer().programs.includes(item.program) ? ( const cost = Player.getHomeComputer().programs.includes(item.program) ? (
@ -44,7 +44,7 @@ export function buyDarkwebItem(itemName: string): void {
// find the program that matches, if any // find the program that matches, if any
let item: DarkWebItem | null = null; let item: DarkWebItem | null = null;
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const i = DarkWebItems[key]; const i = DarkWebItems[key];
if (i.program.toLowerCase() == itemName) { if (i.program.toLowerCase() == itemName) {
item = i; item = i;
@ -93,7 +93,7 @@ export function buyAllDarkwebItems(): void {
const itemsToBuy: DarkWebItem[] = []; const itemsToBuy: DarkWebItem[] = [];
let cost = 0; let cost = 0;
for (const key in DarkWebItems) { for (const key of Object.keys(DarkWebItems)) {
const item = DarkWebItems[key]; const item = DarkWebItems[key];
if (!Player.hasProgram(item.program)) { if (!Player.hasProgram(item.program)) {
itemsToBuy.push(item); itemsToBuy.push(item);

@ -46,25 +46,25 @@ export function Companies(): React.ReactElement {
} }
function tonsOfRepCompanies(): void { function tonsOfRepCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].playerReputation = bigNumber; AllCompanies[c].playerReputation = bigNumber;
} }
} }
function resetAllRepCompanies(): void { function resetAllRepCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].playerReputation = 0; AllCompanies[c].playerReputation = 0;
} }
} }
function tonsOfFavorCompanies(): void { function tonsOfFavorCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].favor = bigNumber; AllCompanies[c].favor = bigNumber;
} }
} }
function resetAllFavorCompanies(): void { function resetAllFavorCompanies(): void {
for (const c in AllCompanies) { for (const c of Object.keys(AllCompanies)) {
AllCompanies[c].favor = 0; AllCompanies[c].favor = 0;
} }
} }

@ -36,7 +36,7 @@ export function Factions(props: IProps): React.ReactElement {
} }
function receiveAllInvites(): void { function receiveAllInvites(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
props.player.receiveInvite(AllFaction[i].name); props.player.receiveInvite(AllFaction[i].name);
} }
} }
@ -74,25 +74,25 @@ export function Factions(props: IProps): React.ReactElement {
} }
function tonsOfRep(): void { function tonsOfRep(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].playerReputation = bigNumber; AllFaction[i].playerReputation = bigNumber;
} }
} }
function resetAllRep(): void { function resetAllRep(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].playerReputation = 0; AllFaction[i].playerReputation = 0;
} }
} }
function tonsOfFactionFavor(): void { function tonsOfFactionFavor(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].favor = bigNumber; AllFaction[i].favor = bigNumber;
} }
} }
function resetAllFactionFavor(): void { function resetAllFactionFavor(): void {
for (const i in AllFaction) { for (const i of Object.keys(AllFaction)) {
AllFaction[i].favor = 0; AllFaction[i].favor = 0;
} }
} }

@ -1,4 +1,4 @@
import React from "react"; import React, { useEffect, useState } from "react";
import Accordion from "@mui/material/Accordion"; import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionSummary from "@mui/material/AccordionSummary";
@ -17,6 +17,8 @@ interface IProps {
} }
export function General(props: IProps): React.ReactElement { export function General(props: IProps): React.ReactElement {
const [error, setError] = useState(false);
function addMoney(n: number) { function addMoney(n: number) {
return function () { return function () {
props.player.gainMoney(n, "other"); props.player.gainMoney(n, "other");
@ -43,6 +45,10 @@ export function General(props: IProps): React.ReactElement {
props.router.toBitVerse(false, false); props.router.toBitVerse(false, false);
} }
useEffect(() => {
if (error) throw new ReferenceError('Manually thrown error');
}, [error]);
return ( return (
<Accordion TransitionProps={{ unmountOnExit: true }}> <Accordion TransitionProps={{ unmountOnExit: true }}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}> <AccordionSummary expandIcon={<ExpandMoreIcon />}>
@ -81,6 +87,7 @@ export function General(props: IProps): React.ReactElement {
<Button onClick={b1tflum3}>Run b1t_flum3.exe</Button> <Button onClick={b1tflum3}>Run b1t_flum3.exe</Button>
<Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button> <Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button>
<Button onClick={hackW0r1dD43m0n}>Hack w0rld_d34m0n</Button> <Button onClick={hackW0r1dD43m0n}>Hack w0rld_d34m0n</Button>
<Button onClick={() => setError(true)}>Throw Error</Button>
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
); );

@ -28,7 +28,7 @@ export function Programs(props: IProps): React.ReactElement {
} }
function addAllPrograms(): void { function addAllPrograms(): void {
for (const i in AllPrograms) { for (const i of Object.keys(AllPrograms)) {
if (!props.player.hasProgram(AllPrograms[i].name)) { if (!props.player.hasProgram(AllPrograms[i].name)) {
props.player.getHomeComputer().programs.push(AllPrograms[i].name); props.player.getHomeComputer().programs.push(AllPrograms[i].name);
} }

@ -38,7 +38,7 @@ export function StockMarket(): React.ReactElement {
}; };
} }
for (const name in SM) { for (const name of Object.keys(SM)) {
if (SM.hasOwnProperty(name)) { if (SM.hasOwnProperty(name)) {
const stock = SM[name]; const stock = SM[name];
if (stock instanceof Stock && match(stock.symbol)) { if (stock instanceof Stock && match(stock.symbol)) {

@ -34,8 +34,7 @@ export function joinFaction(faction: Faction): void {
const factionInfo = faction.getInfo(); const factionInfo = faction.getInfo();
//Determine what factions you are banned from now that you have joined this faction //Determine what factions you are banned from now that you have joined this faction
for (const i in factionInfo.enemies) { for (const enemy of factionInfo.enemies) {
const enemy = factionInfo.enemies[i];
if (Factions[enemy] instanceof Faction) { if (Factions[enemy] instanceof Faction) {
Factions[enemy].isBanned = true; Factions[enemy].isBanned = true;
} }
@ -121,7 +120,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
} }
} }
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]]; Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]];
} }
@ -170,7 +169,7 @@ export function getNextNeurofluxLevel(): number {
} }
export function processPassiveFactionRepGain(numCycles: number): void { export function processPassiveFactionRepGain(numCycles: number): void {
for (const name in Factions) { for (const name of Object.keys(Factions)) {
if (name === Player.currentWorkFactionName) continue; if (name === Player.currentWorkFactionName) continue;
if (!Factions.hasOwnProperty(name)) continue; if (!Factions.hasOwnProperty(name)) continue;
const faction = Factions[name]; const faction = Factions[name];

@ -34,7 +34,7 @@ export function factionExists(name: string): boolean {
} }
export function initFactions(): void { export function initFactions(): void {
for (const name in FactionInfos) { for (const name of Object.keys(FactionInfos)) {
resetFaction(new Faction(name)); resetFaction(new Faction(name));
} }
} }

@ -44,7 +44,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
function getAugs(): string[] { function getAugs(): string[] {
if (isPlayersGang) { if (isPlayersGang) {
const augs: string[] = []; const augs: string[] = [];
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName]; const aug = Augmentations[augName];

@ -158,7 +158,7 @@ export class Gang implements IGang {
// Process power first // Process power first
const gangName = this.facName; const gangName = this.facName;
for (const name in AllGangs) { for (const name of Object.keys(AllGangs)) {
if (AllGangs.hasOwnProperty(name)) { if (AllGangs.hasOwnProperty(name)) {
if (name == gangName) { if (name == gangName) {
AllGangs[name].power += this.calculatePower(); AllGangs[name].power += this.calculatePower();

@ -4,7 +4,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { RecruitModal } from "./RecruitModal"; import { RecruitModal } from "./RecruitModal";
import { GangConstants } from "../data/Constants"; import { GangConstants } from "../data/Constants";
import { formatNumber } from "../../utils/StringHelperFunctions"; import { numeralWrapper } from "../../ui/numeralFormat";
import { useGang } from "./Context"; import { useGang } from "./Context";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
@ -28,7 +28,7 @@ export function RecruitButton(props: IProps): React.ReactElement {
<Button sx={{ mx: 1 }} disabled> <Button sx={{ mx: 1 }} disabled>
Recruit Gang Member Recruit Gang Member
</Button> </Button>
<Typography>{formatNumber(respect, 2)} respect needed to recruit next member</Typography> <Typography>{numeralWrapper.formatRespect(respect)} respect needed to recruit next member</Typography>
</Box> </Box>
); );
} }

@ -24,7 +24,7 @@ export class HashManager {
upgrades: IMap<number> = {}; upgrades: IMap<number> = {};
constructor() { constructor() {
for (const name in HashUpgrades) { for (const name of Object.keys(HashUpgrades)) {
this.upgrades[name] = 0; this.upgrades[name] = 0;
} }
} }
@ -85,7 +85,7 @@ export class HashManager {
} }
prestige(): void { prestige(): void {
for (const name in HashUpgrades) { for (const name of Object.keys(HashUpgrades)) {
this.upgrades[name] = 0; this.upgrades[name] = 0;
} }
this.hashes = 0; this.hashes = 0;

@ -220,7 +220,7 @@ for (const metadata of LocationsMetadata) {
const cityName = loc.city; const cityName = loc.city;
if (cityName === null) { if (cityName === null) {
// Generic location, add to all cities // Generic location, add to all cities
for (const city in Cities) { for (const city of Object.keys(Cities)) {
Cities[city].addLocation(loc.name); Cities[city].addLocation(loc.name);
} }
} else { } else {

@ -39,7 +39,6 @@ export function ApplyToJobButton(props: IProps): React.ReactElement {
<Tooltip title={<span dangerouslySetInnerHTML={{ __html: getJobRequirementTooltip() }}></span>}> <Tooltip title={<span dangerouslySetInnerHTML={{ __html: getJobRequirementTooltip() }}></span>}>
<Button onClick={props.onClick}>{props.text}</Button> <Button onClick={props.onClick}>{props.text}</Button>
</Tooltip> </Tooltip>
<br />
</> </>
); );
} }

@ -132,10 +132,10 @@ function ASCIICity(props: IProps): React.ReactElement {
const elems: JSX.Element[] = []; const elems: JSX.Element[] = [];
const lines = props.city.asciiArt.split("\n"); const lines = props.city.asciiArt.split("\n");
for (const i in lines) { for (const line of lines) {
elems.push( elems.push(
<Typography key={i} sx={{ lineHeight: "1em", whiteSpace: "pre" }}> <Typography key={line} sx={{ lineHeight: "1em", whiteSpace: "pre" }}>
{lineElems(lines[i])} {lineElems(line)}
</Typography>, </Typography>,
); );
} }

@ -61,15 +61,12 @@ export function GymLocation(props: IProps): React.ReactElement {
<Button onClick={trainStrength}> <Button onClick={trainStrength}>
Train Strength (<Money money={cost} player={props.p} /> / sec) Train Strength (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>
<br />
<Button onClick={trainDefense}> <Button onClick={trainDefense}>
Train Defense (<Money money={cost} player={props.p} /> / sec) Train Defense (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>
<br />
<Button onClick={trainDexterity}> <Button onClick={trainDexterity}>
Train Dexterity (<Money money={cost} player={props.p} /> / sec) Train Dexterity (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>
<br />
<Button onClick={trainAgility}> <Button onClick={trainAgility}>
Train Agility (<Money money={cost} player={props.p} /> / sec) Train Agility (<Money money={cost} player={props.p} /> / sec)
</Button> </Button>

@ -42,7 +42,6 @@ function ServerButton(props: IServerProps): React.ReactElement {
cost={cost} cost={cost}
rerender={props.rerender} rerender={props.rerender}
/> />
<br />
</> </>
); );
} }

@ -106,6 +106,8 @@ export const RamCosts: IMap<any> = {
hackAnalyzeSecurity: RamCostConstants.ScriptHackAnalyzeRamCost, hackAnalyzeSecurity: RamCostConstants.ScriptHackAnalyzeRamCost,
hackAnalyzeChance: RamCostConstants.ScriptHackAnalyzeRamCost, hackAnalyzeChance: RamCostConstants.ScriptHackAnalyzeRamCost,
sleep: 0, sleep: 0,
share: 2.4,
getSharePower: 0.2,
grow: RamCostConstants.ScriptGrowRamCost, grow: RamCostConstants.ScriptGrowRamCost,
growthAnalyze: RamCostConstants.ScriptGrowthAnalyzeRamCost, growthAnalyze: RamCostConstants.ScriptGrowthAnalyzeRamCost,
growthAnalyzeSecurity: RamCostConstants.ScriptGrowthAnalyzeRamCost, growthAnalyzeSecurity: RamCostConstants.ScriptGrowthAnalyzeRamCost,
@ -368,6 +370,7 @@ export const RamCosts: IMap<any> = {
getStyles: 0, getStyles: 0,
setStyles: 0, setStyles: 0,
resetStyles: 0, resetStyles: 0,
getGameInfo: 0,
}, },
heart: { heart: {

@ -3,24 +3,20 @@ import { GetServer } from "./Server/AllServers";
import { WorkerScript } from "./Netscript/WorkerScript"; import { WorkerScript } from "./Netscript/WorkerScript";
export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> { export function netscriptDelay(time: number, workerScript: WorkerScript): Promise<void> {
if (workerScript.delayReject) workerScript.delayReject();
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
workerScript.delay = window.setTimeout(() => { workerScript.delay = window.setTimeout(() => {
workerScript.delay = null; workerScript.delay = null;
workerScript.delayReject = undefined; workerScript.delayReject = undefined;
if (workerScript.env.stopFlag) if (workerScript.env.stopFlag) reject(workerScript);
reject(workerScript); else resolve();
else
resolve();
}, time); }, time);
workerScript.delayReject = reject; workerScript.delayReject = reject;
}); });
} }
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string { export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
if ((msg as any) instanceof WorkerScript) {
console.error("HERE");
}
const server = GetServer(workerScript.hostname); const server = GetServer(workerScript.hostname);
if (server == null) { if (server == null) {
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`); throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);

@ -88,6 +88,8 @@ import { dialogBoxCreate } from "./ui/React/DialogBox";
import { SnackbarEvents } from "./ui/React/Snackbar"; import { SnackbarEvents } from "./ui/React/Snackbar";
import { Flags } from "./NetscriptFunctions/Flags"; import { Flags } from "./NetscriptFunctions/Flags";
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
interface NS extends INS { interface NS extends INS {
[key: string]: any; [key: string]: any;
@ -692,7 +694,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
workerScript.log( workerScript.log(
"weaken", "weaken",
() => () =>
`'${server.hostname}' security level weakened to ${server.hackDifficulty `'${server.hostname}' security level weakened to ${
server.hackDifficulty
}. Gained ${numeralWrapper.formatExp(expGain)} hacking exp (t=${numeralWrapper.formatThreads(threads)})`, }. Gained ${numeralWrapper.formatExp(expGain)} hacking exp (t=${numeralWrapper.formatThreads(threads)})`,
); );
workerScript.scriptRef.onlineExpGained += expGain; workerScript.scriptRef.onlineExpGained += expGain;
@ -704,6 +707,17 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const coreBonus = 1 + (cores - 1) / 16; const coreBonus = 1 + (cores - 1) / 16;
return CONSTANTS.ServerWeakenAmount * threads * coreBonus; return CONSTANTS.ServerWeakenAmount * threads * coreBonus;
}, },
share: function (): Promise<void> {
workerScript.log("share", () => "Sharing this computer.");
const end = StartSharing(workerScript.scriptRef.threads * calculateIntelligenceBonus(Player.intelligence, 2));
return netscriptDelay(10000, workerScript).finally(function () {
workerScript.log("share", () => "Finished sharing this computer.");
end();
});
},
getSharePower: function(): number {
return CalculateShareMult();
},
print: function (...args: any[]): void { print: function (...args: any[]): void {
if (args.length === 0) { if (args.length === 0) {
throw makeRuntimeErrorMsg("print", "Takes at least 1 argument."); throw makeRuntimeErrorMsg("print", "Takes at least 1 argument.");
@ -762,7 +776,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}, },
disableLog: function (fn: any): any { disableLog: function (fn: any): any {
if (fn === "ALL") { if (fn === "ALL") {
for (fn in possibleLogs) { for (fn of Object.keys(possibleLogs)) {
workerScript.disableLogs[fn] = true; workerScript.disableLogs[fn] = true;
} }
workerScript.log("disableLog", () => `Disabled logging for all functions`); workerScript.log("disableLog", () => `Disabled logging for all functions`);
@ -775,7 +789,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}, },
enableLog: function (fn: any): any { enableLog: function (fn: any): any {
if (fn === "ALL") { if (fn === "ALL") {
for (fn in possibleLogs) { for (fn of Object.keys(possibleLogs)) {
delete workerScript.disableLogs[fn]; delete workerScript.disableLogs[fn];
} }
workerScript.log("enableLog", () => `Enabled logging for all functions`); workerScript.log("enableLog", () => `Enabled logging for all functions`);
@ -1302,8 +1316,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("ps", getRamCost(Player, "ps")); updateDynamicRam("ps", getRamCost(Player, "ps"));
const server = safeGetServer(hostname, "ps"); const server = safeGetServer(hostname, "ps");
const processes = []; const processes = [];
for (const i in server.runningScripts) { for (const script of server.runningScripts) {
const script = server.runningScripts[i];
processes.push({ processes.push({
filename: script.filename, filename: script.filename,
threads: script.threads, threads: script.threads,
@ -2269,8 +2282,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const source_is_txt = source.endsWith(".txt"); const source_is_txt = source.endsWith(".txt");
const dest_is_txt = destination.endsWith(".txt"); const dest_is_txt = destination.endsWith(".txt");
if (!isScriptFilename(source) && !source_is_txt) throw makeRuntimeErrorMsg("mv", `'mv' can only be used on scripts and text files (.txt)`); if (!isScriptFilename(source) && !source_is_txt)
if (source_is_txt != dest_is_txt) throw makeRuntimeErrorMsg("mv", `Source and destination files must have the same type`); throw makeRuntimeErrorMsg("mv", `'mv' can only be used on scripts and text files (.txt)`);
if (source_is_txt != dest_is_txt)
throw makeRuntimeErrorMsg("mv", `Source and destination files must have the same type`);
if (source === destination) { if (source === destination) {
return; return;
@ -2279,7 +2294,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
// This will throw if the server is not found, we do not need to validate result. // This will throw if the server is not found, we do not need to validate result.
const destServer: BaseServer | null = safeGetServer(host, "mv"); const destServer: BaseServer | null = safeGetServer(host, "mv");
if (!source_is_txt && destServer.isRunning(source)) throw makeRuntimeErrorMsg("mv", `Cannot use 'mv' on a script that is running`) if (!source_is_txt && destServer.isRunning(source))
throw makeRuntimeErrorMsg("mv", `Cannot use 'mv' on a script that is running`);
interface File { interface File {
filename: string; filename: string;
@ -2298,7 +2314,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
} }
if (source_file == null) throw makeRuntimeErrorMsg("mv", `Source file ${source} does not exist`) if (source_file == null) throw makeRuntimeErrorMsg("mv", `Source file ${source} does not exist`);
if (dest_file != null) { if (dest_file != null) {
if (dest_file instanceof TextFile && source_file instanceof TextFile) { if (dest_file instanceof TextFile && source_file instanceof TextFile) {

@ -101,7 +101,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation")); helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation"));
checkGangApiAccess("getOtherGangInformation"); checkGangApiAccess("getOtherGangInformation");
const cpy: any = {}; const cpy: any = {};
for (const gang in AllGangs) { for (const gang of Object.keys(AllGangs)) {
cpy[gang] = Object.assign({}, AllGangs[gang]); cpy[gang] = Object.assign({}, AllGangs[gang]);
} }

@ -113,7 +113,7 @@ export function NetscriptSingularity(
// If player has a gang with this faction, return all augmentations. // If player has a gang with this faction, return all augmentations.
if (player.hasGangWith(facname)) { if (player.hasGangWith(facname)) {
const res = []; const res = [];
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const aug = Augmentations[augName]; const aug = Augmentations[augName];
@ -165,7 +165,7 @@ export function NetscriptSingularity(
let augs = []; let augs = [];
if (player.hasGangWith(faction)) { if (player.hasGangWith(faction)) {
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
if (augName === AugmentationNames.NeuroFluxGovernor) continue; if (augName === AugmentationNames.NeuroFluxGovernor) continue;
if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue; if (augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) continue;
const tempAug = Augmentations[augName]; const tempAug = Augmentations[augName];
@ -264,7 +264,7 @@ export function NetscriptSingularity(
return false; return false;
} }
Router.toLocation(location); Router.toLocation(location);
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 500); player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
return true; return true;
}, },
universityCourse: function (universityName: any, className: any, focus = true): any { universityCourse: function (universityName: any, className: any, focus = true): any {
@ -479,7 +479,7 @@ export function NetscriptSingularity(
player.loseMoney(CONSTANTS.TravelCost, "other"); player.loseMoney(CONSTANTS.TravelCost, "other");
player.city = cityname; player.city = cityname;
workerScript.log("travelToCity", () => `Traveled to ${cityname}`); workerScript.log("travelToCity", () => `Traveled to ${cityname}`);
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50); player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
return true; return true;
default: default:
workerScript.log("travelToCity", () => `Invalid city name: '${cityname}'.`); workerScript.log("travelToCity", () => `Invalid city name: '${cityname}'.`);
@ -515,7 +515,7 @@ export function NetscriptSingularity(
player.getHomeComputer().serversOnNetwork.push(darkweb.hostname); player.getHomeComputer().serversOnNetwork.push(darkweb.hostname);
darkweb.serversOnNetwork.push(player.getHomeComputer().hostname); darkweb.serversOnNetwork.push(player.getHomeComputer().hostname);
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50); player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 500);
workerScript.log("purchaseTor", () => "You have purchased a Tor router!"); workerScript.log("purchaseTor", () => "You have purchased a Tor router!");
return true; return true;
}, },
@ -555,7 +555,7 @@ export function NetscriptSingularity(
"purchaseProgram", "purchaseProgram",
() => `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.`,
); );
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50); player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
return true; return true;
}, },
getCurrentServer: function (): any { getCurrentServer: function (): any {

@ -273,7 +273,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const orders: any = {}; const orders: any = {};
const stockMarketOrders = StockMarket["Orders"]; const stockMarketOrders = StockMarket["Orders"];
for (const symbol in stockMarketOrders) { for (const symbol of Object.keys(stockMarketOrders)) {
const orderBook = stockMarketOrders[symbol]; const orderBook = stockMarketOrders[symbol];
if (orderBook.constructor === Array && orderBook.length > 0) { if (orderBook.constructor === Array && orderBook.length > 0) {
orders[symbol] = []; orders[symbol] = [];

@ -2,11 +2,13 @@ import { INetscriptHelper } from "./INetscriptHelper";
import { WorkerScript } from "../Netscript/WorkerScript"; import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { getRamCost } from "../Netscript/RamCostGenerator"; import { getRamCost } from "../Netscript/RamCostGenerator";
import { IStyleSettings, UserInterface as IUserInterface, UserInterfaceTheme } from "../ScriptEditor/NetscriptDefinitions"; import { GameInfo, IStyleSettings, UserInterface as IUserInterface, UserInterfaceTheme } from "../ScriptEditor/NetscriptDefinitions";
import { Settings } from "../Settings/Settings"; import { Settings } from "../Settings/Settings";
import { ThemeEvents } from "../ui/React/Theme"; import { ThemeEvents } from "../ui/React/Theme";
import { defaultTheme } from "../Settings/Themes"; import { defaultTheme } from "../Settings/Themes";
import { defaultStyles } from "../Settings/Styles"; import { defaultStyles } from "../Settings/Styles";
import { CONSTANTS } from "../Constants";
import { hash } from "../hash/hash";
export function NetscriptUserInterface( export function NetscriptUserInterface(
player: IPlayer, player: IPlayer,
@ -84,6 +86,19 @@ export function NetscriptUserInterface(
Settings.styles = { ...defaultStyles }; Settings.styles = { ...defaultStyles };
ThemeEvents.emit(); ThemeEvents.emit();
workerScript.log("ui.resetStyles", () => `Reinitialized styles to default`); workerScript.log("ui.resetStyles", () => `Reinitialized styles to default`);
},
getGameInfo: function (): GameInfo {
helper.updateDynamicRam("getGameInfo", getRamCost(player, "ui", "getGameInfo"));
const version = CONSTANTS.VersionString;
const commit = hash();
const platform = (navigator.userAgent.toLowerCase().indexOf(" electron/") > -1) ? 'Steam' : 'Browser';
const gameInfo = {
version, commit, platform,
}
return gameInfo;
} }
} }
} }

@ -28,7 +28,7 @@ export function toNative(pseudoObj: any): any {
} else { } else {
// Object. // Object.
nativeObj = {}; nativeObj = {};
for (const key in pseudoObj.properties) { for (const key of Object.keys(pseudoObj.properties)) {
const val = pseudoObj.properties[key]; const val = pseudoObj.properties[key];
nativeObj[key] = toNative(val); nativeObj[key] = toNative(val);
} }

@ -82,6 +82,16 @@ export async function executeJSScript(
return loadedModule.main(ns); return loadedModule.main(ns);
} }
function isDependencyOutOfDate(filename: string, scripts: Script[], scriptModuleSequenceNumber: number): boolean {
const depScript = scripts.find((s) => s.filename == filename);
// If the script is not present on the server, we should recompile, if only to get any necessary
// compilation errors.
if (!depScript) return true;
const depIsMoreRecent = depScript.moduleSequenceNumber > scriptModuleSequenceNumber;
return depIsMoreRecent;
}
/** Returns whether we should compile the script parameter. /** Returns whether we should compile the script parameter.
* *
* @param {Script} script * @param {Script} script
@ -89,16 +99,7 @@ export async function executeJSScript(
*/ */
function shouldCompile(script: Script, scripts: Script[]): boolean { function shouldCompile(script: Script, scripts: Script[]): boolean {
if (script.module === "") return true; if (script.module === "") return true;
return script.dependencies.some((dep) => { return script.dependencies.some((dep) => isDependencyOutOfDate(dep.filename, scripts, script.moduleSequenceNumber));
const depScript = scripts.find((s) => s.filename == dep.filename);
// If the script is not present on the server, we should recompile, if only to get any necessary
// compilation errors.
if (!depScript) return true;
const depIsMoreRecent = depScript.moduleSequenceNumber > script.moduleSequenceNumber;
return depIsMoreRecent;
});
} }
// Gets a stack of blob urls, the top/right-most element being // Gets a stack of blob urls, the top/right-most element being
@ -123,8 +124,13 @@ function shouldCompile(script: Script, scripts: Script[]): boolean {
// BUG: apparently seen is never consulted. Oops. // BUG: apparently seen is never consulted. Oops.
function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): ScriptUrl[] { function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): ScriptUrl[] {
// Inspired by: https://stackoverflow.com/a/43834063/91401 // Inspired by: https://stackoverflow.com/a/43834063/91401
/** @type {ScriptUrl[]} */ const urlStack: ScriptUrl[] = [];
const urlStack = []; // Seen contains the dependents of the current script. Make sure we include that in the script dependents.
for (const dependent of seen) {
if (!script.dependents.some((s) => s.server === dependent.server && s.filename == dependent.filename)) {
script.dependents.push({ server: dependent.server, filename: dependent.filename });
}
}
seen.push(script); seen.push(script);
try { try {
// Replace every import statement with an import to a blob url containing // Replace every import statement with an import to a blob url containing
@ -149,7 +155,7 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
importNodes.push({ importNodes.push({
filename: node.source.value, filename: node.source.value,
start: node.source.range[0] + 1, start: node.source.range[0] + 1,
end: node.source.range[1] - 1 end: node.source.range[1] - 1,
}); });
}, },
ExportNamedDeclaration(node: any) { ExportNamedDeclaration(node: any) {
@ -157,7 +163,7 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
importNodes.push({ importNodes.push({
filename: node.source.value, filename: node.source.value,
start: node.source.range[0] + 1, start: node.source.range[0] + 1,
end: node.source.range[1] - 1 end: node.source.range[1] - 1,
}); });
} }
}, },
@ -166,10 +172,10 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
importNodes.push({ importNodes.push({
filename: node.source.value, filename: node.source.value,
start: node.source.range[0] + 1, start: node.source.range[0] + 1,
end: node.source.range[1] - 1 end: node.source.range[1] - 1,
}); });
} }
} },
}); });
// Sort the nodes from last start index to first. This replaces the last import with a blob first, // Sort the nodes from last start index to first. This replaces the last import with a blob first,
// preventing the ranges for other imports from being shifted. // preventing the ranges for other imports from being shifted.
@ -187,6 +193,19 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
// Check to see if the urls for this script are stored in the cache by the hash value. // Check to see if the urls for this script are stored in the cache by the hash value.
let urls = ImportCache.get(importedScript.hash()); let urls = ImportCache.get(importedScript.hash());
// If we don't have it in the cache, then we need to generate the urls for it. // If we don't have it in the cache, then we need to generate the urls for it.
if (urls) {
// Verify that these urls are valid and have not been updated.
for (const url of urls) {
if (isDependencyOutOfDate(url.filename, scripts, url.moduleSequenceNumber)) {
// Revoke these URLs from the browser. We will be unable to use them again.
for (const url of urls) URL.revokeObjectURL(url.url);
// Clear the cache and prepare for new blobs.
urls = null;
ImportCache.remove(importedScript.hash());
break;
}
}
}
if (!urls) { if (!urls) {
// Try to get a URL for the requested script and its dependencies. // Try to get a URL for the requested script and its dependencies.
urls = _getScriptUrls(importedScript, scripts, seen); urls = _getScriptUrls(importedScript, scripts, seen);
@ -217,11 +236,11 @@ function _getScriptUrls(script: Script, scripts: Script[], seen: Script[]): Scri
// (e.g. same scripts on server, same hash value, etc) can use this blob url. // (e.g. same scripts on server, same hash value, etc) can use this blob url.
BlobCache.store(transformedHash, blob); BlobCache.store(transformedHash, blob);
// Push the blob URL onto the top of the stack. // Push the blob URL onto the top of the stack.
urlStack.push(new ScriptUrl(script.filename, blob)); urlStack.push(new ScriptUrl(script.filename, blob, script.moduleSequenceNumber));
return urlStack; return urlStack;
} catch (err) { } catch (err) {
// If there is an error, we need to clean up the URLs. // If there is an error, we need to clean up the URLs.
for (const url in urlStack) URL.revokeObjectURL(url); for (const url of urlStack) URL.revokeObjectURL(url.url);
throw err; throw err;
} finally { } finally {
seen.pop(); seen.pop();

@ -116,11 +116,11 @@ function startNetscript2Script(player: IPlayer, workerScript: WorkerScript): Pro
}; };
} }
for (const prop in workerScript.env.vars) { for (const prop of Object.keys(workerScript.env.vars)) {
if (typeof workerScript.env.vars[prop] !== "function") continue; if (typeof workerScript.env.vars[prop] !== "function") continue;
workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]); workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
} }
workerScript.env.vars.stanek.charge = wrap("stanek.prop", workerScript.env.vars.stanek.charge); workerScript.env.vars.stanek.charge = wrap("stanek.charge", workerScript.env.vars.stanek.charge);
// Note: the environment that we pass to the JS script only needs to contain the functions visible // Note: the environment that we pass to the JS script only needs to contain the functions visible
// to that script, which env.vars does at this point. // to that script, which env.vars does at this point.
@ -131,7 +131,6 @@ function startNetscript2Script(player: IPlayer, workerScript: WorkerScript): Pro
}) })
.catch((e) => reject(e)); .catch((e) => reject(e));
}).catch((e) => { }).catch((e) => {
console.log(e);
if (e instanceof Error) { if (e instanceof Error) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, e.message + " (sorry we can't be more helpful)"); workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, e.message + " (sorry we can't be more helpful)");
@ -175,7 +174,7 @@ function startNetscript1Script(workerScript: WorkerScript): Promise<WorkerScript
const interpreterInitialization = function (int: any, scope: any): void { const interpreterInitialization = function (int: any, scope: any): void {
//Add the Netscript environment //Add the Netscript environment
const ns = NetscriptFunctions(workerScript); const ns = NetscriptFunctions(workerScript);
for (const name in ns) { for (const name of Object.keys(ns)) {
const entry = ns[name]; const entry = ns[name];
if (typeof entry === "function") { if (typeof entry === "function") {
//Async functions need to be wrapped. See JS-Interpreter documentation //Async functions need to be wrapped. See JS-Interpreter documentation

@ -0,0 +1,13 @@
import { CalculateShareMult as CSM } from "./formulas/share";
export let sharePower = 1;
export function StartSharing(threads: number): () => void {
sharePower += threads;
return () => (sharePower -= threads);
}
export function CalculateShareMult(): number {
console.log(`${sharePower} => ${CSM(sharePower)}`);
return CSM(sharePower);
}

@ -0,0 +1,5 @@
export function CalculateShareMult(power: number): number {
const x = 1 + Math.log(power) / (8 * Math.log(1000));
if (isNaN(x) || !isFinite(x)) return 1;
return x;
}

@ -112,7 +112,7 @@ export abstract class Person {
* Updates this object's multipliers for the given augmentation * Updates this object's multipliers for the given augmentation
*/ */
applyAugmentation(aug: Augmentation): void { applyAugmentation(aug: Augmentation): void {
for (const mult in aug.mults) { for (const mult of Object.keys(aug.mults)) {
if ((this as any)[mult] == null) { if ((this as any)[mult] == null) {
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`); console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
} else { } else {

@ -1485,7 +1485,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
if (determineCrimeSuccess(this, this.crimeType)) { if (determineCrimeSuccess(this, this.crimeType)) {
//Handle Karma and crime statistics //Handle Karma and crime statistics
let crime = null; let crime = null;
for (const i in Crimes) { for (const i of Object.keys(Crimes)) {
if (Crimes[i].type == this.crimeType) { if (Crimes[i].type == this.crimeType) {
crime = Crimes[i]; crime = Crimes[i];
break; break;
@ -2557,15 +2557,15 @@ export function setBitNodeNumber(this: IPlayer, n: number): void {
} }
export function queueAugmentation(this: IPlayer, name: string): void { export function queueAugmentation(this: IPlayer, name: string): void {
for (const i in this.queuedAugmentations) { for (const aug of this.queuedAugmentations) {
if (this.queuedAugmentations[i].name == name) { if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`); console.warn(`tried to queue ${name} twice, this may be a bug`);
return; return;
} }
} }
for (const i in this.augmentations) { for (const aug of this.augmentations) {
if (this.augmentations[i].name == name) { if (aug.name == name) {
console.warn(`tried to queue ${name} twice, this may be a bug`); console.warn(`tried to queue ${name} twice, this may be a bug`);
return; return;
} }

@ -37,7 +37,7 @@ export function purchaseResleeve(r: Resleeve, p: IPlayer): boolean {
p.charisma_exp = r.charisma_exp; p.charisma_exp = r.charisma_exp;
// Reset Augmentation "owned" data // Reset Augmentation "owned" data
for (const augKey in Augmentations) { for (const augKey of Object.keys(Augmentations)) {
Augmentations[augKey].owned = false; Augmentations[augKey].owned = false;
} }

@ -42,7 +42,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
if (p.inGang()) { if (p.inGang()) {
const fac = p.getGangFaction(); const fac = p.getGangFaction();
for (const augName in Augmentations) { for (const augName of Object.keys(Augmentations)) {
const aug = Augmentations[augName]; const aug = Augmentations[augName];
if (!isAvailableForSleeve(aug)) { if (!isAvailableForSleeve(aug)) {
continue; continue;

@ -2,6 +2,7 @@ import { IPlayer } from "../IPlayer";
import { Faction } from "../../Faction/Faction"; import { Faction } from "../../Faction/Faction";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
import { CalculateShareMult } from "../../NetworkShare/Share";
function mult(f: Faction): number { function mult(f: Faction): number {
let favorMult = 1 + f.favor / 100; let favorMult = 1 + f.favor / 100;
@ -16,7 +17,8 @@ export function getHackingWorkRepGain(p: IPlayer, f: Faction): number {
((p.hacking + p.intelligence / 3) / CONSTANTS.MaxSkillLevel) * ((p.hacking + p.intelligence / 3) / CONSTANTS.MaxSkillLevel) *
p.faction_rep_mult * p.faction_rep_mult *
p.getIntelligenceBonus(1) * p.getIntelligenceBonus(1) *
mult(f) mult(f) *
CalculateShareMult()
); );
} }

@ -75,14 +75,14 @@ export function prestigeAugmentation(): void {
initForeignServers(Player.getHomeComputer()); initForeignServers(Player.getHomeComputer());
// Gain favor for Companies // Gain favor for Companies
for (const member in Companies) { for (const member of Object.keys(Companies)) {
if (Companies.hasOwnProperty(member)) { if (Companies.hasOwnProperty(member)) {
Companies[member].gainFavor(); Companies[member].gainFavor();
} }
} }
// Gain favor for factions // Gain favor for factions
for (const member in Factions) { for (const member of Object.keys(Factions)) {
if (Factions.hasOwnProperty(member)) { if (Factions.hasOwnProperty(member)) {
Factions[member].gainFavor(); Factions[member].gainFavor();
} }
@ -113,6 +113,15 @@ export function prestigeAugmentation(): void {
if (faction instanceof Faction) { if (faction instanceof Faction) {
joinFaction(faction); joinFaction(faction);
} }
const penalty = 0.95;
for (const m of gang.members) {
m.hack_asc_points *= penalty;
m.str_asc_points *= penalty;
m.def_asc_points *= penalty;
m.dex_asc_points *= penalty;
m.agi_asc_points *= penalty;
m.cha_asc_points *= penalty;
}
} }
// BitNode 3: Corporatocracy // BitNode 3: Corporatocracy
@ -200,14 +209,14 @@ export function prestigeSourceFile(flume: boolean): void {
homeComp.cpuCores = 1; homeComp.cpuCores = 1;
// Reset favor for Companies // Reset favor for Companies
for (const member in Companies) { for (const member of Object.keys(Companies)) {
if (Companies.hasOwnProperty(member)) { if (Companies.hasOwnProperty(member)) {
Companies[member].favor = 0; Companies[member].favor = 0;
} }
} }
// Reset favor for factions // Reset favor for factions
for (const member in Factions) { for (const member of Object.keys(Factions)) {
if (Factions.hasOwnProperty(member)) { if (Factions.hasOwnProperty(member)) {
Factions[member].favor = 0; Factions[member].favor = 0;
} }
@ -219,7 +228,7 @@ export function prestigeSourceFile(flume: boolean): void {
} }
// Delete all Augmentations // Delete all Augmentations
for (const name in Augmentations) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
delete Augmentations[name]; delete Augmentations[name];
} }
@ -242,7 +251,7 @@ export function prestigeSourceFile(flume: boolean): void {
// Messages // Messages
initMessages(); initMessages();
if (Player.sourceFileLvl(5) > 0) { if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) {
homeComp.programs.push(Programs.Formulas.name); homeComp.programs.push(Programs.Formulas.name);
} }

@ -6,7 +6,7 @@ import { IPlayer } from "../PersonObjects/IPlayer";
//Returns the programs this player can create. //Returns the programs this player can create.
export function getAvailableCreatePrograms(player: IPlayer): Program[] { export function getAvailableCreatePrograms(player: IPlayer): Program[] {
const programs: Program[] = []; const programs: Program[] = [];
for (const key in Programs) { for (const key of Object.keys(Programs)) {
// Non-creatable program // Non-creatable program
const create = Programs[key].create; const create = Programs[key].create;
if (create == null) continue; if (create == null) continue;

@ -115,7 +115,7 @@ function evaluateVersionCompatibility(ver: string | number): void {
} }
// The "companyName" property of all Companies is renamed to "name" // The "companyName" property of all Companies is renamed to "name"
for (const companyName in Companies) { for (const companyName of Object.keys(Companies)) {
const company: any = Companies[companyName]; const company: any = Companies[companyName];
if (company.name == 0 && company.companyName != null) { if (company.name == 0 && company.companyName != null) {
company.name = company.companyName; company.name = company.companyName;

@ -388,7 +388,8 @@ function parseOnlyCalculateDeps(code: string, currentModule: string): any {
} }
}, },
FunctionDeclaration: (node: any) => { FunctionDeclaration: (node: any) => {
const key = currentModule + "." + node.id.name; // node.id will be null when using 'export default'. Add a module name indicating the default export.
const key = currentModule + "." + (node.id === null ? "__SPECIAL_DEFAULT_EXPORT__" : node.id.name);
walk.recursive(node, { key: key }, commonVisitors()); walk.recursive(node, { key: key }, commonVisitors());
}, },
}, },

@ -10,10 +10,13 @@ import { ScriptUrl } from "./ScriptUrl";
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
import { roundToTwo } from "../utils/helpers/roundToTwo"; import { roundToTwo } from "../utils/helpers/roundToTwo";
import { computeHash } from "../utils/helpers/computeHash"; import { computeHash } from "../utils/helpers/computeHash";
import { ImportCache } from "../utils/ImportCache";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
let globalModuleSequenceNumber = 0; let globalModuleSequenceNumber = 0;
interface ScriptReference { filename: string; server: string }
export class Script { export class Script {
// Code for this script // Code for this script
code = ""; code = "";
@ -35,6 +38,7 @@ export class Script {
// whenever the script is first evaluated, and therefore may be out of date if the script // whenever the script is first evaluated, and therefore may be out of date if the script
// has been updated since it was last run. // has been updated since it was last run.
dependencies: ScriptUrl[] = []; dependencies: ScriptUrl[] = [];
dependents: ScriptReference[] = [];
// Amount of RAM this Script requres to run // Amount of RAM this Script requres to run
ramUsage = 0; ramUsage = 0;
@ -99,7 +103,11 @@ export class Script {
* Force update of the computed hash based on the source code. * Force update of the computed hash based on the source code.
*/ */
rehash(): void { rehash(): void {
const oldHash = this._hash;
this._hash = computeHash(this.code); this._hash = computeHash(this.code);
if (oldHash !== this._hash) {
ImportCache.remove(oldHash);
}
} }
/** /**
@ -124,6 +132,10 @@ export class Script {
this.server = hostname; this.server = hostname;
this.updateRamUsage(player, otherScripts); this.updateRamUsage(player, otherScripts);
this.markUpdated(); this.markUpdated();
for (const dependent of this.dependents) {
const [dependentScript] = otherScripts.filter(s => s.filename === dependent.filename && s.server == dependent.server);
if (dependentScript !== null) dependentScript.markUpdated();
}
} }
/** /**
@ -156,6 +168,7 @@ export class Script {
s.url = ""; s.url = "";
// Rehash the code to ensure that hash is set properly. // Rehash the code to ensure that hash is set properly.
s.rehash(); s.rehash();
s.dependents = [];
return s; return s;
} }

@ -27,7 +27,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
// Grow // Grow
for (const hostname in runningScript.dataMap) { for (const hostname of Object.keys(runningScript.dataMap)) {
if (runningScript.dataMap.hasOwnProperty(hostname)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) { if (runningScript.dataMap[hostname][2] == 0 || runningScript.dataMap[hostname][2] == null) {
continue; continue;
@ -60,7 +60,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
runningScript.offlineExpGained += expGain; runningScript.offlineExpGained += expGain;
// Weaken // Weaken
for (const hostname in runningScript.dataMap) { for (const hostname of Object.keys(runningScript.dataMap)) {
if (runningScript.dataMap.hasOwnProperty(hostname)) { if (runningScript.dataMap.hasOwnProperty(hostname)) {
if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) { if (runningScript.dataMap[hostname][3] == 0 || runningScript.dataMap[hostname][3] == null) {
continue; continue;

@ -1,9 +1,11 @@
export class ScriptUrl { export class ScriptUrl {
filename: string; filename: string;
url: string; url: string;
moduleSequenceNumber: number;
constructor(filename: string, url: string) { constructor(filename: string, url: string, moduleSequenceNumber: number) {
this.filename = filename; this.filename = filename;
this.url = url; this.url = url;
this.moduleSequenceNumber = moduleSequenceNumber;
} }
} }

@ -3932,7 +3932,7 @@ interface Stanek {
/** /**
* List possible fragments. * List possible fragments.
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns List of possible fragments. * @returns List of possible fragments.
*/ */
@ -3941,7 +3941,7 @@ interface Stanek {
/** /**
* List of fragments in Stanek's Gift. * List of fragments in Stanek's Gift.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @returns List of active fragments placed on Stanek's Gift. * @returns List of active fragments placed on Stanek's Gift.
*/ */
@ -3950,14 +3950,14 @@ interface Stanek {
/** /**
* Clear the board of all fragments. * Clear the board of all fragments.
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
clear(): void; clear(): void;
/** /**
* Check if fragment can be placed at specified location. * Check if fragment can be placed at specified location.
* @remarks * @remarks
* RAM cost: cost: 0.5 GB * RAM cost: 0.5 GB
* *
* @param rootX - rootX Root X against which to align the top left of the fragment. * @param rootX - rootX Root X against which to align the top left of the fragment.
* @param rootY - rootY Root Y against which to align the top left of the fragment. * @param rootY - rootY Root Y against which to align the top left of the fragment.
@ -3969,7 +3969,7 @@ interface Stanek {
/** /**
* Place fragment on Stanek's Gift. * Place fragment on Stanek's Gift.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -3981,7 +3981,7 @@ interface Stanek {
/** /**
* Get placed fragment at location. * Get placed fragment at location.
* @remarks * @remarks
* RAM cost: cost: 5 GB * RAM cost: 5 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -3992,7 +3992,7 @@ interface Stanek {
/** /**
* Remove fragment at location. * Remove fragment at location.
* @remarks * @remarks
* RAM cost: cost: 0.15 GB * RAM cost: 0.15 GB
* *
* @param rootX - X against which to align the top left of the fragment. * @param rootX - X against which to align the top left of the fragment.
* @param rootY - Y against which to align the top left of the fragment. * @param rootY - Y against which to align the top left of the fragment.
@ -4009,7 +4009,7 @@ interface UserInterface {
/** /**
* Get the current theme * Get the current theme
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns An object containing the theme's colors * @returns An object containing the theme's colors
*/ */
@ -4018,7 +4018,7 @@ interface UserInterface {
/** /**
* Sets the current theme * Sets the current theme
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* @example * @example
* Usage example (NS2) * Usage example (NS2)
* ```ts * ```ts
@ -4032,14 +4032,14 @@ interface UserInterface {
/** /**
* Resets the player's theme to the default values * Resets the player's theme to the default values
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
resetTheme(): void; resetTheme(): void;
/** /**
* Get the current styles * Get the current styles
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* *
* @returns An object containing the player's styles * @returns An object containing the player's styles
*/ */
@ -4048,7 +4048,7 @@ interface UserInterface {
/** /**
* Sets the current styles * Sets the current styles
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
* @example * @example
* Usage example (NS2) * Usage example (NS2)
* ```ts * ```ts
@ -4062,9 +4062,16 @@ interface UserInterface {
/** /**
* Resets the player's styles to the default values * Resets the player's styles to the default values
* @remarks * @remarks
* RAM cost: cost: 0 GB * RAM cost: 0 GB
*/ */
resetStyles(): void; resetStyles(): void;
/**
* Gets the current game information (version, commit, ...)
* @remarks
* RAM cost: 0 GB
*/
getGameInfo(): GameInfo;
} }
/** /**
@ -5175,9 +5182,9 @@ export interface NS extends Singularity {
* @remarks * @remarks
* RAM cost: 0.1 GB * RAM cost: 0.1 GB
* *
* Returns the servers instrinsic growth parameter. This growth * Returns the servers intrinsic growth parameter. This growth
* parameter is a number between 0 and 100 that represents how * parameter is a number typically between 0 and 100 that represents
* quickly the servers money grows. This parameter affects the * how quickly the servers money grows. This parameter affects the
* percentage by which the servers money is increased when using the * percentage by which the servers money is increased when using the
* grow function. A higher growth parameter will result in a * grow function. A higher growth parameter will result in a
* higher percentage increase from grow. * higher percentage increase from grow.
@ -6066,6 +6073,20 @@ export interface NS extends Singularity {
* ``` * ```
*/ */
flags(schema: [string, string | number | boolean | string[]][]): any; flags(schema: [string, string | number | boolean | string[]][]): any;
/**
* Share your computer with your factions. Increasing your rep gain for a short duration.
* @remarks
* RAM cost: 2.4 GB
*/
share(): Promise<void>;
/**
* Calculate your share power.
* @remarks
* RAM cost: 0.2 GB
*/
getSharePower(): number;
} }
/** /**
@ -6573,3 +6594,13 @@ interface IStyleSettings {
fontFamily: string; fontFamily: string;
lineHeight: number; lineHeight: number;
} }
/**
* Game Information
* @internal
*/
interface GameInfo {
version: string;
commit: string;
platform: string;
}

@ -20,7 +20,7 @@ import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
let AllServers: IMap<Server | HacknetServer> = {}; let AllServers: IMap<Server | HacknetServer> = {};
function GetServerByIP(ip: string): BaseServer | undefined { function GetServerByIP(ip: string): BaseServer | undefined {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.ip !== ip) continue; if (server.ip !== ip) continue;
return server; return server;
@ -30,7 +30,7 @@ function GetServerByIP(ip: string): BaseServer | undefined {
//Returns server object with corresponding hostname //Returns server object with corresponding hostname
// Relatively slow, would rather not use this a lot // Relatively slow, would rather not use this a lot
function GetServerByHostname(hostname: string): BaseServer | null { function GetServerByHostname(hostname: string): BaseServer | null {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.hostname == hostname) { if (server.hostname == hostname) {
return server; return server;
@ -58,14 +58,14 @@ export function GetServer(s: string): BaseServer | null {
export function GetAllServers(): BaseServer[] { export function GetAllServers(): BaseServer[] {
const servers: BaseServer[] = []; const servers: BaseServer[] = [];
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
servers.push(AllServers[key]); servers.push(AllServers[key]);
} }
return servers; return servers;
} }
export function DeleteServer(serverkey: string): void { export function DeleteServer(serverkey: string): void {
for (const key in AllServers) { for (const key of Object.keys(AllServers)) {
const server = AllServers[key]; const server = AllServers[key];
if (server.ip !== serverkey && server.hostname !== serverkey) continue; if (server.ip !== serverkey && server.hostname !== serverkey) continue;
delete AllServers[key]; delete AllServers[key];
@ -194,7 +194,7 @@ export function initForeignServers(homeComputer: Server): void {
} }
export function prestigeAllServers(): void { export function prestigeAllServers(): void {
for (const member in AllServers) { for (const member of Object.keys(AllServers)) {
delete AllServers[member]; delete AllServers[member];
} }
AllServers = {}; AllServers = {};
@ -206,7 +206,7 @@ export function loadAllServers(saveString: string): void {
export function saveAllServers(excludeRunningScripts = false): string { export function saveAllServers(excludeRunningScripts = false): string {
const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver); const TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
for (const key in TempAllServers) { for (const key of Object.keys(TempAllServers)) {
const server = TempAllServers[key]; const server = TempAllServers[key];
if (excludeRunningScripts) { if (excludeRunningScripts) {
server.runningScripts = []; server.runningScripts = [];

@ -142,6 +142,11 @@ interface IDefaultSettings {
* Character overview settings * Character overview settings
*/ */
overview: OverviewSettings; overview: OverviewSettings;
/**
* If the game's sidebar is opened
*/
IsSidebarOpened: boolean;
} }
/** /**
@ -194,6 +199,7 @@ export const defaultSettings: IDefaultSettings = {
SuppressSavedGameToast: false, SuppressSavedGameToast: false,
UseIEC60027_2: false, UseIEC60027_2: false,
ExcludeRunningScriptsFromSave: false, ExcludeRunningScriptsFromSave: false,
IsSidebarOpened: true,
theme: defaultTheme, theme: defaultTheme,
styles: defaultStyles, styles: defaultStyles,
@ -231,6 +237,8 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast, SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast,
UseIEC60027_2: defaultSettings.UseIEC60027_2, UseIEC60027_2: defaultSettings.UseIEC60027_2,
ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave, ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave,
IsSidebarOpened: defaultSettings.IsSidebarOpened,
MonacoTheme: "monokai", MonacoTheme: "monokai",
MonacoInsertSpaces: false, MonacoInsertSpaces: false,
MonacoFontSize: 20, MonacoFontSize: 20,

@ -106,6 +106,8 @@ interface IProps {
player: IPlayer; player: IPlayer;
router: IRouter; router: IRouter;
page: Page; page: Page;
opened: boolean;
onToggled: (newValue: boolean) => void;
} }
export function SidebarRoot(props: IProps): React.ReactElement { export function SidebarRoot(props: IProps): React.ReactElement {
@ -297,7 +299,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
} else if (event.keyCode === KEY.W && event.altKey) { } else if (event.keyCode === KEY.W && event.altKey) {
event.preventDefault(); event.preventDefault();
clickCity(); clickCity();
} else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey && props.player.hasJob()) { } else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey && canJob) {
// ctrl/cmd + alt + j is shortcut to open Chrome dev tools // ctrl/cmd + alt + j is shortcut to open Chrome dev tools
event.preventDefault(); event.preventDefault();
clickJob(); clickJob();
@ -319,10 +321,10 @@ export function SidebarRoot(props: IProps): React.ReactElement {
} else if (event.keyCode === KEY.U && event.altKey) { } else if (event.keyCode === KEY.U && event.altKey) {
event.preventDefault(); event.preventDefault();
clickTutorial(); clickTutorial();
} else if (event.keyCode === KEY.B && event.altKey) { } else if (event.keyCode === KEY.B && event.altKey && props.player.bladeburner) {
event.preventDefault(); event.preventDefault();
clickBladeburner(); clickBladeburner();
} else if (event.keyCode === KEY.G && event.altKey) { } else if (event.keyCode === KEY.G && event.altKey && props.player.gang) {
event.preventDefault(); event.preventDefault();
clickGang(); clickGang();
} }
@ -337,8 +339,13 @@ export function SidebarRoot(props: IProps): React.ReactElement {
}, []); }, []);
const classes = useStyles(); const classes = useStyles();
const [open, setOpen] = useState(true); const [open, setOpen] = useState(props.opened);
const toggleDrawer = (): void => setOpen((old) => !old); const toggleDrawer = (): void => setOpen((old) => !old);
useEffect(() => {
props.onToggled(open);
}, [open]);
return ( return (
<Drawer open={open} anchor="left" variant="permanent"> <Drawer open={open} anchor="left" variant="permanent">
<ListItem classes={{ root: classes.listitem }} button onClick={toggleDrawer}> <ListItem classes={{ root: classes.listitem }} button onClick={toggleDrawer}>
@ -357,7 +364,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<List> <List>
<ListItem classes={{ root: classes.listitem }} button onClick={() => setHackingOpen((old) => !old)}> <ListItem classes={{ root: classes.listitem }} button onClick={() => setHackingOpen((old) => !old)}>
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Hacking" : ""}>
<ComputerIcon color="primary" /> <ComputerIcon color="primary" />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText primary={<Typography>Hacking</Typography>} /> <ListItemText primary={<Typography>Hacking</Typography>} />
{hackingOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />} {hackingOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />}
@ -374,9 +383,11 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickTerminal} onClick={clickTerminal}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Terminal" : ""}>
<LastPageIcon <LastPageIcon
color={flashTerminal ? "error" : props.page !== Page.Terminal ? "secondary" : "primary"} color={flashTerminal ? "error" : props.page !== Page.Terminal ? "secondary" : "primary"}
/> />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={flashTerminal ? "error" : props.page !== Page.Terminal ? "secondary" : "primary"}> <Typography color={flashTerminal ? "error" : props.page !== Page.Terminal ? "secondary" : "primary"}>
@ -394,7 +405,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickScriptEditor} onClick={clickScriptEditor}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Script Editor" : ""}>
<CreateIcon color={props.page !== Page.ScriptEditor ? "secondary" : "primary"} /> <CreateIcon color={props.page !== Page.ScriptEditor ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.ScriptEditor ? "secondary" : "primary"}> <Typography color={props.page !== Page.ScriptEditor ? "secondary" : "primary"}>
@ -412,9 +425,11 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickActiveScripts} onClick={clickActiveScripts}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Active Scripts" : ""}>
<StorageIcon <StorageIcon
color={flashActiveScripts ? "error" : props.page !== Page.ActiveScripts ? "secondary" : "primary"} color={flashActiveScripts ? "error" : props.page !== Page.ActiveScripts ? "secondary" : "primary"}
/> />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography <Typography
@ -435,7 +450,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
> >
<ListItemIcon> <ListItemIcon>
<Badge badgeContent={programCount > 0 ? programCount : undefined} color="error"> <Badge badgeContent={programCount > 0 ? programCount : undefined} color="error">
<Tooltip title={!open ? "Create Program" : ""}>
<BugReportIcon color={props.page !== Page.CreateProgram ? "secondary" : "primary"} /> <BugReportIcon color={props.page !== Page.CreateProgram ? "secondary" : "primary"} />
</Tooltip>
</Badge> </Badge>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
@ -455,7 +472,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickStaneksGift} onClick={clickStaneksGift}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Stanek's Gift" : ""}>
<DeveloperBoardIcon color={props.page !== Page.StaneksGift ? "secondary" : "primary"} /> <DeveloperBoardIcon color={props.page !== Page.StaneksGift ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.StaneksGift ? "secondary" : "primary"}> <Typography color={props.page !== Page.StaneksGift ? "secondary" : "primary"}>
@ -470,7 +489,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<Divider /> <Divider />
<ListItem classes={{ root: classes.listitem }} button onClick={() => setCharacterOpen((old) => !old)}> <ListItem classes={{ root: classes.listitem }} button onClick={() => setCharacterOpen((old) => !old)}>
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Character" : ""}>
<AccountBoxIcon color="primary" /> <AccountBoxIcon color="primary" />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText primary={<Typography>Character</Typography>} /> <ListItemText primary={<Typography>Character</Typography>} />
{characterOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />} {characterOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />}
@ -485,7 +506,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickStats} onClick={clickStats}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Stats" : ""}>
<EqualizerIcon color={flashStats ? "error" : props.page !== Page.Stats ? "secondary" : "primary"} /> <EqualizerIcon color={flashStats ? "error" : props.page !== Page.Stats ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={flashStats ? "error" : props.page !== Page.Stats ? "secondary" : "primary"}> <Typography color={flashStats ? "error" : props.page !== Page.Stats ? "secondary" : "primary"}>
@ -505,7 +528,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
> >
<ListItemIcon> <ListItemIcon>
<Badge badgeContent={invitationsCount !== 0 ? invitationsCount : undefined} color="error"> <Badge badgeContent={invitationsCount !== 0 ? invitationsCount : undefined} color="error">
<Tooltip title={!open ? "Factions" : ""}>
<ContactsIcon color={![Page.Factions, Page.Faction].includes(props.page) ? "secondary" : "primary"} /> <ContactsIcon color={![Page.Factions, Page.Faction].includes(props.page) ? "secondary" : "primary"} />
</Tooltip>
</Badge> </Badge>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
@ -527,10 +552,12 @@ export function SidebarRoot(props: IProps): React.ReactElement {
> >
<ListItemIcon> <ListItemIcon>
<Badge badgeContent={augmentationCount !== 0 ? augmentationCount : undefined} color="error"> <Badge badgeContent={augmentationCount !== 0 ? augmentationCount : undefined} color="error">
<Tooltip title={!open ? "Augmentations" : ""}>
<DoubleArrowIcon <DoubleArrowIcon
style={{ transform: "rotate(-90deg)" }} style={{ transform: "rotate(-90deg)" }}
color={props.page !== Page.Augmentations ? "secondary" : "primary"} color={props.page !== Page.Augmentations ? "secondary" : "primary"}
/> />
</Tooltip>
</Badge> </Badge>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
@ -549,7 +576,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickHacknet} onClick={clickHacknet}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Hacknet" : ""}>
<AccountTreeIcon color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"} /> <AccountTreeIcon color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"}> <Typography color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"}>
@ -568,7 +597,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickSleeves} onClick={clickSleeves}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Sleeves" : ""}>
<PeopleAltIcon color={props.page !== Page.Sleeves ? "secondary" : "primary"} /> <PeopleAltIcon color={props.page !== Page.Sleeves ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Sleeves ? "secondary" : "primary"}>Sleeves</Typography> <Typography color={props.page !== Page.Sleeves ? "secondary" : "primary"}>Sleeves</Typography>
@ -580,7 +611,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<Divider /> <Divider />
<ListItem classes={{ root: classes.listitem }} button onClick={() => setWorldOpen((old) => !old)}> <ListItem classes={{ root: classes.listitem }} button onClick={() => setWorldOpen((old) => !old)}>
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "World" : ""}>
<PublicIcon color="primary" /> <PublicIcon color="primary" />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText primary={<Typography>World</Typography>} /> <ListItemText primary={<Typography>World</Typography>} />
{worldOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />} {worldOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />}
@ -596,7 +629,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickCity} onClick={clickCity}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "City" : ""}>
<LocationCityIcon color={flashCity ? "error" : props.page !== Page.City ? "secondary" : "primary"} /> <LocationCityIcon color={flashCity ? "error" : props.page !== Page.City ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={flashCity ? "error" : props.page !== Page.City ? "secondary" : "primary"}> <Typography color={flashCity ? "error" : props.page !== Page.City ? "secondary" : "primary"}>
@ -613,7 +648,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickTravel} onClick={clickTravel}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Travel" : ""}>
<AirplanemodeActiveIcon color={props.page !== Page.Travel ? "secondary" : "primary"} /> <AirplanemodeActiveIcon color={props.page !== Page.Travel ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Travel ? "secondary" : "primary"}>Travel</Typography> <Typography color={props.page !== Page.Travel ? "secondary" : "primary"}>Travel</Typography>
@ -630,7 +667,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickJob} onClick={clickJob}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Job" : ""}>
<WorkIcon color={props.page !== Page.Job ? "secondary" : "primary"} /> <WorkIcon color={props.page !== Page.Job ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Job ? "secondary" : "primary"}>Job</Typography> <Typography color={props.page !== Page.Job ? "secondary" : "primary"}>Job</Typography>
@ -648,7 +687,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickStockMarket} onClick={clickStockMarket}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Stock Market" : ""}>
<TrendingUpIcon color={props.page !== Page.StockMarket ? "secondary" : "primary"} /> <TrendingUpIcon color={props.page !== Page.StockMarket ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.StockMarket ? "secondary" : "primary"}>Stock Market</Typography> <Typography color={props.page !== Page.StockMarket ? "secondary" : "primary"}>Stock Market</Typography>
@ -666,7 +707,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickBladeburner} onClick={clickBladeburner}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Bladeburner" : ""}>
<FormatBoldIcon color={props.page !== Page.Bladeburner ? "secondary" : "primary"} /> <FormatBoldIcon color={props.page !== Page.Bladeburner ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Bladeburner ? "secondary" : "primary"}>Bladeburner</Typography> <Typography color={props.page !== Page.Bladeburner ? "secondary" : "primary"}>Bladeburner</Typography>
@ -684,7 +727,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickCorp} onClick={clickCorp}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Corp" : ""}>
<BusinessIcon color={props.page !== Page.Corporation ? "secondary" : "primary"} /> <BusinessIcon color={props.page !== Page.Corporation ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Corporation ? "secondary" : "primary"}>Corp</Typography> <Typography color={props.page !== Page.Corporation ? "secondary" : "primary"}>Corp</Typography>
@ -702,7 +747,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickGang} onClick={clickGang}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Gang" : ""}>
<SportsMmaIcon color={props.page !== Page.Gang ? "secondary" : "primary"} /> <SportsMmaIcon color={props.page !== Page.Gang ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Gang ? "secondary" : "primary"}>Gang</Typography> <Typography color={props.page !== Page.Gang ? "secondary" : "primary"}>Gang</Typography>
@ -714,7 +761,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<Divider /> <Divider />
<ListItem classes={{ root: classes.listitem }} button onClick={() => setHelpOpen((old) => !old)}> <ListItem classes={{ root: classes.listitem }} button onClick={() => setHelpOpen((old) => !old)}>
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Help" : ""}>
<LiveHelpIcon color="primary" /> <LiveHelpIcon color="primary" />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText primary={<Typography>Help</Typography>} /> <ListItemText primary={<Typography>Help</Typography>} />
{helpOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />} {helpOpen ? <ExpandLessIcon color="primary" /> : <ExpandMoreIcon color="primary" />}
@ -729,7 +778,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickMilestones} onClick={clickMilestones}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Milestones" : ""}>
<CheckIcon color={props.page !== Page.Milestones ? "secondary" : "primary"} /> <CheckIcon color={props.page !== Page.Milestones ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Milestones ? "secondary" : "primary"}>Milestones</Typography> <Typography color={props.page !== Page.Milestones ? "secondary" : "primary"}>Milestones</Typography>
@ -744,7 +795,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickTutorial} onClick={clickTutorial}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Tutorial" : ""}>
<HelpIcon color={flashTutorial ? "error" : props.page !== Page.Tutorial ? "secondary" : "primary"} /> <HelpIcon color={flashTutorial ? "error" : props.page !== Page.Tutorial ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={flashTutorial ? "error" : props.page !== Page.Tutorial ? "secondary" : "primary"}> <Typography color={flashTutorial ? "error" : props.page !== Page.Tutorial ? "secondary" : "primary"}>
@ -761,7 +814,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickAchievements} onClick={clickAchievements}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Achievements" : ""}>
<EmojiEventsIcon color={props.page !== Page.Achievements ? "secondary" : "primary"} /> <EmojiEventsIcon color={props.page !== Page.Achievements ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Achievements ? "secondary" : "primary"}>Achievements</Typography> <Typography color={props.page !== Page.Achievements ? "secondary" : "primary"}>Achievements</Typography>
@ -776,7 +831,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickOptions} onClick={clickOptions}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Options" : ""}>
<SettingsIcon color={props.page !== Page.Options ? "secondary" : "primary"} /> <SettingsIcon color={props.page !== Page.Options ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.Options ? "secondary" : "primary"}>Options</Typography> <Typography color={props.page !== Page.Options ? "secondary" : "primary"}>Options</Typography>
@ -793,7 +850,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
onClick={clickDev} onClick={clickDev}
> >
<ListItemIcon> <ListItemIcon>
<Tooltip title={!open ? "Dev" : ""}>
<DeveloperBoardIcon color={props.page !== Page.DevMenu ? "secondary" : "primary"} /> <DeveloperBoardIcon color={props.page !== Page.DevMenu ? "secondary" : "primary"} />
</Tooltip>
</ListItemIcon> </ListItemIcon>
<ListItemText> <ListItemText>
<Typography color={props.page !== Page.DevMenu ? "secondary" : "primary"}>Dev</Typography> <Typography color={props.page !== Page.DevMenu ? "secondary" : "primary"}>Dev</Typography>

@ -42,7 +42,7 @@ export function processOrders(
const orderBook = refs.stockMarket["Orders"]; const orderBook = refs.stockMarket["Orders"];
if (orderBook == null) { if (orderBook == null) {
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in refs.stockMarket) { for (const name of Object.keys(refs.stockMarket)) {
const stock = refs.stockMarket[name]; const stock = refs.stockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;

@ -55,7 +55,7 @@ export function placeOrder(
const order = new Order(stock.symbol, shares, price, type, position); const order = new Order(stock.symbol, shares, price, type, position);
if (StockMarket["Orders"] == null) { if (StockMarket["Orders"] == null) {
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stk = StockMarket[name]; const stk = StockMarket[name];
if (!(stk instanceof Stock)) { if (!(stk instanceof Stock)) {
continue; continue;
@ -157,7 +157,7 @@ export function deleteStockMarket(): void {
} }
export function initStockMarket(): void { export function initStockMarket(): void {
for (const stk in StockMarket) { for (const stk of Object.keys(StockMarket)) {
if (StockMarket.hasOwnProperty(stk)) { if (StockMarket.hasOwnProperty(stk)) {
delete StockMarket[stk]; delete StockMarket[stk];
} }
@ -169,7 +169,7 @@ export function initStockMarket(): void {
} }
const orders: IOrderBook = {}; const orders: IOrderBook = {};
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;
@ -184,7 +184,7 @@ export function initStockMarket(): void {
} }
export function initSymbolToStockMap(): void { export function initSymbolToStockMap(): void {
for (const name in StockSymbols) { for (const name of Object.keys(StockSymbols)) {
if (StockSymbols.hasOwnProperty(name)) { if (StockSymbols.hasOwnProperty(name)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (stock == null) { if (stock == null) {
@ -198,7 +198,7 @@ export function initSymbolToStockMap(): void {
} }
function stockMarketCycle(): void { function stockMarketCycle(): void {
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;
@ -247,7 +247,7 @@ export function processStockPrices(numCycles = 1): void {
} }
const v = Math.random(); const v = Math.random();
for (const name in StockMarket) { for (const name of Object.keys(StockMarket)) {
const stock = StockMarket[name]; const stock = StockMarket[name];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;

@ -5,7 +5,7 @@ export const TickerHeaderFormatData = {
longestSymbol: 0, longestSymbol: 0,
}; };
for (const key in StockSymbols) { for (const key of Object.keys(StockSymbols)) {
TickerHeaderFormatData.longestName = Math.max(key.length, TickerHeaderFormatData.longestName); TickerHeaderFormatData.longestName = Math.max(key.length, TickerHeaderFormatData.longestName);
TickerHeaderFormatData.longestSymbol = Math.max(StockSymbols[key].length, TickerHeaderFormatData.longestSymbol); TickerHeaderFormatData.longestSymbol = Math.max(StockSymbols[key].length, TickerHeaderFormatData.longestSymbol);
} }

@ -66,7 +66,7 @@ export function StockTickers(props: IProps): React.ReactElement {
} }
const tickers: React.ReactElement[] = []; const tickers: React.ReactElement[] = [];
for (const stockMarketProp in props.stockMarket) { for (const stockMarketProp of Object.keys(props.stockMarket)) {
const val = props.stockMarket[stockMarketProp]; const val = props.stockMarket[stockMarketProp];
if (val instanceof Stock) { if (val instanceof Stock) {
// Skip if there's a filter and the stock isnt in that filter // Skip if there's a filter and the stock isnt in that filter

@ -7,7 +7,7 @@ export const TerminalHelpText: string[] = [
' alias [-g] [name="value"] Create or display Terminal aliases', ' alias [-g] [name="value"] Create or display Terminal aliases',
" analyze Get information about the current machine ", " analyze Get information about the current machine ",
" backdoor Install a backdoor on the current machine ", " backdoor Install a backdoor on the current machine ",
"buy [-l/program] Purchase a program through the Dark Web", " buy [-l/-a/program] Purchase a program through the Dark Web",
" cat [file] Display a .msg, .lit, or .txt file", " cat [file] Display a .msg, .lit, or .txt file",
" cd [dir] Change to a new directory", " cd [dir] Change to a new directory",
" check [script] [args...] Print a script's logs to Terminal", " check [script] [args...] Print a script's logs to Terminal",
@ -29,7 +29,7 @@ export const TerminalHelpText: string[] = [
" 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 ...] | [glob] 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",
" rm [file] Delete a file from the server", " rm [file] Delete a file from the server",
" run [name] [-t n] [--tail] [args...] Execute a program or script", " run [name] [-t n] [--tail] [args...] Execute a program or script",
@ -40,15 +40,16 @@ export const TerminalHelpText: string[] = [
" 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",
" unalias [alias name] Deletes the specified alias", " unalias [alias name] Deletes the specified alias",
"vim [file ...] | [glob] Text editor - Open up and edit one or more scripts or text files in vim mode", " vim [file ...] Text editor - Open up and edit one or more scripts or text files in vim mode",
" weaken Reduce the security of the current machine", " weaken Reduce the security of the current machine",
" wget [url] [target file] Retrieves code/text from a web server", " wget [url] [target file] Retrieves code/text from a web server",
" ",
]; ];
const TemplatedHelpTexts: IMap<(command: string) => string[]> = { const TemplatedHelpTexts: IMap<(command: string) => string[]> = {
scriptEditor: (command) => { scriptEditor: (command) => {
return [ return [
`${command} [file ...] | [glob]`, `Usage: ${command} [file ...] | [glob]`,
` `, ` `,
`Opens up the specified file(s) in the Script Editor. Only scripts (.js, .ns, .script) or text files (.txt) `, `Opens up the specified file(s) in the Script Editor. Only scripts (.js, .ns, .script) or text files (.txt) `,
`can be edited using the Script Editor. If a file does not exist a new one will be created`, `can be edited using the Script Editor. If a file does not exist a new one will be created`,
@ -63,6 +64,7 @@ const TemplatedHelpTexts: IMap<(command: string) => string[]> = {
` `, ` `,
` ${command} test.*`, ` ${command} test.*`,
` ${command} /my-dir/*.js`, ` ${command} /my-dir/*.js`,
` `
] ]
} }
} }

@ -127,7 +127,7 @@ export function ls(
const classes = makeStyles((theme: Theme) => const classes = makeStyles((theme: Theme) =>
createStyles({ createStyles({
scriptLinksWrap: { scriptLinksWrap: {
display: "flex", display: "inline-flex",
color: theme.palette.warning.main, color: theme.palette.warning.main,
}, },
scriptLink: { scriptLink: {

@ -204,7 +204,7 @@ export async function determineAllPossibilitiesForTabCompletion(
if (isCommand("buy")) { if (isCommand("buy")) {
const options = []; const options = [];
for (const i in DarkWebItems) { for (const i of Object.keys(DarkWebItems)) {
const item = DarkWebItems[i]; const item = DarkWebItems[i];
options.push(item.program); options.push(item.program);
} }

@ -169,7 +169,7 @@ const Engine: {
}, },
decrementAllCounters: function (numCycles = 1) { decrementAllCounters: function (numCycles = 1) {
for (const counterName in Engine.Counters) { for (const counterName of Object.keys(Engine.Counters)) {
const counter = Engine.Counters[counterName]; const counter = Engine.Counters[counterName];
if (counter === undefined) throw new Error("counter should not be undefined"); if (counter === undefined) throw new Error("counter should not be undefined");
Engine.Counters[counterName] = counter - numCycles; Engine.Counters[counterName] = counter - numCycles;

Some files were not shown because too many files have changed in this diff Show More