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

This commit is contained in:
Olivier Gagnon 2021-12-17 16:34:14 -05:00
commit eb002d655a
10 changed files with 93 additions and 6 deletions

@ -2,12 +2,9 @@ root = true
[*] [*]
indent_style = space indent_style = space
indent_size = 4 indent_size = 2
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[package.json]
indent_size = 2
[md] [md]
trim_trailing_whitespace = false trim_trailing_whitespace = false

@ -13,6 +13,7 @@ function createWindow(killall) {
const win = new BrowserWindow({ const win = new BrowserWindow({
show: false, show: false,
backgroundThrottling: false, backgroundThrottling: false,
backgroundColor: '#000000',
}); });
win.removeMenu(); win.removeMenu();

@ -12012,6 +12012,34 @@
], ],
"name": "getHashUpgradeLevel" "name": "getHashUpgradeLevel"
}, },
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!Hacknet#getHashUpgrades:member(1)",
"docComment": "/**\n * Get the list of hash upgrades\n *\n * @remarks\n *\n * RAM cost: 0 GB\n *\n * This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).\n *\n * Returns the list of all available hash upgrades that can be used in the spendHashes function.\n *\n * @returns An array containing the available upgrades\n *\n * @example\n * ```ts\n * const upgrades = hacknet.getHashUpgrades(); // [\"Sell for Money\",\"Sell for Corporation Funds\",...]\n * ```\n *\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "getHashUpgrades(): "
},
{
"kind": "Content",
"text": "string[]"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "getHashUpgrades"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Hacknet#getLevelUpgradeCost:member(1)", "canonicalReference": "bitburner!Hacknet#getLevelUpgradeCost:member(1)",

@ -0,0 +1,34 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Hacknet](./bitburner.hacknet.md) &gt; [getHashUpgrades](./bitburner.hacknet.gethashupgrades.md)
## Hacknet.getHashUpgrades() method
Get the list of hash upgrades
<b>Signature:</b>
```typescript
getHashUpgrades(): string[];
```
<b>Returns:</b>
string\[\]
An array containing the available upgrades
## Remarks
RAM cost: 0 GB
This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
Returns the list of all available hash upgrades that can be used in the spendHashes function.
## Example
```ts
const upgrades = hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
```

@ -23,6 +23,7 @@ Not all these functions are immediately available.
| [getCacheUpgradeCost(index, n)](./bitburner.hacknet.getcacheupgradecost.md) | Calculate the cost of upgrading hacknet node cache. | | [getCacheUpgradeCost(index, n)](./bitburner.hacknet.getcacheupgradecost.md) | Calculate the cost of upgrading hacknet node cache. |
| [getCoreUpgradeCost(index, n)](./bitburner.hacknet.getcoreupgradecost.md) | Calculate the cost of upgrading hacknet node cores. | | [getCoreUpgradeCost(index, n)](./bitburner.hacknet.getcoreupgradecost.md) | Calculate the cost of upgrading hacknet node cores. |
| [getHashUpgradeLevel(upgName)](./bitburner.hacknet.gethashupgradelevel.md) | Get the level of a hash upgrade. | | [getHashUpgradeLevel(upgName)](./bitburner.hacknet.gethashupgradelevel.md) | Get the level of a hash upgrade. |
| [getHashUpgrades()](./bitburner.hacknet.gethashupgrades.md) | Get the list of hash upgrades |
| [getLevelUpgradeCost(index, n)](./bitburner.hacknet.getlevelupgradecost.md) | Calculate the cost of upgrading hacknet node levels. | | [getLevelUpgradeCost(index, n)](./bitburner.hacknet.getlevelupgradecost.md) | Calculate the cost of upgrading hacknet node levels. |
| [getNodeStats(index)](./bitburner.hacknet.getnodestats.md) | Get the stats of a hacknet node. | | [getNodeStats(index)](./bitburner.hacknet.getnodestats.md) | Get the stats of a hacknet node. |
| [getPurchaseNodeCost()](./bitburner.hacknet.getpurchasenodecost.md) | Get the price of the next hacknet node. | | [getPurchaseNodeCost()](./bitburner.hacknet.getpurchasenodecost.md) | Get the price of the next hacknet node. |

@ -16,6 +16,8 @@ import {
} from "../Hacknet/HacknetHelpers"; } from "../Hacknet/HacknetHelpers";
import { HacknetServer } from "../Hacknet/HacknetServer"; import { HacknetServer } from "../Hacknet/HacknetServer";
import { HacknetNode } from "../Hacknet/HacknetNode"; import { HacknetNode } from "../Hacknet/HacknetNode";
import { HashUpgrades } from "../Hacknet/HashUpgrades";
import { HashUpgrade } from "../Hacknet/HashUpgrade";
import { GetServer } from "../Server/AllServers"; import { GetServer } from "../Server/AllServers";
import { Hacknet as IHacknet, NodeStats } from "../ScriptEditor/NetscriptDefinitions"; import { Hacknet as IHacknet, NodeStats } from "../ScriptEditor/NetscriptDefinitions";
@ -166,6 +168,12 @@ export function NetscriptHacknet(player: IPlayer, workerScript: WorkerScript, he
} }
return purchaseHashUpgrade(player, upgName, upgTarget); return purchaseHashUpgrade(player, upgName, upgTarget);
}, },
getHashUpgrades: function(): string[] {
if (!hasHacknetServers(player)) {
return [];
}
return Object.values(HashUpgrades).map((upgrade: HashUpgrade) => upgrade.name);
},
getHashUpgradeLevel: function (upgName: any): number { getHashUpgradeLevel: function (upgName: any): number {
const level = player.hashManager.upgrades[upgName]; const level = player.hashManager.upgrades[upgName];
if (level === undefined) { if (level === undefined) {

@ -2290,6 +2290,22 @@ export interface Hacknet {
*/ */
spendHashes(upgName: string, upgTarget?: string): boolean; spendHashes(upgName: string, upgTarget?: string): boolean;
/**
* Get the list of hash upgrades
* @remarks
* RAM cost: 0 GB
*
* This function is only applicable for Hacknet Servers (the upgraded version of a Hacknet Node).
*
* Returns the list of all available hash upgrades that can be used in the spendHashes function.
* @example
* ```ts
* const upgrades = hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
* ```
* @returns An array containing the available upgrades
*/
getHashUpgrades(): string[];
/** /**
* Get the level of a hash upgrade. * Get the level of a hash upgrade.
* @remarks * @remarks

@ -292,7 +292,8 @@ 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) { } else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey) {
// ctrl/cmd + alt + j is shortcut to open Chrome dev tools
event.preventDefault(); event.preventDefault();
clickJob(); clickJob();
} else if (event.keyCode === KEY.R && event.altKey) { } else if (event.keyCode === KEY.R && event.altKey) {

@ -108,7 +108,7 @@ export function TutorialRoot(props: IProps): React.ReactElement {
target="_blank" target="_blank"
href="https://bitburner.readthedocs.io/en/latest/netscript/netscriptlearntoprogram.html#netscript-1-0-vs-netscript-2-0" href="https://bitburner.readthedocs.io/en/latest/netscript/netscriptlearntoprogram.html#netscript-1-0-vs-netscript-2-0"
> >
<Typography>NS1 vs NS1 (or .script vs .js)</Typography> <Typography>NS1 vs NS2 (or .script vs .js)</Typography>
</Link> </Link>
</Box> </Box>
</> </>

@ -40,6 +40,7 @@ function ColorEditor({ name, onColorChange, color, defaultColor }: IColorEditorP
<> <>
<ColorPicker <ColorPicker
hideTextfield hideTextfield
deferred
value={color} value={color}
onChange={(newColor: Color) => onColorChange(name, "#" + newColor.hex)} onChange={(newColor: Color) => onColorChange(name, "#" + newColor.hex)}
/> />