mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-13 11:13:50 +01:00
Merge branch 'dev' of https://github.com/rderfler/bitburner into dev
This commit is contained in:
commit
d1388a62aa
3
.github/PULL_REQUEST_TEMPLATE
vendored
3
.github/PULL_REQUEST_TEMPLATE
vendored
@ -9,3 +9,6 @@
|
|||||||
|
|
||||||
- Include how it was tested
|
- Include how it was tested
|
||||||
- Include screenshot / gif (if possible)
|
- Include screenshot / gif (if possible)
|
||||||
|
|
||||||
|
|
||||||
|
Make sure you run `npm run format` and `npm run lint` before pushing.
|
||||||
|
22
.github/workflows/bump-version.yml
vendored
22
.github/workflows/bump-version.yml
vendored
@ -4,28 +4,28 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: 'Version (format: x.y.z)'
|
description: "Version (format: x.y.z)"
|
||||||
required: true
|
required: true
|
||||||
versionNumber:
|
versionNumber:
|
||||||
description: 'Version Number (for saves migration)'
|
description: "Version Number (for saves migration)"
|
||||||
required: true
|
required: true
|
||||||
changelog:
|
changelog:
|
||||||
description: 'Changelog (url that points to RAW markdown)'
|
description: "Changelog (url that points to RAW markdown)"
|
||||||
default: ''
|
default: ""
|
||||||
buildApp:
|
buildApp:
|
||||||
description: 'Include Application Build'
|
description: "Include Application Build"
|
||||||
type: boolean
|
type: boolean
|
||||||
default: 'true'
|
default: "true"
|
||||||
required: true
|
required: true
|
||||||
buildDoc:
|
buildDoc:
|
||||||
description: 'Include Documentation Build'
|
description: "Include Documentation Build"
|
||||||
type: boolean
|
type: boolean
|
||||||
default: 'true'
|
default: "true"
|
||||||
required: true
|
required: true
|
||||||
prepareRelease:
|
prepareRelease:
|
||||||
description: 'Prepare Draft Release'
|
description: "Prepare Draft Release"
|
||||||
type: boolean
|
type: boolean
|
||||||
default: 'true'
|
default: "true"
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -46,7 +46,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.13.1
|
node-version: 16.13.1
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- name: Install NPM dependencies for version updater
|
- name: Install NPM dependencies for version updater
|
||||||
working-directory: ./tools/bump-version
|
working-directory: ./tools/bump-version
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
6
.github/workflows/fetch-changes.yml
vendored
6
.github/workflows/fetch-changes.yml
vendored
@ -3,10 +3,10 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
fromCommit:
|
fromCommit:
|
||||||
description: 'From Commit SHA (full-length)'
|
description: "From Commit SHA (full-length)"
|
||||||
required: true
|
required: true
|
||||||
toCommit:
|
toCommit:
|
||||||
description: 'To Commit SHA (full-length, if omitted will use latest)'
|
description: "To Commit SHA (full-length, if omitted will use latest)"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
fetchChangelog:
|
fetchChangelog:
|
||||||
@ -17,7 +17,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 16.13.1
|
node-version: 16.13.1
|
||||||
cache: 'npm'
|
cache: "npm"
|
||||||
- name: Install NPM dependencies
|
- name: Install NPM dependencies
|
||||||
working-directory: ./tools/fetch-changelog
|
working-directory: ./tools/fetch-changelog
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
42
dist/vendor.bundle.js
vendored
42
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/vendor.bundle.js.map
vendored
2
dist/vendor.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
@ -25,8 +25,8 @@ I need equations that test many different aspect of "math culture", it can be ch
|
|||||||
|
|
||||||
All variable purchasing will be scriptable.
|
All variable purchasing will be scriptable.
|
||||||
|
|
||||||
|
|
||||||
All equation must have:
|
All equation must have:
|
||||||
|
|
||||||
- several variables that can be upgraded, at least 1 variable must be strategic in it's upgrading (upgrading too much can cause drop in performance)
|
- several variables that can be upgraded, at least 1 variable must be strategic in it's upgrading (upgrading too much can cause drop in performance)
|
||||||
- Some sort of math twist that requires some thinking, like (-2)^c1 alters between positive and negative.
|
- Some sort of math twist that requires some thinking, like (-2)^c1 alters between positive and negative.
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ Fork and clone the repo
|
|||||||
- Regularly rebase your branch against `dev` to make sure you have the latest updates pulled.
|
- Regularly rebase your branch against `dev` to make sure you have the latest updates pulled.
|
||||||
- When merging, always merge your branch into `dev`. When releasing a new update, then merge `dev` into `master`
|
- When merging, always merge your branch into `dev`. When releasing a new update, then merge `dev` into `master`
|
||||||
|
|
||||||
|
|
||||||
## Running locally.
|
## Running locally.
|
||||||
|
|
||||||
Install
|
Install
|
||||||
@ -131,7 +130,6 @@ Inside the root of the repo run
|
|||||||
After that you can open any browser and navigate to `localhost:8000` and play the game.
|
After that you can open any browser and navigate to `localhost:8000` and play the game.
|
||||||
Saving a file will reload the game automatically.
|
Saving a file will reload the game automatically.
|
||||||
|
|
||||||
|
|
||||||
### How to build the electron app
|
### How to build the electron app
|
||||||
|
|
||||||
Tested on Node v16.13.1 (LTS) on Windows
|
Tested on Node v16.13.1 (LTS) on Windows
|
||||||
|
23
doc/FAQ.md
23
doc/FAQ.md
@ -23,10 +23,11 @@ Yes, just export the save file from the options menu & import it in the other pl
|
|||||||
## Game is stuck after running scripts!
|
## Game is stuck after running scripts!
|
||||||
|
|
||||||
You may have created an infinite loop with no sleep. You'll have to restart the game by killing all scripts.
|
You may have created an infinite loop with no sleep. You'll have to restart the game by killing all scripts.
|
||||||
* On Browser: Stick `?noScript` at the end of the URL
|
|
||||||
* On Steam:
|
- On Browser: Stick `?noScript` at the end of the URL
|
||||||
* In the menu, "Reloads" -> "Reload & Kill All Scripts".
|
- On Steam:
|
||||||
* If this does not work, when launching the game, use the kill all script options.
|
- In the menu, "Reloads" -> "Reload & Kill All Scripts".
|
||||||
|
- If this does not work, when launching the game, use the kill all script options.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -51,11 +52,13 @@ You can navigate to the game files by right-clicking the game in your library an
|
|||||||
## Steam: Game won't launch
|
## Steam: Game won't launch
|
||||||
|
|
||||||
### **On Windows**
|
### **On Windows**
|
||||||
|
|
||||||
If the game is installed on a network drive, it will fail to start due to a [limitation in Chromium](https://github.com/electron/electron/issues/27356).
|
If the game is installed on a network drive, it will fail to start due to a [limitation in Chromium](https://github.com/electron/electron/issues/27356).
|
||||||
|
|
||||||
If you cannot move the game to another drive, you'll have to add the `--no-sandbox` launch option. In your Steam Library, Right click the game and hit "Properties". You'll see the launch option section in the "General" window.
|
If you cannot move the game to another drive, you'll have to add the `--no-sandbox` launch option. In your Steam Library, Right click the game and hit "Properties". You'll see the launch option section in the "General" window.
|
||||||
|
|
||||||
### **On Linux**
|
### **On Linux**
|
||||||
|
|
||||||
The game is built natively, do not use Proton unless native does not work.
|
The game is built natively, do not use Proton unless native does not work.
|
||||||
|
|
||||||
When launching the game, you will be prompted with three options. If the standard launch does not work, you may attempt the `--disable-seccomp-filter-sandbox` or `--no-sandbox` launch option. If this still does not work, the game should be able to start by launching it directly or through the terminal. See [How do I get to the game files?](#game-files).
|
When launching the game, you will be prompted with three options. If the standard launch does not work, you may attempt the `--disable-seccomp-filter-sandbox` or `--no-sandbox` launch option. If this still does not work, the game should be able to start by launching it directly or through the terminal. See [How do I get to the game files?](#game-files).
|
||||||
@ -68,17 +71,17 @@ When launching the game, you will be prompted with three options. If the standar
|
|||||||
|
|
||||||
You may want access the logs to get information about crashes or such.
|
You may want access the logs to get information about crashes or such.
|
||||||
|
|
||||||
* on Linux: `~/.config/bitburner/logs/main.log`
|
- on Linux: `~/.config/bitburner/logs/main.log`
|
||||||
* on macOS: `~/Library/Logs/bitburner/main.log`
|
- on macOS: `~/Library/Logs/bitburner/main.log`
|
||||||
* on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\logs\main.log`
|
- on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\logs\main.log`
|
||||||
|
|
||||||
### Config (using [electron-store](https://github.com/sindresorhus/electron-store#readme))
|
### Config (using [electron-store](https://github.com/sindresorhus/electron-store#readme))
|
||||||
|
|
||||||
Configuration file will be written to disk in the application data directory.
|
Configuration file will be written to disk in the application data directory.
|
||||||
|
|
||||||
* on Linux: `~/.config/bitburner/config.json`
|
- on Linux: `~/.config/bitburner/config.json`
|
||||||
* on macOS: `~/Library/Application\ Support/bitburner/config.json`
|
- on macOS: `~/Library/Application\ Support/bitburner/config.json`
|
||||||
* on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\config.json`
|
- on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\config.json`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -196,6 +196,23 @@ The list contains the name of (i.e. the value returned by
|
|||||||
| | | |
|
| | | |
|
||||||
| | | Determine how many unique paths there are from start to finish. |
|
| | | Determine how many unique paths there are from start to finish. |
|
||||||
+------------------------------------+------------------------------------------------------------------------------------------+
|
+------------------------------------+------------------------------------------------------------------------------------------+
|
||||||
|
| Shortest Path in a Grid | | You are given a 2D array of numbers (array of array of numbers) representing |
|
||||||
|
| | | a grid. The 2D array contains 1's and 0's, where 1 represents an obstacle and |
|
||||||
|
| | | 0 represents a free space. |
|
||||||
|
| | | |
|
||||||
|
| | | Assume you are initially positioned in top-left corner of that grid and that you |
|
||||||
|
| | | are trying to reach the bottom-right corner. In each step, you may move to the up, |
|
||||||
|
| | | down, left or right. Furthermore, you cannot move onto spaces which have obstacles. |
|
||||||
|
| | | |
|
||||||
|
| | | Determine if paths exist from start to destination, and find the shortest one. |
|
||||||
|
| | | |
|
||||||
|
| | | Examples: |
|
||||||
|
| | | [[0,1,0,0,0], |
|
||||||
|
| | | [0,0,0,1,0]] -> "DRRURRD" |
|
||||||
|
| | | [[0,1], |
|
||||||
|
| | | [1,0]] -> "" |
|
||||||
|
| | | |
|
||||||
|
+------------------------------------+------------------------------------------------------------------------------------------+
|
||||||
| Sanitize Parentheses in Expression | | Given a string with parentheses and letters, remove the minimum number of invalid |
|
| Sanitize Parentheses in Expression | | Given a string with parentheses and letters, remove the minimum number of invalid |
|
||||||
| | | parentheses in order to validate the string. If there are multiple minimal ways |
|
| | | parentheses in order to validate the string. If there are multiple minimal ways |
|
||||||
| | | to validate the string, provide all of the possible results. |
|
| | | to validate the string, provide all of the possible results. |
|
||||||
|
@ -10,7 +10,7 @@ async function enableAchievementsInterval(window) {
|
|||||||
// here. Hey if it works it works.
|
// here. Hey if it works it works.
|
||||||
const steamAchievements = greenworks.getAchievementNames();
|
const steamAchievements = greenworks.getAchievementNames();
|
||||||
log.silly(`All Steam achievements ${JSON.stringify(steamAchievements)}`);
|
log.silly(`All Steam achievements ${JSON.stringify(steamAchievements)}`);
|
||||||
const playerAchieved = (await Promise.all(steamAchievements.map(checkSteamAchievement))).filter(name => !!name);
|
const playerAchieved = (await Promise.all(steamAchievements.map(checkSteamAchievement))).filter((name) => !!name);
|
||||||
log.debug(`Player has Steam achievements ${JSON.stringify(playerAchieved)}`);
|
log.debug(`Player has Steam achievements ${JSON.stringify(playerAchieved)}`);
|
||||||
const intervalID = setInterval(async () => {
|
const intervalID = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
@ -26,7 +26,7 @@ async function enableAchievementsInterval(window) {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
|
|
||||||
// The interval probably did not get cleared after a window kill
|
// The interval probably did not get cleared after a window kill
|
||||||
log.warn('Clearing achievements timer');
|
log.warn("Clearing achievements timer");
|
||||||
clearInterval(intervalID);
|
clearInterval(intervalID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -36,10 +36,14 @@ async function enableAchievementsInterval(window) {
|
|||||||
|
|
||||||
function checkSteamAchievement(name) {
|
function checkSteamAchievement(name) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
greenworks.getAchievement(name, playerHas => resolve(playerHas ? name : ""), err => {
|
greenworks.getAchievement(
|
||||||
|
name,
|
||||||
|
(playerHas) => resolve(playerHas ? name : ""),
|
||||||
|
(err) => {
|
||||||
log.warn(`Failed to get Steam achievement ${name} status: ${err}`);
|
log.warn(`Failed to get Steam achievement ${name} status: ${err}`);
|
||||||
resolve("");
|
resolve("");
|
||||||
});
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,5 +54,6 @@ function disableAchievementsInterval(window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
enableAchievementsInterval, disableAchievementsInterval
|
enableAchievementsInterval,
|
||||||
}
|
disableAchievementsInterval,
|
||||||
|
};
|
||||||
|
@ -12,25 +12,27 @@ async function initialize(win) {
|
|||||||
window = win;
|
window = win;
|
||||||
server = http.createServer(async function (req, res) {
|
server = http.createServer(async function (req, res) {
|
||||||
let body = "";
|
let body = "";
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
req.on("data", (chunk) => {
|
req.on("data", (chunk) => {
|
||||||
body += chunk.toString(); // convert Buffer to string
|
body += chunk.toString(); // convert Buffer to string
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on("end", async () => {
|
req.on("end", async () => {
|
||||||
const providedToken = req.headers?.authorization?.replace('Bearer ', '') ?? '';
|
const providedToken = req.headers?.authorization?.replace("Bearer ", "") ?? "";
|
||||||
const isValid = providedToken === getAuthenticationToken();
|
const isValid = providedToken === getAuthenticationToken();
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
log.debug('Valid authentication token');
|
log.debug("Valid authentication token");
|
||||||
} else {
|
} else {
|
||||||
log.log('Invalid authentication token');
|
log.log("Invalid authentication token");
|
||||||
res.writeHead(401);
|
res.writeHead(401);
|
||||||
|
|
||||||
res.end(JSON.stringify({
|
res.end(
|
||||||
|
JSON.stringify({
|
||||||
success: false,
|
success: false,
|
||||||
msg: 'Invalid authentication token'
|
msg: "Invalid authentication token",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +42,12 @@ async function initialize(win) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn(`Invalid body data`);
|
log.warn(`Invalid body data`);
|
||||||
res.writeHead(400);
|
res.writeHead(400);
|
||||||
res.end(JSON.stringify({
|
res.end(
|
||||||
|
JSON.stringify({
|
||||||
success: false,
|
success: false,
|
||||||
msg: 'Invalid body data'
|
msg: "Invalid body data",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -62,10 +66,12 @@ async function initialize(win) {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
log.warn(`Invalid script update request - No data`);
|
log.warn(`Invalid script update request - No data`);
|
||||||
res.writeHead(400);
|
res.writeHead(400);
|
||||||
res.end(JSON.stringify({
|
res.end(
|
||||||
|
JSON.stringify({
|
||||||
success: false,
|
success: false,
|
||||||
msg: 'Invalid script update request - No data'
|
msg: "Invalid script update request - No data",
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,19 +90,20 @@ async function initialize(win) {
|
|||||||
log.warn(`Api Server Error`, result.msg);
|
log.warn(`Api Server Error`, result.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.end(JSON.stringify({
|
res.end(
|
||||||
|
JSON.stringify({
|
||||||
success: result.res,
|
success: result.res,
|
||||||
msg: result.msg,
|
msg: result.msg,
|
||||||
data: result.data
|
data: result.data,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const autostart = config.get('autostart', false);
|
const autostart = config.get("autostart", false);
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
try {
|
try {
|
||||||
await enable()
|
await enable();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
@ -105,15 +112,14 @@ async function initialize(win) {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function enable() {
|
function enable() {
|
||||||
if (isListening()) {
|
if (isListening()) {
|
||||||
log.warn('API server already listening');
|
log.warn("API server already listening");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const port = config.get('port', 9990);
|
const port = config.get("port", 9990);
|
||||||
const host = config.get('host', '127.0.0.1');
|
const host = config.get("host", "127.0.0.1");
|
||||||
log.log(`Starting http server on port ${port} - listening on ${host}`);
|
log.log(`Starting http server on port ${port} - listening on ${host}`);
|
||||||
|
|
||||||
// https://stackoverflow.com/a/62289870
|
// https://stackoverflow.com/a/62289870
|
||||||
@ -125,13 +131,10 @@ function enable() {
|
|||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
server.once('error', (err) => {
|
server.once("error", (err) => {
|
||||||
if (!startFinished) {
|
if (!startFinished) {
|
||||||
startFinished = true;
|
startFinished = true;
|
||||||
console.log(
|
console.log("There was an error starting the server in the error listener:", err);
|
||||||
'There was an error starting the server in the error listener:',
|
|
||||||
err
|
|
||||||
);
|
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -140,11 +143,11 @@ function enable() {
|
|||||||
|
|
||||||
function disable() {
|
function disable() {
|
||||||
if (!isListening()) {
|
if (!isListening()) {
|
||||||
log.warn('API server not listening');
|
log.warn("API server not listening");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.log('Stopping http server');
|
log.log("Stopping http server");
|
||||||
return server.close();
|
return server.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,31 +165,35 @@ function isListening() {
|
|||||||
|
|
||||||
function toggleAutostart() {
|
function toggleAutostart() {
|
||||||
const newValue = !isAutostart();
|
const newValue = !isAutostart();
|
||||||
config.set('autostart', newValue);
|
config.set("autostart", newValue);
|
||||||
log.log(`New autostart value is '${newValue}'`);
|
log.log(`New autostart value is '${newValue}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAutostart() {
|
function isAutostart() {
|
||||||
return config.get('autostart');
|
return config.get("autostart");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAuthenticationToken() {
|
function getAuthenticationToken() {
|
||||||
const token = config.get('token');
|
const token = config.get("token");
|
||||||
if (token) return token;
|
if (token) return token;
|
||||||
|
|
||||||
const newToken = generateToken();
|
const newToken = generateToken();
|
||||||
config.set('token', newToken);
|
config.set("token", newToken);
|
||||||
return newToken;
|
return newToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateToken() {
|
function generateToken() {
|
||||||
const buffer = crypto.randomBytes(48);
|
const buffer = crypto.randomBytes(48);
|
||||||
return buffer.toString('base64')
|
return buffer.toString("base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
initialize,
|
initialize,
|
||||||
enable, disable, toggleServer,
|
enable,
|
||||||
toggleAutostart, isAutostart,
|
disable,
|
||||||
getAuthenticationToken, isListening,
|
toggleServer,
|
||||||
}
|
toggleAutostart,
|
||||||
|
isAutostart,
|
||||||
|
getAuthenticationToken,
|
||||||
|
isListening,
|
||||||
|
};
|
||||||
|
@ -15,19 +15,20 @@ const debug = process.argv.includes("--debug");
|
|||||||
|
|
||||||
async function createWindow(killall) {
|
async function createWindow(killall) {
|
||||||
const setStopProcessHandler = global.app_handlers.stopProcess;
|
const setStopProcessHandler = global.app_handlers.stopProcess;
|
||||||
|
app.setAppUserModelId("Bitburner");
|
||||||
|
|
||||||
let icon;
|
let icon;
|
||||||
if (process.platform == 'linux') {
|
if (process.platform == "linux") {
|
||||||
icon = path.join(__dirname, 'icon.png');
|
icon = path.join(__dirname, "icon.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
const tracker = windowTracker('main');
|
const tracker = windowTracker("main");
|
||||||
const window = new BrowserWindow({
|
const window = new BrowserWindow({
|
||||||
icon,
|
icon,
|
||||||
show: false,
|
show: false,
|
||||||
backgroundThrottling: false,
|
backgroundThrottling: false,
|
||||||
backgroundColor: "#000000",
|
backgroundColor: "#000000",
|
||||||
title: 'Bitburner',
|
title: "Bitburner",
|
||||||
x: tracker.state.x,
|
x: tracker.state.x,
|
||||||
y: tracker.state.y,
|
y: tracker.state.y,
|
||||||
width: tracker.state.width,
|
width: tracker.state.width,
|
||||||
@ -36,7 +37,7 @@ async function createWindow(killall) {
|
|||||||
minHeight: 400,
|
minHeight: 400,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,12 +52,12 @@ async function createWindow(killall) {
|
|||||||
|
|
||||||
window.webContents.on("new-window", async function (e, url) {
|
window.webContents.on("new-window", async function (e, url) {
|
||||||
// Let's make sure sure we have a proper url
|
// Let's make sure sure we have a proper url
|
||||||
let parsedUrl
|
let parsedUrl;
|
||||||
try {
|
try {
|
||||||
parsedUrl = new URL(url);
|
parsedUrl = new URL(url);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// This is an invalid url, let's just do nothing
|
// This is an invalid url, let's just do nothing
|
||||||
log.warn(`Invalid url found: ${url}`)
|
log.warn(`Invalid url found: ${url}`);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,11 +74,13 @@ async function createWindow(killall) {
|
|||||||
|
|
||||||
if (!isChild) {
|
if (!isChild) {
|
||||||
// If we're not relative to our app's path let's abort
|
// If we're not relative to our app's path let's abort
|
||||||
log.warn(`Requested path ${filePath.dir}${path.sep}${filePath.base} is not relative to the app: ${appPath.dir}${path.sep}${appPath.base}`)
|
log.warn(
|
||||||
|
`Requested path ${filePath.dir}${path.sep}${filePath.base} is not relative to the app: ${appPath.dir}${path.sep}${appPath.base}`,
|
||||||
|
);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (!fileExists) {
|
} else if (!fileExists) {
|
||||||
// If the file does not exist let's abort
|
// If the file does not exist let's abort
|
||||||
log.warn(`Requested path ${filePath.dir}${path.sep}${filePath.base} does not exist`)
|
log.warn(`Requested path ${filePath.dir}${path.sep}${filePath.base} does not exist`);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +92,7 @@ async function createWindow(killall) {
|
|||||||
let urlToOpen = parsedUrl.toString();
|
let urlToOpen = parsedUrl.toString();
|
||||||
if (parsedUrl.search) {
|
if (parsedUrl.search) {
|
||||||
log.log(`Cannot open a path with parameters: ${parsedUrl.search}`);
|
log.log(`Cannot open a path with parameters: ${parsedUrl.search}`);
|
||||||
urlToOpen = urlToOpen.replace(parsedUrl.search, '');
|
urlToOpen = urlToOpen.replace(parsedUrl.search, "");
|
||||||
// It would be possible to launch an URL with parameter using this, but it would mess up the process again...
|
// It would be possible to launch an URL with parameter using this, but it would mess up the process again...
|
||||||
// const escapedUri = parsedUrl.href.replace('&', '^&');
|
// const escapedUri = parsedUrl.href.replace('&', '^&');
|
||||||
// cp.spawn("cmd.exe", ["/c", "start", escapedUri], { detached: true, stdio: "ignore" });
|
// cp.spawn("cmd.exe", ["/c", "start", escapedUri], { detached: true, stdio: "ignore" });
|
||||||
|
@ -3,83 +3,91 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// The source code can be found in https://github.com/greenheartgames/greenworks
|
// The source code can be found in https://github.com/greenheartgames/greenworks
|
||||||
var fs = require('fs');
|
var fs = require("fs");
|
||||||
|
|
||||||
var greenworks;
|
var greenworks;
|
||||||
|
|
||||||
if (process.platform == 'darwin') {
|
if (process.platform == "darwin") {
|
||||||
if (process.arch == 'x64')
|
if (process.arch == "x64") greenworks = require("./lib/greenworks-osx64");
|
||||||
greenworks = require('./lib/greenworks-osx64');
|
else if (process.arch == "ia32") greenworks = require("./lib/greenworks-osx32");
|
||||||
else if (process.arch == 'ia32')
|
} else if (process.platform == "win32") {
|
||||||
greenworks = require('./lib/greenworks-osx32');
|
if (process.arch == "x64") greenworks = require("./lib/greenworks-win64");
|
||||||
} else if (process.platform == 'win32') {
|
else if (process.arch == "ia32") greenworks = require("./lib/greenworks-win32");
|
||||||
if (process.arch == 'x64')
|
} else if (process.platform == "linux") {
|
||||||
greenworks = require('./lib/greenworks-win64');
|
if (process.arch == "x64") greenworks = require("./lib/greenworks-linux64");
|
||||||
else if (process.arch == 'ia32')
|
else if (process.arch == "ia32") greenworks = require("./lib/greenworks-linux32");
|
||||||
greenworks = require('./lib/greenworks-win32');
|
|
||||||
} else if (process.platform == 'linux') {
|
|
||||||
if (process.arch == 'x64')
|
|
||||||
greenworks = require('./lib/greenworks-linux64');
|
|
||||||
else if (process.arch == 'ia32')
|
|
||||||
greenworks = require('./lib/greenworks-linux32');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function error_process(err, error_callback) {
|
function error_process(err, error_callback) {
|
||||||
if (err && error_callback)
|
if (err && error_callback) error_callback(err);
|
||||||
error_callback(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
greenworks.ugcGetItems = function(options, ugc_matching_type, ugc_query_type,
|
greenworks.ugcGetItems = function (options, ugc_matching_type, ugc_query_type, success_callback, error_callback) {
|
||||||
success_callback, error_callback) {
|
if (typeof options !== "object") {
|
||||||
if (typeof options !== 'object') {
|
|
||||||
error_callback = success_callback;
|
error_callback = success_callback;
|
||||||
success_callback = ugc_query_type;
|
success_callback = ugc_query_type;
|
||||||
ugc_query_type = ugc_matching_type;
|
ugc_query_type = ugc_matching_type;
|
||||||
ugc_matching_type = options;
|
ugc_matching_type = options;
|
||||||
options = {
|
options = {
|
||||||
'app_id': greenworks.getAppId(),
|
app_id: greenworks.getAppId(),
|
||||||
'page_num': 1
|
page_num: 1,
|
||||||
}
|
};
|
||||||
}
|
|
||||||
greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type,
|
|
||||||
success_callback, error_callback);
|
|
||||||
}
|
}
|
||||||
|
greenworks._ugcGetItems(options, ugc_matching_type, ugc_query_type, success_callback, error_callback);
|
||||||
|
};
|
||||||
|
|
||||||
greenworks.ugcGetUserItems = function(options, ugc_matching_type,
|
greenworks.ugcGetUserItems = function (
|
||||||
ugc_list_sort_order, ugc_list, success_callback, error_callback) {
|
options,
|
||||||
if (typeof options !== 'object') {
|
ugc_matching_type,
|
||||||
|
ugc_list_sort_order,
|
||||||
|
ugc_list,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
) {
|
||||||
|
if (typeof options !== "object") {
|
||||||
error_callback = success_callback;
|
error_callback = success_callback;
|
||||||
success_callback = ugc_list;
|
success_callback = ugc_list;
|
||||||
ugc_list = ugc_list_sort_order;
|
ugc_list = ugc_list_sort_order;
|
||||||
ugc_list_sort_order = ugc_matching_type;
|
ugc_list_sort_order = ugc_matching_type;
|
||||||
ugc_matching_type = options;
|
ugc_matching_type = options;
|
||||||
options = {
|
options = {
|
||||||
'app_id': greenworks.getAppId(),
|
app_id: greenworks.getAppId(),
|
||||||
'page_num': 1
|
page_num: 1,
|
||||||
}
|
};
|
||||||
}
|
|
||||||
greenworks._ugcGetUserItems(options, ugc_matching_type, ugc_list_sort_order,
|
|
||||||
ugc_list, success_callback, error_callback);
|
|
||||||
}
|
}
|
||||||
|
greenworks._ugcGetUserItems(
|
||||||
|
options,
|
||||||
|
ugc_matching_type,
|
||||||
|
ugc_list_sort_order,
|
||||||
|
ugc_list,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback,
|
greenworks.ugcSynchronizeItems = function (options, sync_dir, success_callback, error_callback) {
|
||||||
error_callback) {
|
if (typeof options !== "object") {
|
||||||
if (typeof options !== 'object') {
|
|
||||||
error_callback = success_callback;
|
error_callback = success_callback;
|
||||||
success_callback = sync_dir;
|
success_callback = sync_dir;
|
||||||
sync_dir = options;
|
sync_dir = options;
|
||||||
options = {
|
options = {
|
||||||
'app_id': greenworks.getAppId(),
|
app_id: greenworks.getAppId(),
|
||||||
'page_num': 1
|
page_num: 1,
|
||||||
}
|
};
|
||||||
}
|
|
||||||
greenworks._ugcSynchronizeItems(options, sync_dir, success_callback,
|
|
||||||
error_callback);
|
|
||||||
}
|
}
|
||||||
|
greenworks._ugcSynchronizeItems(options, sync_dir, success_callback, error_callback);
|
||||||
|
};
|
||||||
|
|
||||||
greenworks.publishWorkshopFile = function(options, file_path, image_path, title,
|
greenworks.publishWorkshopFile = function (
|
||||||
description, success_callback, error_callback) {
|
options,
|
||||||
if (typeof options !== 'object') {
|
file_path,
|
||||||
|
image_path,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
) {
|
||||||
|
if (typeof options !== "object") {
|
||||||
error_callback = success_callback;
|
error_callback = success_callback;
|
||||||
success_callback = description;
|
success_callback = description;
|
||||||
description = title;
|
description = title;
|
||||||
@ -87,18 +95,24 @@ greenworks.publishWorkshopFile = function(options, file_path, image_path, title,
|
|||||||
image_path = file_path;
|
image_path = file_path;
|
||||||
file_path = options;
|
file_path = options;
|
||||||
options = {
|
options = {
|
||||||
'app_id': greenworks.getAppId(),
|
app_id: greenworks.getAppId(),
|
||||||
'tags': []
|
tags: [],
|
||||||
}
|
};
|
||||||
}
|
|
||||||
greenworks._publishWorkshopFile(options, file_path, image_path, title,
|
|
||||||
description, success_callback, error_callback);
|
|
||||||
}
|
}
|
||||||
|
greenworks._publishWorkshopFile(options, file_path, image_path, title, description, success_callback, error_callback);
|
||||||
|
};
|
||||||
|
|
||||||
greenworks.updatePublishedWorkshopFile = function(options,
|
greenworks.updatePublishedWorkshopFile = function (
|
||||||
published_file_handle, file_path, image_path, title, description,
|
options,
|
||||||
success_callback, error_callback) {
|
published_file_handle,
|
||||||
if (typeof options !== 'object') {
|
file_path,
|
||||||
|
image_path,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
) {
|
||||||
|
if (typeof options !== "object") {
|
||||||
error_callback = success_callback;
|
error_callback = success_callback;
|
||||||
success_callback = description;
|
success_callback = description;
|
||||||
description = title;
|
description = title;
|
||||||
@ -107,104 +121,166 @@ greenworks.updatePublishedWorkshopFile = function(options,
|
|||||||
file_path = published_file_handle;
|
file_path = published_file_handle;
|
||||||
published_file_handle = options;
|
published_file_handle = options;
|
||||||
options = {
|
options = {
|
||||||
'tags': [] // No tags are set
|
tags: [], // No tags are set
|
||||||
}
|
};
|
||||||
}
|
|
||||||
greenworks._updatePublishedWorkshopFile(options, published_file_handle,
|
|
||||||
file_path, image_path, title, description, success_callback,
|
|
||||||
error_callback);
|
|
||||||
}
|
}
|
||||||
|
greenworks._updatePublishedWorkshopFile(
|
||||||
|
options,
|
||||||
|
published_file_handle,
|
||||||
|
file_path,
|
||||||
|
image_path,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// An utility function for publish related APIs.
|
// An utility function for publish related APIs.
|
||||||
// It processes remains steps after saving files to Steam Cloud.
|
// It processes remains steps after saving files to Steam Cloud.
|
||||||
function file_share_process(file_name, image_name, next_process_func,
|
function file_share_process(file_name, image_name, next_process_func, error_callback, progress_callback) {
|
||||||
error_callback, progress_callback) {
|
if (progress_callback) progress_callback("Completed on saving files on Steam Cloud.");
|
||||||
if (progress_callback)
|
greenworks.fileShare(
|
||||||
progress_callback("Completed on saving files on Steam Cloud.");
|
file_name,
|
||||||
greenworks.fileShare(file_name, function() {
|
function () {
|
||||||
greenworks.fileShare(image_name, function() {
|
greenworks.fileShare(
|
||||||
|
image_name,
|
||||||
|
function () {
|
||||||
next_process_func();
|
next_process_func();
|
||||||
}, function(err) { error_process(err, error_callback); });
|
},
|
||||||
}, function(err) { error_process(err, error_callback); });
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publishing user generated content(ugc) to Steam contains following steps:
|
// Publishing user generated content(ugc) to Steam contains following steps:
|
||||||
// 1. Save file and image to Steam Cloud.
|
// 1. Save file and image to Steam Cloud.
|
||||||
// 2. Share the file and image.
|
// 2. Share the file and image.
|
||||||
// 3. publish the file to workshop.
|
// 3. publish the file to workshop.
|
||||||
greenworks.ugcPublish = function(file_name, title, description, image_name,
|
greenworks.ugcPublish = function (
|
||||||
success_callback, error_callback, progress_callback) {
|
file_name,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
image_name,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
progress_callback,
|
||||||
|
) {
|
||||||
var publish_file_process = function () {
|
var publish_file_process = function () {
|
||||||
if (progress_callback)
|
if (progress_callback) progress_callback("Completed on sharing files.");
|
||||||
progress_callback("Completed on sharing files.");
|
greenworks.publishWorkshopFile(
|
||||||
greenworks.publishWorkshopFile(file_name, image_name, title, description,
|
file_name,
|
||||||
function(publish_file_id) { success_callback(publish_file_id); },
|
image_name,
|
||||||
function(err) { error_process(err, error_callback); });
|
title,
|
||||||
|
description,
|
||||||
|
function (publish_file_id) {
|
||||||
|
success_callback(publish_file_id);
|
||||||
|
},
|
||||||
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
greenworks.saveFilesToCloud(
|
||||||
|
[file_name, image_name],
|
||||||
|
function () {
|
||||||
|
file_share_process(file_name, image_name, publish_file_process, error_callback, progress_callback);
|
||||||
|
},
|
||||||
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
greenworks.saveFilesToCloud([file_name, image_name], function() {
|
|
||||||
file_share_process(file_name, image_name, publish_file_process,
|
|
||||||
error_callback, progress_callback);
|
|
||||||
}, function(err) { error_process(err, error_callback); });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update publish ugc steps:
|
// Update publish ugc steps:
|
||||||
// 1. Save new file and image to Steam Cloud.
|
// 1. Save new file and image to Steam Cloud.
|
||||||
// 2. Share file and images.
|
// 2. Share file and images.
|
||||||
// 3. Update published file.
|
// 3. Update published file.
|
||||||
greenworks.ugcPublishUpdate = function(published_file_id, file_name, title,
|
greenworks.ugcPublishUpdate = function (
|
||||||
description, image_name, success_callback, error_callback,
|
published_file_id,
|
||||||
progress_callback) {
|
file_name,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
image_name,
|
||||||
|
success_callback,
|
||||||
|
error_callback,
|
||||||
|
progress_callback,
|
||||||
|
) {
|
||||||
var update_published_file_process = function () {
|
var update_published_file_process = function () {
|
||||||
if (progress_callback)
|
if (progress_callback) progress_callback("Completed on sharing files.");
|
||||||
progress_callback("Completed on sharing files.");
|
greenworks.updatePublishedWorkshopFile(
|
||||||
greenworks.updatePublishedWorkshopFile(published_file_id,
|
published_file_id,
|
||||||
file_name, image_name, title, description,
|
file_name,
|
||||||
function() { success_callback(); },
|
image_name,
|
||||||
function(err) { error_process(err, error_callback); });
|
title,
|
||||||
|
description,
|
||||||
|
function () {
|
||||||
|
success_callback();
|
||||||
|
},
|
||||||
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
greenworks.saveFilesToCloud([file_name, image_name], function() {
|
greenworks.saveFilesToCloud(
|
||||||
file_share_process(file_name, image_name, update_published_file_process,
|
[file_name, image_name],
|
||||||
error_callback, progress_callback);
|
function () {
|
||||||
}, function(err) { error_process(err, error_callback); });
|
file_share_process(file_name, image_name, update_published_file_process, error_callback, progress_callback);
|
||||||
}
|
},
|
||||||
|
function (err) {
|
||||||
|
error_process(err, error_callback);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Greenworks Utils APIs implmentation.
|
// Greenworks Utils APIs implmentation.
|
||||||
greenworks.Utils.move = function(source_dir, target_dir, success_callback,
|
greenworks.Utils.move = function (source_dir, target_dir, success_callback, error_callback) {
|
||||||
error_callback) {
|
|
||||||
fs.rename(source_dir, target_dir, function (err) {
|
fs.rename(source_dir, target_dir, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (error_callback) error_callback(err);
|
if (error_callback) error_callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (success_callback)
|
if (success_callback) success_callback();
|
||||||
success_callback();
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
greenworks.init = function () {
|
greenworks.init = function () {
|
||||||
if (this.initAPI()) return true;
|
if (this.initAPI()) return true;
|
||||||
if (!this.isSteamRunning())
|
if (!this.isSteamRunning()) throw new Error("Steam initialization failed. Steam is not running.");
|
||||||
throw new Error("Steam initialization failed. Steam is not running.");
|
|
||||||
var appId;
|
var appId;
|
||||||
try {
|
try {
|
||||||
appId = fs.readFileSync('steam_appid.txt', 'utf8');
|
appId = fs.readFileSync("steam_appid.txt", "utf8");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Steam initialization failed. Steam is running," +
|
throw new Error(
|
||||||
|
"Steam initialization failed. Steam is running," +
|
||||||
"but steam_appid.txt is missing. Expected to find it in: " +
|
"but steam_appid.txt is missing. Expected to find it in: " +
|
||||||
require('path').resolve('steam_appid.txt'));
|
require("path").resolve("steam_appid.txt"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!/^\d+ *\r?\n?$/.test(appId)) {
|
if (!/^\d+ *\r?\n?$/.test(appId)) {
|
||||||
throw new Error("Steam initialization failed. " +
|
throw new Error(
|
||||||
|
"Steam initialization failed. " +
|
||||||
"steam_appid.txt appears to be invalid; " +
|
"steam_appid.txt appears to be invalid; " +
|
||||||
"it should contain a numeric ID: " + appId);
|
"it should contain a numeric ID: " +
|
||||||
|
appId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
throw new Error("Steam initialization failed, but Steam is running, " +
|
throw new Error(
|
||||||
|
"Steam initialization failed, but Steam is running, " +
|
||||||
"and steam_appid.txt is present and valid." +
|
"and steam_appid.txt is present and valid." +
|
||||||
"Maybe that's not really YOUR app ID? " + appId.trim());
|
"Maybe that's not really YOUR app ID? " +
|
||||||
}
|
appId.trim(),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require("events").EventEmitter;
|
||||||
greenworks.__proto__ = EventEmitter.prototype;
|
greenworks.__proto__ = EventEmitter.prototype;
|
||||||
EventEmitter.call(greenworks);
|
EventEmitter.call(greenworks);
|
||||||
|
|
||||||
@ -212,6 +288,6 @@ greenworks._steam_events.on = function () {
|
|||||||
greenworks.emit.apply(greenworks, arguments);
|
greenworks.emit.apply(greenworks, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
process.versions['greenworks'] = greenworks._version;
|
process.versions["greenworks"] = greenworks._version;
|
||||||
|
|
||||||
module.exports = greenworks;
|
module.exports = greenworks;
|
||||||
|
@ -18,7 +18,7 @@ log.transports.console.level = config.get("console-log-level", "debug");
|
|||||||
log.catchErrors();
|
log.catchErrors();
|
||||||
log.info(`Started app: ${JSON.stringify(process.argv)}`);
|
log.info(`Started app: ${JSON.stringify(process.argv)}`);
|
||||||
|
|
||||||
process.on('uncaughtException', function () {
|
process.on("uncaughtException", function () {
|
||||||
// The exception will already have been logged by electron-log
|
// The exception will already have been logged by electron-log
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
@ -67,42 +67,43 @@ function setStopProcessHandler(app, window, enabled) {
|
|||||||
// So we'll alert the player to close their browser.
|
// So we'll alert the player to close their browser.
|
||||||
if (global.app_playerOpenedExternalLink) {
|
if (global.app_playerOpenedExternalLink) {
|
||||||
await dialog.showMessageBox({
|
await dialog.showMessageBox({
|
||||||
title: 'Bitburner',
|
title: "Bitburner",
|
||||||
message: 'You may have to close your browser to properly exit the game.',
|
message: "You may have to close your browser to properly exit the game.",
|
||||||
detail: 'Steam will keep tracking Bitburner as "Running" if any process started within the game is still running.' +
|
detail:
|
||||||
' This includes launching an external link, which opens up your browser.',
|
'Steam will keep tracking Bitburner as "Running" if any process started within the game is still running.' +
|
||||||
type: 'warning', buttons: ['OK']
|
" This includes launching an external link, which opens up your browser.",
|
||||||
|
type: "warning",
|
||||||
|
buttons: ["OK"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// We'll try to execute javascript on the page to see if we're stuck
|
// We'll try to execute javascript on the page to see if we're stuck
|
||||||
let canRunJS = false;
|
let canRunJS = false;
|
||||||
window.webContents.executeJavaScript('window.stop(); document.close()', true)
|
window.webContents.executeJavaScript("window.stop(); document.close()", true).then(() => (canRunJS = true));
|
||||||
.then(() => canRunJS = true);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Wait a few milliseconds to prevent a race condition before loading the exit screen
|
// Wait a few milliseconds to prevent a race condition before loading the exit screen
|
||||||
window.webContents.stop();
|
window.webContents.stop();
|
||||||
window.loadFile("exit.html")
|
window.loadFile("exit.html");
|
||||||
}, 20);
|
}, 20);
|
||||||
|
|
||||||
// Wait 200ms, if the promise has not yet resolved, let's crash the process since we're possibly in a stuck scenario
|
// Wait 200ms, if the promise has not yet resolved, let's crash the process since we're possibly in a stuck scenario
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!canRunJS) {
|
if (!canRunJS) {
|
||||||
// We're stuck, let's crash the process
|
// We're stuck, let's crash the process
|
||||||
log.warn('Forcefully crashing the renderer process');
|
log.warn("Forcefully crashing the renderer process");
|
||||||
window.webContents.forcefullyCrashRenderer();
|
window.webContents.forcefullyCrashRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug('Destroying the window');
|
log.debug("Destroying the window");
|
||||||
window.destroy();
|
window.destroy();
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
};
|
||||||
|
|
||||||
const clearWindowHandler = () => {
|
const clearWindowHandler = () => {
|
||||||
window = null;
|
window = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const stopProcessHandler = () => {
|
const stopProcessHandler = () => {
|
||||||
log.info('Quitting the app...');
|
log.info("Quitting the app...");
|
||||||
app.isQuiting = true;
|
app.isQuiting = true;
|
||||||
app.quit();
|
app.quit();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
@ -121,12 +122,12 @@ function setStopProcessHandler(app, window, enabled) {
|
|||||||
const restoreNewest = config.get("onload-restore-newest", true);
|
const restoreNewest = config.get("onload-restore-newest", true);
|
||||||
if (restoreNewest && !isRestoreDisabled) {
|
if (restoreNewest && !isRestoreDisabled) {
|
||||||
try {
|
try {
|
||||||
await storage.restoreIfNewerExists(window)
|
await storage.restoreIfNewerExists(window);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error("Could not restore newer file", error);
|
log.error("Could not restore newer file", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const receivedDisableRestoreHandler = async (event, arg) => {
|
const receivedDisableRestoreHandler = async (event, arg) => {
|
||||||
if (!window) {
|
if (!window) {
|
||||||
@ -140,7 +141,7 @@ function setStopProcessHandler(app, window, enabled) {
|
|||||||
isRestoreDisabled = false;
|
isRestoreDisabled = false;
|
||||||
log.debug("Re-enabling auto-restore");
|
log.debug("Re-enabling auto-restore");
|
||||||
}, arg.duration);
|
}, arg.duration);
|
||||||
}
|
};
|
||||||
|
|
||||||
const receivedGameSavedHandler = async (event, arg) => {
|
const receivedGameSavedHandler = async (event, arg) => {
|
||||||
if (!window) {
|
if (!window) {
|
||||||
@ -164,10 +165,11 @@ function setStopProcessHandler(app, window, enabled) {
|
|||||||
log.debug(`Auto-save to cloud disabled for save game under ${minimumPlaytime}ms (${playtime}ms)`);
|
log.debug(`Auto-save to cloud disabled for save game under ${minimumPlaytime}ms (${playtime}ms)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const saveToCloud = debounce(async (save) => {
|
const saveToCloud = debounce(
|
||||||
log.debug("Saving to Steam Cloud ...")
|
async (save) => {
|
||||||
|
log.debug("Saving to Steam Cloud ...");
|
||||||
try {
|
try {
|
||||||
const playerId = window.gameInfo.player.identifier;
|
const playerId = window.gameInfo.player.identifier;
|
||||||
await storage.pushGameSaveToSteamCloud(save, playerId);
|
await storage.pushGameSaveToSteamCloud(save, playerId);
|
||||||
@ -176,26 +178,33 @@ function setStopProcessHandler(app, window, enabled) {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
utils.writeToast(window, "Could not save to Steam Cloud.", "error", 5000);
|
utils.writeToast(window, "Could not save to Steam Cloud.", "error", 5000);
|
||||||
}
|
}
|
||||||
}, config.get("cloud-save-min-time", 1000 * 60 * 15), { leading: true });
|
},
|
||||||
|
config.get("cloud-save-min-time", 1000 * 60 * 15),
|
||||||
|
{ leading: true },
|
||||||
|
);
|
||||||
|
|
||||||
const saveToDisk = debounce(async (save, fileName) => {
|
const saveToDisk = debounce(
|
||||||
log.debug("Saving to Disk ...")
|
async (save, fileName) => {
|
||||||
|
log.debug("Saving to Disk ...");
|
||||||
try {
|
try {
|
||||||
const file = await storage.saveGameToDisk(window, { save, fileName });
|
const file = await storage.saveGameToDisk(window, { save, fileName });
|
||||||
log.silly(`Saved Game to '${file.replaceAll('\\', '\\\\')}'`);
|
log.silly(`Saved Game to '${file.replaceAll("\\", "\\\\")}'`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
utils.writeToast(window, "Could not save to disk", "error", 5000);
|
utils.writeToast(window, "Could not save to disk", "error", 5000);
|
||||||
}
|
}
|
||||||
}, config.get("disk-save-min-time", 1000 * 60 * 5), { leading: true });
|
},
|
||||||
|
config.get("disk-save-min-time", 1000 * 60 * 5),
|
||||||
|
{ leading: true },
|
||||||
|
);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
log.debug("Adding closing handlers");
|
log.debug("Adding closing handlers");
|
||||||
ipcMain.on("push-game-ready", receivedGameReadyHandler);
|
ipcMain.on("push-game-ready", receivedGameReadyHandler);
|
||||||
ipcMain.on("push-game-saved", receivedGameSavedHandler);
|
ipcMain.on("push-game-saved", receivedGameSavedHandler);
|
||||||
ipcMain.on("push-disable-restore", receivedDisableRestoreHandler)
|
ipcMain.on("push-disable-restore", receivedDisableRestoreHandler);
|
||||||
window.on("closed", clearWindowHandler);
|
window.on("closed", clearWindowHandler);
|
||||||
window.on("close", closingWindowHandler)
|
window.on("close", closingWindowHandler);
|
||||||
app.on("window-all-closed", stopProcessHandler);
|
app.on("window-all-closed", stopProcessHandler);
|
||||||
} else {
|
} else {
|
||||||
log.debug("Removing closing handlers");
|
log.debug("Removing closing handlers");
|
||||||
@ -213,7 +222,7 @@ async function startWindow(noScript) {
|
|||||||
global.app_handlers = {
|
global.app_handlers = {
|
||||||
stopProcess: setStopProcessHandler,
|
stopProcess: setStopProcessHandler,
|
||||||
createWindow: startWindow,
|
createWindow: startWindow,
|
||||||
}
|
};
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
log.info("Application is ready!");
|
log.info("Application is ready!");
|
||||||
@ -231,7 +240,8 @@ app.whenReady().then(async () => {
|
|||||||
title: "Bitburner",
|
title: "Bitburner",
|
||||||
message: "Could not connect to Steam",
|
message: "Could not connect to Steam",
|
||||||
detail: `${global.greenworksError}\n\nYou won't be able to receive achievements until this is resolved and you restart the game.`,
|
detail: `${global.greenworksError}\n\nYou won't be able to receive achievements until this is resolved and you restart the game.`,
|
||||||
type: 'warning', buttons: ['OK']
|
type: "warning",
|
||||||
|
buttons: ["OK"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
106
electron/menu.js
106
electron/menu.js
@ -37,7 +37,7 @@ function getMenu(window) {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
utils.writeToast(window, "Could not load last save from disk", "error", 5000);
|
utils.writeToast(window, "Could not load last save from disk", "error", 5000);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Load From File",
|
label: "Load From File",
|
||||||
@ -51,9 +51,7 @@ function getMenu(window) {
|
|||||||
{ name: "Game Saves", extensions: ["json", "json.gz", "txt"] },
|
{ name: "Game Saves", extensions: ["json", "json.gz", "txt"] },
|
||||||
{ name: "All", extensions: ["*"] },
|
{ name: "All", extensions: ["*"] },
|
||||||
],
|
],
|
||||||
properties: [
|
properties: ["openFile", "dontAddToRecent"],
|
||||||
"openFile", "dontAddToRecent",
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
if (result.canceled) return;
|
if (result.canceled) return;
|
||||||
const file = result.filePaths[0];
|
const file = result.filePaths[0];
|
||||||
@ -65,7 +63,7 @@ function getMenu(window) {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
utils.writeToast(window, "Could not load save from disk", "error", 5000);
|
utils.writeToast(window, "Could not load save from disk", "error", 5000);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Load From Steam Cloud",
|
label: "Load From Steam Cloud",
|
||||||
@ -78,7 +76,7 @@ function getMenu(window) {
|
|||||||
log.error(error);
|
log.error(error);
|
||||||
utils.writeToast(window, "Could not load from Steam Cloud", "error", 5000);
|
utils.writeToast(window, "Could not load from Steam Cloud", "error", 5000);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "separator",
|
type: "separator",
|
||||||
@ -89,8 +87,7 @@ function getMenu(window) {
|
|||||||
checked: storage.isSaveCompressionEnabled(),
|
checked: storage.isSaveCompressionEnabled(),
|
||||||
click: (menuItem) => {
|
click: (menuItem) => {
|
||||||
storage.setSaveCompressionConfig(menuItem.checked);
|
storage.setSaveCompressionConfig(menuItem.checked);
|
||||||
utils.writeToast(window,
|
utils.writeToast(window, `${menuItem.checked ? "Enabled" : "Disabled"} Save Compression`, "info", 5000);
|
||||||
`${menuItem.checked ? "Enabled" : "Disabled"} Save Compression`, "info", 5000);
|
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -100,8 +97,7 @@ function getMenu(window) {
|
|||||||
checked: storage.isAutosaveEnabled(),
|
checked: storage.isAutosaveEnabled(),
|
||||||
click: (menuItem) => {
|
click: (menuItem) => {
|
||||||
storage.setAutosaveConfig(menuItem.checked);
|
storage.setAutosaveConfig(menuItem.checked);
|
||||||
utils.writeToast(window,
|
utils.writeToast(window, `${menuItem.checked ? "Enabled" : "Disabled"} Auto-Save to Disk`, "info", 5000);
|
||||||
`${menuItem.checked ? "Enabled" : "Disabled"} Auto-Save to Disk`, "info", 5000);
|
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -112,8 +108,12 @@ function getMenu(window) {
|
|||||||
checked: storage.isCloudEnabled(),
|
checked: storage.isCloudEnabled(),
|
||||||
click: (menuItem) => {
|
click: (menuItem) => {
|
||||||
storage.setCloudEnabledConfig(menuItem.checked);
|
storage.setCloudEnabledConfig(menuItem.checked);
|
||||||
utils.writeToast(window,
|
utils.writeToast(
|
||||||
`${menuItem.checked ? "Enabled" : "Disabled"} Auto-Save to Steam Cloud`, "info", 5000);
|
window,
|
||||||
|
`${menuItem.checked ? "Enabled" : "Disabled"} Auto-Save to Steam Cloud`,
|
||||||
|
"info",
|
||||||
|
5000,
|
||||||
|
);
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -123,8 +123,12 @@ function getMenu(window) {
|
|||||||
checked: config.get("onload-restore-newest", true),
|
checked: config.get("onload-restore-newest", true),
|
||||||
click: (menuItem) => {
|
click: (menuItem) => {
|
||||||
config.set("onload-restore-newest", menuItem.checked);
|
config.set("onload-restore-newest", menuItem.checked);
|
||||||
utils.writeToast(window,
|
utils.writeToast(
|
||||||
`${menuItem.checked ? "Enabled" : "Disabled"} Restore Newest on Load`, "info", 5000);
|
window,
|
||||||
|
`${menuItem.checked ? "Enabled" : "Disabled"} Restore Newest on Load`,
|
||||||
|
"info",
|
||||||
|
5000,
|
||||||
|
);
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -153,7 +157,7 @@ function getMenu(window) {
|
|||||||
label: "Open Data Directory",
|
label: "Open Data Directory",
|
||||||
click: () => shell.openPath(app.getPath("userData")),
|
click: () => shell.openPath(app.getPath("userData")),
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "separator",
|
type: "separator",
|
||||||
@ -162,7 +166,7 @@ function getMenu(window) {
|
|||||||
label: "Quit",
|
label: "Quit",
|
||||||
click: () => app.quit(),
|
click: () => app.quit(),
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Edit",
|
label: "Edit",
|
||||||
@ -210,29 +214,29 @@ function getMenu(window) {
|
|||||||
label: "API Server",
|
label: "API Server",
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: api.isListening() ? 'Disable Server' : 'Enable Server',
|
label: api.isListening() ? "Disable Server" : "Enable Server",
|
||||||
click: (async () => {
|
click: async () => {
|
||||||
let success = false;
|
let success = false;
|
||||||
try {
|
try {
|
||||||
await api.toggleServer();
|
await api.toggleServer();
|
||||||
success = true;
|
success = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
utils.showErrorBox('Error Toggling Server', error);
|
utils.showErrorBox("Error Toggling Server", error);
|
||||||
}
|
}
|
||||||
if (success && api.isListening()) {
|
if (success && api.isListening()) {
|
||||||
utils.writeToast(window, "Started API Server", "success");
|
utils.writeToast(window, "Started API Server", "success");
|
||||||
} else if (success && !api.isListening()) {
|
} else if (success && !api.isListening()) {
|
||||||
utils.writeToast(window, "Stopped API Server", "success");
|
utils.writeToast(window, "Stopped API Server", "success");
|
||||||
} else {
|
} else {
|
||||||
utils.writeToast(window, 'Error Toggling Server', "error");
|
utils.writeToast(window, "Error Toggling Server", "error");
|
||||||
}
|
}
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
})
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: api.isAutostart() ? 'Disable Autostart' : 'Enable Autostart',
|
label: api.isAutostart() ? "Disable Autostart" : "Enable Autostart",
|
||||||
click: (async () => {
|
click: async () => {
|
||||||
api.toggleAutostart();
|
api.toggleAutostart();
|
||||||
if (api.isAutostart()) {
|
if (api.isAutostart()) {
|
||||||
utils.writeToast(window, "Enabled API Server Autostart", "success");
|
utils.writeToast(window, "Enabled API Server Autostart", "success");
|
||||||
@ -240,42 +244,45 @@ function getMenu(window) {
|
|||||||
utils.writeToast(window, "Disabled API Server Autostart", "success");
|
utils.writeToast(window, "Disabled API Server Autostart", "success");
|
||||||
}
|
}
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
})
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Copy Auth Token',
|
label: "Copy Auth Token",
|
||||||
click: (async () => {
|
click: async () => {
|
||||||
const token = api.getAuthenticationToken();
|
const token = api.getAuthenticationToken();
|
||||||
log.log('Wrote authentication token to clipboard');
|
log.log("Wrote authentication token to clipboard");
|
||||||
clipboard.writeText(token);
|
clipboard.writeText(token);
|
||||||
utils.writeToast(window, "Copied Authentication Token to Clipboard", "info");
|
utils.writeToast(window, "Copied Authentication Token to Clipboard", "info");
|
||||||
})
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator',
|
type: "separator",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Information',
|
label: "Information",
|
||||||
click: () => {
|
click: () => {
|
||||||
dialog.showMessageBox({
|
dialog
|
||||||
type: 'info',
|
.showMessageBox({
|
||||||
title: 'Bitburner > API Server Information',
|
type: "info",
|
||||||
message: 'The API Server is used to write script files to your in-game home.',
|
title: "Bitburner > API Server Information",
|
||||||
detail: 'There is an official Visual Studio Code extension that makes use of that feature.\n\n' +
|
message: "The API Server is used to write script files to your in-game home.",
|
||||||
'It allows you to write your script file in an external IDE and have them pushed over to the game automatically.\n' +
|
detail:
|
||||||
'If you want more information, head over to: https://github.com/bitburner-official/bitburner-vscode.',
|
"There is an official Visual Studio Code extension that makes use of that feature.\n\n" +
|
||||||
buttons: ['Dismiss', 'Open Extension Link (GitHub)'],
|
"It allows you to write your script file in an external IDE and have them pushed over to the game automatically.\n" +
|
||||||
|
"If you want more information, head over to: https://github.com/bitburner-official/bitburner-vscode.",
|
||||||
|
buttons: ["Dismiss", "Open Extension Link (GitHub)"],
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
cancelId: 0,
|
cancelId: 0,
|
||||||
noLink: true,
|
noLink: true,
|
||||||
}).then(({response}) => {
|
})
|
||||||
|
.then(({ response }) => {
|
||||||
if (response === 1) {
|
if (response === 1) {
|
||||||
utils.openExternal('https://github.com/bitburner-official/bitburner-vscode');
|
utils.openExternal("https://github.com/bitburner-official/bitburner-vscode");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Zoom",
|
label: "Zoom",
|
||||||
@ -291,7 +298,7 @@ function getMenu(window) {
|
|||||||
utils.setZoomFactor(window, newZoom);
|
utils.setZoomFactor(window, newZoom);
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
} else {
|
} else {
|
||||||
log.log('Max zoom out')
|
log.log("Max zoom out");
|
||||||
utils.writeToast(window, "Cannot zoom in anymore", "warning");
|
utils.writeToast(window, "Cannot zoom in anymore", "warning");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -307,7 +314,7 @@ function getMenu(window) {
|
|||||||
utils.setZoomFactor(window, newZoom);
|
utils.setZoomFactor(window, newZoom);
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
} else {
|
} else {
|
||||||
log.log('Max zoom in')
|
log.log("Max zoom in");
|
||||||
utils.writeToast(window, "Cannot zoom out anymore", "warning");
|
utils.writeToast(window, "Cannot zoom out anymore", "warning");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -340,8 +347,8 @@ function getMenu(window) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -352,5 +359,6 @@ function refreshMenu(window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getMenu, refreshMenu,
|
getMenu,
|
||||||
}
|
refreshMenu,
|
||||||
|
};
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const { ipcRenderer, contextBridge } = require('electron')
|
const { ipcRenderer, contextBridge } = require("electron");
|
||||||
const log = require("electron-log");
|
const log = require("electron-log");
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld(
|
contextBridge.exposeInMainWorld("electronBridge", {
|
||||||
"electronBridge", {
|
|
||||||
send: (channel, data) => {
|
send: (channel, data) => {
|
||||||
log.log("Send on channel " + channel)
|
log.log("Send on channel " + channel);
|
||||||
// whitelist channels
|
// whitelist channels
|
||||||
let validChannels = [
|
let validChannels = [
|
||||||
"get-save-data-response",
|
"get-save-data-response",
|
||||||
@ -20,7 +19,7 @@ contextBridge.exposeInMainWorld(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
receive: (channel, func) => {
|
receive: (channel, func) => {
|
||||||
log.log("Receive on channel " + channel)
|
log.log("Receive on channel " + channel);
|
||||||
let validChannels = [
|
let validChannels = [
|
||||||
"get-save-data-request",
|
"get-save-data-request",
|
||||||
"get-save-info-request",
|
"get-save-info-request",
|
||||||
@ -33,6 +32,5 @@ contextBridge.exposeInMainWorld(
|
|||||||
// Deliberately strip event as it includes `sender`
|
// Deliberately strip event as it includes `sender`
|
||||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
@ -16,9 +16,9 @@ const config = new Config();
|
|||||||
// https://stackoverflow.com/a/69418940
|
// https://stackoverflow.com/a/69418940
|
||||||
const dirSize = async (directory) => {
|
const dirSize = async (directory) => {
|
||||||
const files = await fs.readdir(directory);
|
const files = await fs.readdir(directory);
|
||||||
const stats = files.map(file => fs.stat(path.join(directory, file)));
|
const stats = files.map((file) => fs.stat(path.join(directory, file)));
|
||||||
return (await Promise.all(stats)).reduce((accumulator, { size }) => accumulator + size, 0);
|
return (await Promise.all(stats)).reduce((accumulator, { size }) => accumulator + size, 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getDirFileStats = async (directory) => {
|
const getDirFileStats = async (directory) => {
|
||||||
const files = await fs.readdir(directory);
|
const files = await fs.readdir(directory);
|
||||||
@ -26,30 +26,31 @@ const getDirFileStats = async (directory) => {
|
|||||||
const file = path.join(directory, f);
|
const file = path.join(directory, f);
|
||||||
return fs.stat(file).then((stat) => ({ file, stat }));
|
return fs.stat(file).then((stat) => ({ file, stat }));
|
||||||
});
|
});
|
||||||
const data = (await Promise.all(stats));
|
const data = await Promise.all(stats);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNewestFile = async (directory) => {
|
const getNewestFile = async (directory) => {
|
||||||
const data = await getDirFileStats(directory)
|
const data = await getDirFileStats(directory);
|
||||||
return data.sort((a, b) => b.stat.mtime.getTime() - a.stat.mtime.getTime())[0];
|
return data.sort((a, b) => b.stat.mtime.getTime() - a.stat.mtime.getTime())[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAllSaves = async (window) => {
|
const getAllSaves = async (window) => {
|
||||||
const rootDirectory = await getSaveFolder(window, true);
|
const rootDirectory = await getSaveFolder(window, true);
|
||||||
const data = await fs.readdir(rootDirectory, { withFileTypes: true });
|
const data = await fs.readdir(rootDirectory, { withFileTypes: true });
|
||||||
const savesPromises = data.filter((e) => e.isDirectory()).
|
const savesPromises = data
|
||||||
map((dir) => path.join(rootDirectory, dir.name)).
|
.filter((e) => e.isDirectory())
|
||||||
map((dir) => getDirFileStats(dir));
|
.map((dir) => path.join(rootDirectory, dir.name))
|
||||||
|
.map((dir) => getDirFileStats(dir));
|
||||||
const saves = await Promise.all(savesPromises);
|
const saves = await Promise.all(savesPromises);
|
||||||
const flat = flatten(saves);
|
const flat = flatten(saves);
|
||||||
return flat;
|
return flat;
|
||||||
}
|
};
|
||||||
|
|
||||||
async function prepareSaveFolders(window) {
|
async function prepareSaveFolders(window) {
|
||||||
const rootFolder = await getSaveFolder(window, true);
|
const rootFolder = await getSaveFolder(window, true);
|
||||||
const currentFolder = await getSaveFolder(window);
|
const currentFolder = await getSaveFolder(window);
|
||||||
const backupsFolder = path.join(rootFolder, "/_backups")
|
const backupsFolder = path.join(rootFolder, "/_backups");
|
||||||
await prepareFolders(rootFolder, currentFolder, backupsFolder);
|
await prepareFolders(rootFolder, currentFolder, backupsFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ async function prepareFolders(...folders) {
|
|||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await fs.stat(folder);
|
await fs.stat(folder);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'ENOENT') {
|
if (error.code === "ENOENT") {
|
||||||
log.warn(`'${folder}' not found, creating it...`);
|
log.warn(`'${folder}' not found, creating it...`);
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await fs.mkdir(folder);
|
await fs.mkdir(folder);
|
||||||
@ -125,14 +126,14 @@ function isCloudEnabled() {
|
|||||||
function saveCloudFile(name, content) {
|
function saveCloudFile(name, content) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
greenworks.saveTextToFile(name, content, resolve, reject);
|
greenworks.saveTextToFile(name, content, resolve, reject);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFirstCloudFile() {
|
function getFirstCloudFile() {
|
||||||
const nbFiles = greenworks.getFileCount();
|
const nbFiles = greenworks.getFileCount();
|
||||||
if (nbFiles === 0) throw new Error('No files in cloud');
|
if (nbFiles === 0) throw new Error("No files in cloud");
|
||||||
const file = greenworks.getFileNameAndSize(0);
|
const file = greenworks.getFileNameAndSize(0);
|
||||||
log.silly(`Found ${nbFiles} files.`)
|
log.silly(`Found ${nbFiles} files.`);
|
||||||
log.silly(`First File: ${file.name} (${file.size} bytes)`);
|
log.silly(`First File: ${file.name} (${file.size} bytes)`);
|
||||||
return file.name;
|
return file.name;
|
||||||
}
|
}
|
||||||
@ -153,7 +154,7 @@ function deleteCloudFile() {
|
|||||||
|
|
||||||
async function getSteamCloudQuota() {
|
async function getSteamCloudQuota() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
greenworks.getCloudQuota(resolve, reject)
|
greenworks.getCloudQuota(resolve, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,9 +167,9 @@ async function backupSteamDataToDisk(currentPlayerId) {
|
|||||||
if (previousPlayerId !== currentPlayerId) {
|
if (previousPlayerId !== currentPlayerId) {
|
||||||
const backupSave = await getSteamCloudSaveString();
|
const backupSave = await getSteamCloudSaveString();
|
||||||
const backupFile = path.join(app.getPath("userData"), "/saves/_backups", `${previousPlayerId}.json.gz`);
|
const backupFile = path.join(app.getPath("userData"), "/saves/_backups", `${previousPlayerId}.json.gz`);
|
||||||
const buffer = Buffer.from(backupSave, 'base64').toString('utf8');
|
const buffer = Buffer.from(backupSave, "base64").toString("utf8");
|
||||||
saveContent = await gzip(buffer);
|
saveContent = await gzip(buffer);
|
||||||
await fs.writeFile(backupFile, saveContent, 'utf8');
|
await fs.writeFile(backupFile, saveContent, "utf8");
|
||||||
log.debug(`Saved backup game to '${backupFile}`);
|
log.debug(`Saved backup game to '${backupFile}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,7 +220,9 @@ async function saveGameToDisk(window, saveData) {
|
|||||||
const remainingSpaceBytes = maxFolderSizeBytes - saveFolderSizeBytes;
|
const remainingSpaceBytes = maxFolderSizeBytes - saveFolderSizeBytes;
|
||||||
log.debug(`Folder Usage: ${saveFolderSizeBytes} bytes`);
|
log.debug(`Folder Usage: ${saveFolderSizeBytes} bytes`);
|
||||||
log.debug(`Folder Capacity: ${maxFolderSizeBytes} bytes`);
|
log.debug(`Folder Capacity: ${maxFolderSizeBytes} bytes`);
|
||||||
log.debug(`Remaining: ${remainingSpaceBytes} bytes (${(saveFolderSizeBytes / maxFolderSizeBytes * 100).toFixed(2)}% used)`)
|
log.debug(
|
||||||
|
`Remaining: ${remainingSpaceBytes} bytes (${((saveFolderSizeBytes / maxFolderSizeBytes) * 100).toFixed(2)}% used)`,
|
||||||
|
);
|
||||||
const shouldCompress = isSaveCompressionEnabled();
|
const shouldCompress = isSaveCompressionEnabled();
|
||||||
const fileName = saveData.fileName;
|
const fileName = saveData.fileName;
|
||||||
const file = path.join(currentFolder, fileName + (shouldCompress ? ".gz" : ""));
|
const file = path.join(currentFolder, fileName + (shouldCompress ? ".gz" : ""));
|
||||||
@ -227,10 +230,10 @@ async function saveGameToDisk(window, saveData) {
|
|||||||
let saveContent = saveData.save;
|
let saveContent = saveData.save;
|
||||||
if (shouldCompress) {
|
if (shouldCompress) {
|
||||||
// Let's decode the base64 string so GZIP is more efficient.
|
// Let's decode the base64 string so GZIP is more efficient.
|
||||||
const buffer = Buffer.from(saveContent, 'base64').toString('utf8');
|
const buffer = Buffer.from(saveContent, "base64").toString("utf8");
|
||||||
saveContent = await gzip(buffer);
|
saveContent = await gzip(buffer);
|
||||||
}
|
}
|
||||||
await fs.writeFile(file, saveContent, 'utf8');
|
await fs.writeFile(file, saveContent, "utf8");
|
||||||
log.debug(`Saved Game to '${file}'`);
|
log.debug(`Saved Game to '${file}'`);
|
||||||
log.debug(`Save Size: ${saveContent.length} bytes`);
|
log.debug(`Save Size: ${saveContent.length} bytes`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -240,7 +243,8 @@ async function saveGameToDisk(window, saveData) {
|
|||||||
const fileStats = await getDirFileStats(currentFolder);
|
const fileStats = await getDirFileStats(currentFolder);
|
||||||
const oldestFiles = fileStats
|
const oldestFiles = fileStats
|
||||||
.sort((a, b) => a.stat.mtime.getTime() - b.stat.mtime.getTime())
|
.sort((a, b) => a.stat.mtime.getTime() - b.stat.mtime.getTime())
|
||||||
.map(f => f.file).filter(f => f !== file);
|
.map((f) => f.file)
|
||||||
|
.filter((f) => f !== file);
|
||||||
|
|
||||||
while (saveFolderSizeBytes > maxFolderSizeBytes && oldestFiles.length > 0) {
|
while (saveFolderSizeBytes > maxFolderSizeBytes && oldestFiles.length > 0) {
|
||||||
const fileToRemove = oldestFiles.shift();
|
const fileToRemove = oldestFiles.shift();
|
||||||
@ -255,7 +259,12 @@ async function saveGameToDisk(window, saveData) {
|
|||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
saveFolderSizeBytes = await getFolderSizeInBytes(currentFolder);
|
saveFolderSizeBytes = await getFolderSizeInBytes(currentFolder);
|
||||||
log.debug(`Save Folder: ${saveFolderSizeBytes} bytes`);
|
log.debug(`Save Folder: ${saveFolderSizeBytes} bytes`);
|
||||||
log.debug(`Remaining: ${maxFolderSizeBytes - saveFolderSizeBytes} bytes (${(saveFolderSizeBytes / maxFolderSizeBytes * 100).toFixed(2)}% used)`)
|
log.debug(
|
||||||
|
`Remaining: ${maxFolderSizeBytes - saveFolderSizeBytes} bytes (${(
|
||||||
|
(saveFolderSizeBytes / maxFolderSizeBytes) *
|
||||||
|
100
|
||||||
|
).toFixed(2)}% used)`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
@ -271,13 +280,13 @@ async function loadLastFromDisk(window) {
|
|||||||
async function loadFileFromDisk(path) {
|
async function loadFileFromDisk(path) {
|
||||||
const buffer = await fs.readFile(path);
|
const buffer = await fs.readFile(path);
|
||||||
let content;
|
let content;
|
||||||
if (path.endsWith('.gz')) {
|
if (path.endsWith(".gz")) {
|
||||||
const uncompressedBuffer = await gunzip(buffer);
|
const uncompressedBuffer = await gunzip(buffer);
|
||||||
content = uncompressedBuffer.toString('base64');
|
content = uncompressedBuffer.toString("base64");
|
||||||
log.debug(`Uncompressed file content (new size: ${content.length} bytes)`);
|
log.debug(`Uncompressed file content (new size: ${content.length} bytes)`);
|
||||||
} else {
|
} else {
|
||||||
content = buffer.toString('utf8');
|
content = buffer.toString("utf8");
|
||||||
log.debug(`Loaded file with ${content.length} bytes`)
|
log.debug(`Loaded file with ${content.length} bytes`);
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
@ -293,10 +302,10 @@ function getSaveInformation(window, save) {
|
|||||||
|
|
||||||
function getCurrentSave(window) {
|
function getCurrentSave(window) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
ipcMain.once('get-save-data-response', (event, data) => {
|
ipcMain.once("get-save-data-response", (event, data) => {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
window.webContents.send('get-save-data-request');
|
window.webContents.send("get-save-data-request");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,8 +331,7 @@ async function restoreIfNewerExists(window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const saves = (await getAllSaves()).
|
const saves = (await getAllSaves()).sort((a, b) => b.stat.mtime.getTime() - a.stat.mtime.getTime());
|
||||||
sort((a, b) => b.stat.mtime.getTime() - a.stat.mtime.getTime());
|
|
||||||
if (saves.length > 0) {
|
if (saves.length > 0) {
|
||||||
disk.save = await loadFileFromDisk(saves[0].file);
|
disk.save = await loadFileFromDisk(saves[0].file);
|
||||||
disk.data = await getSaveInformation(window, disk.save);
|
disk.data = await getSaveInformation(window, disk.save);
|
||||||
@ -339,18 +347,17 @@ async function restoreIfNewerExists(window) {
|
|||||||
log.info("No data to import");
|
log.info("No data to import");
|
||||||
} else if (!steam.data) {
|
} else if (!steam.data) {
|
||||||
// We'll just compare using the lastSave field for now.
|
// We'll just compare using the lastSave field for now.
|
||||||
log.debug('Best potential save match: Disk');
|
log.debug("Best potential save match: Disk");
|
||||||
bestMatch = disk;
|
bestMatch = disk;
|
||||||
} else if (!disk.data) {
|
} else if (!disk.data) {
|
||||||
log.debug('Best potential save match: Steam Cloud');
|
log.debug("Best potential save match: Steam Cloud");
|
||||||
bestMatch = steam;
|
bestMatch = steam;
|
||||||
} else if ((steam.data.lastSave >= disk.data.lastSave)
|
} else if (steam.data.lastSave >= disk.data.lastSave || steam.data.playtime + lowPlaytime > disk.data.playtime) {
|
||||||
|| (steam.data.playtime + lowPlaytime > disk.data.playtime)) {
|
|
||||||
// We want to prioritze steam data if the playtime is very close
|
// We want to prioritze steam data if the playtime is very close
|
||||||
log.debug('Best potential save match: Steam Cloud');
|
log.debug("Best potential save match: Steam Cloud");
|
||||||
bestMatch = steam;
|
bestMatch = steam;
|
||||||
} else {
|
} else {
|
||||||
log.debug('Best potential save match: disk');
|
log.debug("Best potential save match: disk");
|
||||||
bestMatch = disk;
|
bestMatch = disk;
|
||||||
}
|
}
|
||||||
if (bestMatch) {
|
if (bestMatch) {
|
||||||
@ -373,12 +380,24 @@ async function restoreIfNewerExists(window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getCurrentSave, getSaveInformation,
|
getCurrentSave,
|
||||||
restoreIfNewerExists, pushSaveGameForImport,
|
getSaveInformation,
|
||||||
pushGameSaveToSteamCloud, getSteamCloudSaveString, getSteamCloudQuota, deleteCloudFile,
|
restoreIfNewerExists,
|
||||||
saveGameToDisk, loadLastFromDisk, loadFileFromDisk,
|
pushSaveGameForImport,
|
||||||
getSaveFolder, prepareSaveFolders, getAllSaves,
|
pushGameSaveToSteamCloud,
|
||||||
isCloudEnabled, setCloudEnabledConfig,
|
getSteamCloudSaveString,
|
||||||
isAutosaveEnabled, setAutosaveConfig,
|
getSteamCloudQuota,
|
||||||
isSaveCompressionEnabled, setSaveCompressionConfig,
|
deleteCloudFile,
|
||||||
|
saveGameToDisk,
|
||||||
|
loadLastFromDisk,
|
||||||
|
loadFileFromDisk,
|
||||||
|
getSaveFolder,
|
||||||
|
prepareSaveFolders,
|
||||||
|
getAllSaves,
|
||||||
|
isCloudEnabled,
|
||||||
|
setCloudEnabledConfig,
|
||||||
|
isAutosaveEnabled,
|
||||||
|
setAutosaveConfig,
|
||||||
|
isSaveCompressionEnabled,
|
||||||
|
setSaveCompressionConfig,
|
||||||
};
|
};
|
||||||
|
@ -9,39 +9,42 @@ const Config = require("electron-config");
|
|||||||
const config = new Config();
|
const config = new Config();
|
||||||
|
|
||||||
function reloadAndKill(window, killScripts) {
|
function reloadAndKill(window, killScripts) {
|
||||||
const setStopProcessHandler = global.app_handlers.stopProcess
|
const setStopProcessHandler = global.app_handlers.stopProcess;
|
||||||
const createWindowHandler = global.app_handlers.createWindow;
|
const createWindowHandler = global.app_handlers.createWindow;
|
||||||
|
|
||||||
log.info('Reloading & Killing all scripts...');
|
log.info("Reloading & Killing all scripts...");
|
||||||
setStopProcessHandler(app, window, false);
|
setStopProcessHandler(app, window, false);
|
||||||
|
|
||||||
achievements.disableAchievementsInterval(window);
|
achievements.disableAchievementsInterval(window);
|
||||||
api.disable();
|
api.disable();
|
||||||
|
|
||||||
window.webContents.forcefullyCrashRenderer();
|
window.webContents.forcefullyCrashRenderer();
|
||||||
window.on('closed', () => {
|
window.on("closed", () => {
|
||||||
// Wait for window to be closed before opening the new one to prevent race conditions
|
// Wait for window to be closed before opening the new one to prevent race conditions
|
||||||
log.debug('Opening new window');
|
log.debug("Opening new window");
|
||||||
createWindowHandler(killScripts);
|
createWindowHandler(killScripts);
|
||||||
})
|
});
|
||||||
|
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function promptForReload(window) {
|
function promptForReload(window) {
|
||||||
detachUnresponsiveAppHandler(window);
|
detachUnresponsiveAppHandler(window);
|
||||||
dialog.showMessageBox({
|
dialog
|
||||||
type: 'error',
|
.showMessageBox({
|
||||||
title: 'Bitburner > Application Unresponsive',
|
type: "error",
|
||||||
message: 'The application is unresponsive, possibly due to an infinite loop in your scripts.',
|
title: "Bitburner > Application Unresponsive",
|
||||||
detail:' Did you forget a ns.sleep(x)?\n\n' +
|
message: "The application is unresponsive, possibly due to an infinite loop in your scripts.",
|
||||||
'The application will be restarted for you, do you want to kill all running scripts?',
|
detail:
|
||||||
buttons: ['Restart', 'Cancel'],
|
" Did you forget a ns.sleep(x)?\n\n" +
|
||||||
|
"The application will be restarted for you, do you want to kill all running scripts?",
|
||||||
|
buttons: ["Restart", "Cancel"],
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
checkboxLabel: 'Kill all running scripts',
|
checkboxLabel: "Kill all running scripts",
|
||||||
checkboxChecked: true,
|
checkboxChecked: true,
|
||||||
noLink: true,
|
noLink: true,
|
||||||
}).then(({response, checkboxChecked}) => {
|
})
|
||||||
|
.then(({ response, checkboxChecked }) => {
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
reloadAndKill(window, checkboxChecked);
|
reloadAndKill(window, checkboxChecked);
|
||||||
} else {
|
} else {
|
||||||
@ -52,18 +55,15 @@ function promptForReload(window) {
|
|||||||
|
|
||||||
function attachUnresponsiveAppHandler(window) {
|
function attachUnresponsiveAppHandler(window) {
|
||||||
window.unresponsiveHandler = () => promptForReload(window);
|
window.unresponsiveHandler = () => promptForReload(window);
|
||||||
window.on('unresponsive', window.unresponsiveHandler);
|
window.on("unresponsive", window.unresponsiveHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function detachUnresponsiveAppHandler(window) {
|
function detachUnresponsiveAppHandler(window) {
|
||||||
window.off('unresponsive', window.unresponsiveHandler);
|
window.off("unresponsive", window.unresponsiveHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showErrorBox(title, error) {
|
function showErrorBox(title, error) {
|
||||||
dialog.showErrorBox(
|
dialog.showErrorBox(title, `${error.name}\n\n${error.message}`);
|
||||||
title,
|
|
||||||
`${error.name}\n\n${error.message}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportSaveFromIndexedDb() {
|
function exportSaveFromIndexedDb() {
|
||||||
@ -71,15 +71,15 @@ function exportSaveFromIndexedDb() {
|
|||||||
const dbRequest = indexedDB.open("bitburnerSave");
|
const dbRequest = indexedDB.open("bitburnerSave");
|
||||||
dbRequest.onsuccess = () => {
|
dbRequest.onsuccess = () => {
|
||||||
const db = dbRequest.result;
|
const db = dbRequest.result;
|
||||||
const transaction = db.transaction(['savestring'], "readonly");
|
const transaction = db.transaction(["savestring"], "readonly");
|
||||||
const store = transaction.objectStore('savestring');
|
const store = transaction.objectStore("savestring");
|
||||||
const request = store.get('save');
|
const request = store.get("save");
|
||||||
request.onsuccess = () => {
|
request.onsuccess = () => {
|
||||||
const file = new Blob([request.result], {type: 'text/plain'});
|
const file = new Blob([request.result], { type: "text/plain" });
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
const url = URL.createObjectURL(file);
|
const url = URL.createObjectURL(file);
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = 'save.json';
|
a.download = "save.json";
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -87,24 +87,21 @@ function exportSaveFromIndexedDb() {
|
|||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
resolve();
|
resolve();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exportSave(window) {
|
async function exportSave(window) {
|
||||||
await window.webContents
|
await window.webContents.executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true);
|
||||||
.executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeTerminal(window, message, type = null) {
|
async function writeTerminal(window, message, type = null) {
|
||||||
await window.webContents
|
await window.webContents.executeJavaScript(`window.appNotifier.terminal("${message}", "${type}");`, true);
|
||||||
.executeJavaScript(`window.appNotifier.terminal("${message}", "${type}");`, true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeToast(window, message, type = "info", duration = 2000) {
|
async function writeToast(window, message, type = "info", duration = 2000) {
|
||||||
await window.webContents
|
await window.webContents.executeJavaScript(`window.appNotifier.toast("${message}", "${type}", ${duration});`, true);
|
||||||
.executeJavaScript(`window.appNotifier.toast("${message}", "${type}", ${duration});`, true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openExternal(url) {
|
function openExternal(url) {
|
||||||
@ -113,7 +110,7 @@ function openExternal(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getZoomFactor() {
|
function getZoomFactor() {
|
||||||
const configZoom = config.get('zoom', 1);
|
const configZoom = config.get("zoom", 1);
|
||||||
return configZoom;
|
return configZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,14 +118,20 @@ function setZoomFactor(window, zoom = null) {
|
|||||||
if (zoom === null) {
|
if (zoom === null) {
|
||||||
zoom = 1;
|
zoom = 1;
|
||||||
} else {
|
} else {
|
||||||
config.set('zoom', zoom);
|
config.set("zoom", zoom);
|
||||||
}
|
}
|
||||||
window.webContents.setZoomFactor(zoom);
|
window.webContents.setZoomFactor(zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
reloadAndKill, showErrorBox, exportSave,
|
reloadAndKill,
|
||||||
attachUnresponsiveAppHandler, detachUnresponsiveAppHandler,
|
showErrorBox,
|
||||||
openExternal, writeTerminal, writeToast,
|
exportSave,
|
||||||
getZoomFactor, setZoomFactor,
|
attachUnresponsiveAppHandler,
|
||||||
}
|
detachUnresponsiveAppHandler,
|
||||||
|
openExternal,
|
||||||
|
writeTerminal,
|
||||||
|
writeToast,
|
||||||
|
getZoomFactor,
|
||||||
|
setZoomFactor,
|
||||||
|
};
|
||||||
|
@ -4,12 +4,11 @@ module.exports = {
|
|||||||
transform: {
|
transform: {
|
||||||
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
|
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
|
||||||
},
|
},
|
||||||
testPathIgnorePatterns: [
|
testPathIgnorePatterns: [".cypress", "node_modules", "dist"],
|
||||||
'.cypress', 'node_modules', 'dist',
|
|
||||||
],
|
|
||||||
testEnvironment: "jsdom",
|
testEnvironment: "jsdom",
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/__mocks__/fileMock.js",
|
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
|
||||||
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
|
"<rootDir>/test/__mocks__/fileMock.js",
|
||||||
}
|
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
38
package-lock.json
generated
38
package-lock.json
generated
@ -69,7 +69,7 @@
|
|||||||
"babel-jest": "^27.0.6",
|
"babel-jest": "^27.0.6",
|
||||||
"babel-loader": "^8.0.5",
|
"babel-loader": "^8.0.5",
|
||||||
"cypress": "^8.3.1",
|
"cypress": "^8.3.1",
|
||||||
"electron": "^14.0.2",
|
"electron": "^14.2.4",
|
||||||
"electron-packager": "^15.4.0",
|
"electron-packager": "^15.4.0",
|
||||||
"eslint": "^7.24.0",
|
"eslint": "^7.24.0",
|
||||||
"file-loader": "^6.2.0",
|
"file-loader": "^6.2.0",
|
||||||
@ -7821,9 +7821,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/electron": {
|
"node_modules/electron": {
|
||||||
"version": "14.0.2",
|
"version": "14.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-14.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-14.2.4.tgz",
|
||||||
"integrity": "sha512-LIJj795cfggUtLHIM84lseE7LC0kAs/HNVXoDFPTjtYzQikPX9XAIMI1BTJcod3j+U1ZXsayk9N4M3M890WD3w==",
|
"integrity": "sha512-uskCIp+fpohqVYtM2Q28rbXLqGjZ6sWYylXcX6N+K8jR8kR2eHuDMIkO8DzWrTsqA6t4UNAzn+bJnA3VfIIjQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -15190,9 +15190,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimist": {
|
"node_modules/minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
||||||
},
|
},
|
||||||
"node_modules/mixin-deep": {
|
"node_modules/mixin-deep": {
|
||||||
"version": "1.3.2",
|
"version": "1.3.2",
|
||||||
@ -16484,9 +16484,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/plist": {
|
"node_modules/plist": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
||||||
"integrity": "sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg==",
|
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
@ -28515,9 +28515,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "14.0.2",
|
"version": "14.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-14.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-14.2.4.tgz",
|
||||||
"integrity": "sha512-LIJj795cfggUtLHIM84lseE7LC0kAs/HNVXoDFPTjtYzQikPX9XAIMI1BTJcod3j+U1ZXsayk9N4M3M890WD3w==",
|
"integrity": "sha512-uskCIp+fpohqVYtM2Q28rbXLqGjZ6sWYylXcX6N+K8jR8kR2eHuDMIkO8DzWrTsqA6t4UNAzn+bJnA3VfIIjQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^1.0.1",
|
"@electron/get": "^1.0.1",
|
||||||
@ -34244,9 +34244,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
||||||
},
|
},
|
||||||
"mixin-deep": {
|
"mixin-deep": {
|
||||||
"version": "1.3.2",
|
"version": "1.3.2",
|
||||||
@ -35264,9 +35264,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plist": {
|
"plist": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/plist/-/plist-3.0.5.tgz",
|
||||||
"integrity": "sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg==",
|
"integrity": "sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
"babel-jest": "^27.0.6",
|
"babel-jest": "^27.0.6",
|
||||||
"babel-loader": "^8.0.5",
|
"babel-loader": "^8.0.5",
|
||||||
"cypress": "^8.3.1",
|
"cypress": "^8.3.1",
|
||||||
"electron": "^14.0.2",
|
"electron": "^14.2.4",
|
||||||
"electron-packager": "^15.4.0",
|
"electron-packager": "^15.4.0",
|
||||||
"eslint": "^7.24.0",
|
"eslint": "^7.24.0",
|
||||||
"file-loader": "^6.2.0",
|
"file-loader": "^6.2.0",
|
||||||
|
@ -3,7 +3,7 @@ import React from "react";
|
|||||||
import { Box, Typography } from "@mui/material";
|
import { Box, Typography } from "@mui/material";
|
||||||
|
|
||||||
import { Achievement } from "./Achievements";
|
import { Achievement } from "./Achievements";
|
||||||
import { Settings } from "../Settings/Settings"
|
import { Settings } from "../Settings/Settings";
|
||||||
import { AchievementIcon } from "./AchievementIcon";
|
import { AchievementIcon } from "./AchievementIcon";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -13,43 +13,58 @@ interface IProps {
|
|||||||
cssFiltersLocked: string;
|
cssFiltersLocked: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AchievementEntry({ achievement, unlockedOn, cssFiltersUnlocked, cssFiltersLocked }: IProps): JSX.Element {
|
export function AchievementEntry({
|
||||||
|
achievement,
|
||||||
|
unlockedOn,
|
||||||
|
cssFiltersUnlocked,
|
||||||
|
cssFiltersLocked,
|
||||||
|
}: IProps): JSX.Element {
|
||||||
if (!achievement) return <></>;
|
if (!achievement) return <></>;
|
||||||
const isUnlocked = !!unlockedOn;
|
const isUnlocked = !!unlockedOn;
|
||||||
|
|
||||||
const mainColor = isUnlocked ? Settings.theme.primary : Settings.theme.secondarylight;
|
const mainColor = isUnlocked ? Settings.theme.primary : Settings.theme.secondarylight;
|
||||||
|
|
||||||
let achievedOn = '';
|
let achievedOn = "";
|
||||||
if (unlockedOn) {
|
if (unlockedOn) {
|
||||||
achievedOn = new Date(unlockedOn).toLocaleString();
|
achievedOn = new Date(unlockedOn).toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box
|
||||||
border: `1px solid ${Settings.theme.well}`, mb: 2
|
sx={{
|
||||||
}}>
|
border: `1px solid ${Settings.theme.well}`,
|
||||||
<Box sx={{
|
mb: 2,
|
||||||
display: 'flex',
|
}}
|
||||||
flexDirection: 'row',
|
>
|
||||||
flexWrap: 'wrap',
|
<Box
|
||||||
}}>
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AchievementIcon
|
<AchievementIcon
|
||||||
achievement={achievement} unlocked={isUnlocked} size="72px"
|
achievement={achievement}
|
||||||
colorFilters={isUnlocked ? cssFiltersUnlocked: cssFiltersLocked} />
|
unlocked={isUnlocked}
|
||||||
<Box sx={{
|
size="72px"
|
||||||
display: 'flex',
|
colorFilters={isUnlocked ? cssFiltersUnlocked : cssFiltersLocked}
|
||||||
flexDirection: 'column',
|
/>
|
||||||
justifyContent: 'center',
|
<Box
|
||||||
px: 1
|
sx={{
|
||||||
}}>
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "center",
|
||||||
|
px: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Typography variant="h6" sx={{ color: mainColor }}>
|
<Typography variant="h6" sx={{ color: mainColor }}>
|
||||||
{achievement.Name}
|
{achievement.Name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body2" sx={{ maxWidth: '500px', color: mainColor}}>
|
<Typography variant="body2" sx={{ maxWidth: "500px", color: mainColor }}>
|
||||||
{achievement.Description}
|
{achievement.Description}
|
||||||
</Typography>
|
</Typography>
|
||||||
{isUnlocked && (
|
{isUnlocked && (
|
||||||
<Typography variant="caption" sx={{ fontSize: '12px', color: Settings.theme.primarydark }}>
|
<Typography variant="caption" sx={{ fontSize: "12px", color: Settings.theme.primarydark }}>
|
||||||
Acquired on {achievedOn}
|
Acquired on {achievedOn}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
@ -3,7 +3,7 @@ import React, { useState } from "react";
|
|||||||
import { Box } from "@mui/material";
|
import { Box } from "@mui/material";
|
||||||
|
|
||||||
import { Achievement } from "./Achievements";
|
import { Achievement } from "./Achievements";
|
||||||
import { Settings } from "../Settings/Settings"
|
import { Settings } from "../Settings/Settings";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
achievement: Achievement;
|
achievement: Achievement;
|
||||||
@ -16,20 +16,23 @@ export function AchievementIcon({ achievement, unlocked, colorFilters, size }: I
|
|||||||
const [imgLoaded, setImgLoaded] = useState(false);
|
const [imgLoaded, setImgLoaded] = useState(false);
|
||||||
const mainColor = unlocked ? Settings.theme.primarydark : Settings.theme.secondarydark;
|
const mainColor = unlocked ? Settings.theme.primarydark : Settings.theme.secondarydark;
|
||||||
|
|
||||||
if (!achievement.Icon) return (<></>);
|
if (!achievement.Icon) return <></>;
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
border: `1px solid ${mainColor}`,
|
border: `1px solid ${mainColor}`,
|
||||||
width: size, height: size,
|
width: size,
|
||||||
|
height: size,
|
||||||
m: 1,
|
m: 1,
|
||||||
visibility: imgLoaded ? 'visible' : 'hidden'
|
visibility: imgLoaded ? "visible" : "hidden",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img src={`dist/icons/achievements/${encodeURI(achievement.Icon)}.svg`}
|
<img
|
||||||
|
src={`dist/icons/achievements/${encodeURI(achievement.Icon)}.svg`}
|
||||||
style={{ filter: colorFilters, width: size, height: size }}
|
style={{ filter: colorFilters, width: size, height: size }}
|
||||||
onLoad={() => setImgLoaded(true)}
|
onLoad={() => setImgLoaded(true)}
|
||||||
alt={achievement.Name} />
|
alt={achievement.Name}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Accordion, AccordionSummary, AccordionDetails, Box, Typography } from "
|
|||||||
|
|
||||||
import { AchievementEntry } from "./AchievementEntry";
|
import { AchievementEntry } from "./AchievementEntry";
|
||||||
import { Achievement, PlayerAchievement } from "./Achievements";
|
import { Achievement, PlayerAchievement } from "./Achievements";
|
||||||
import { Settings } from "../Settings/Settings"
|
import { Settings } from "../Settings/Settings";
|
||||||
import { getFiltersFromHex } from "../ThirdParty/colorUtils";
|
import { getFiltersFromHex } from "../ThirdParty/colorUtils";
|
||||||
import { CorruptableText } from "../ui/React/CorruptableText";
|
import { CorruptableText } from "../ui/React/CorruptableText";
|
||||||
|
|
||||||
@ -18,32 +18,39 @@ export function AchievementList({ achievements, playerAchievements }: IProps): J
|
|||||||
const cssPrimary = getFiltersFromHex(Settings.theme.primary);
|
const cssPrimary = getFiltersFromHex(Settings.theme.primary);
|
||||||
const cssSecondary = getFiltersFromHex(Settings.theme.secondary);
|
const cssSecondary = getFiltersFromHex(Settings.theme.secondary);
|
||||||
|
|
||||||
const data = achievements.map(achievement => ({
|
const data = achievements
|
||||||
|
.map((achievement) => ({
|
||||||
achievement,
|
achievement,
|
||||||
unlockedOn: playerAchievements.find(playerAchievement => playerAchievement.ID === achievement.ID)?.unlockedOn,
|
unlockedOn: playerAchievements.find((playerAchievement) => playerAchievement.ID === achievement.ID)?.unlockedOn,
|
||||||
})).sort((a, b) => (b.unlockedOn ?? 0) - (a.unlockedOn ?? 0));
|
}))
|
||||||
|
.sort((a, b) => (b.unlockedOn ?? 0) - (a.unlockedOn ?? 0));
|
||||||
|
|
||||||
const unlocked = data.filter(entry => entry.unlockedOn);
|
const unlocked = data.filter((entry) => entry.unlockedOn);
|
||||||
|
|
||||||
// Hidden achievements
|
// Hidden achievements
|
||||||
const secret = data.filter(entry => !entry.unlockedOn && entry.achievement.Secret)
|
const secret = data.filter((entry) => !entry.unlockedOn && entry.achievement.Secret);
|
||||||
|
|
||||||
// Locked behind locked content (bitnode x)
|
// Locked behind locked content (bitnode x)
|
||||||
const unavailable = data.filter(entry => !entry.unlockedOn && !entry.achievement.Secret && entry.achievement.Visible && !entry.achievement.Visible());
|
const unavailable = data.filter(
|
||||||
|
(entry) =>
|
||||||
|
!entry.unlockedOn && !entry.achievement.Secret && entry.achievement.Visible && !entry.achievement.Visible(),
|
||||||
|
);
|
||||||
|
|
||||||
// Remaining achievements
|
// Remaining achievements
|
||||||
const locked = data
|
const locked = data
|
||||||
.filter(entry => !unlocked.map(u => u.achievement.ID).includes(entry.achievement.ID))
|
.filter((entry) => !unlocked.map((u) => u.achievement.ID).includes(entry.achievement.ID))
|
||||||
.filter(entry => !secret.map(u => u.achievement.ID).includes(entry.achievement.ID))
|
.filter((entry) => !secret.map((u) => u.achievement.ID).includes(entry.achievement.ID))
|
||||||
.filter(entry => !unavailable.map(u => u.achievement.ID).includes(entry.achievement.ID));
|
.filter((entry) => !unavailable.map((u) => u.achievement.ID).includes(entry.achievement.ID));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ pr: 18, my: 2 }}>
|
<Box sx={{ pr: 18, my: 2 }}>
|
||||||
<Box sx={{
|
<Box
|
||||||
display: 'flex',
|
sx={{
|
||||||
flexDirection: 'column',
|
display: "flex",
|
||||||
flexWrap: 'wrap',
|
flexDirection: "column",
|
||||||
}}>
|
flexWrap: "wrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{unlocked.length > 0 && (
|
{unlocked.length > 0 && (
|
||||||
<Accordion defaultExpanded disableGutters square>
|
<Accordion defaultExpanded disableGutters square>
|
||||||
<AccordionSummary>
|
<AccordionSummary>
|
||||||
@ -52,12 +59,14 @@ export function AchievementList({ achievements, playerAchievements }: IProps): J
|
|||||||
</Typography>
|
</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ pt: 2 }}>
|
<AccordionDetails sx={{ pt: 2 }}>
|
||||||
{unlocked.map(item => (
|
{unlocked.map((item) => (
|
||||||
<AchievementEntry key={`unlocked_${item.achievement.ID}`}
|
<AchievementEntry
|
||||||
|
key={`unlocked_${item.achievement.ID}`}
|
||||||
achievement={item.achievement}
|
achievement={item.achievement}
|
||||||
unlockedOn={item.unlockedOn}
|
unlockedOn={item.unlockedOn}
|
||||||
cssFiltersUnlocked={cssPrimary}
|
cssFiltersUnlocked={cssPrimary}
|
||||||
cssFiltersLocked={cssSecondary} />
|
cssFiltersLocked={cssSecondary}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@ -71,11 +80,13 @@ export function AchievementList({ achievements, playerAchievements }: IProps): J
|
|||||||
</Typography>
|
</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails sx={{ pt: 2 }}>
|
<AccordionDetails sx={{ pt: 2 }}>
|
||||||
{locked.map(item => (
|
{locked.map((item) => (
|
||||||
<AchievementEntry key={`locked_${item.achievement.ID}`}
|
<AchievementEntry
|
||||||
|
key={`locked_${item.achievement.ID}`}
|
||||||
achievement={item.achievement}
|
achievement={item.achievement}
|
||||||
cssFiltersUnlocked={cssPrimary}
|
cssFiltersUnlocked={cssPrimary}
|
||||||
cssFiltersLocked={cssSecondary} />
|
cssFiltersLocked={cssSecondary}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@ -105,7 +116,7 @@ export function AchievementList({ achievements, playerAchievements }: IProps): J
|
|||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails>
|
<AccordionDetails>
|
||||||
<Typography color="secondary" sx={{ mt: 1 }}>
|
<Typography color="secondary" sx={{ mt: 1 }}>
|
||||||
{secret.map(item => (
|
{secret.map((item) => (
|
||||||
<span key={`secret_${item.achievement.ID}`}>
|
<span key={`secret_${item.achievement.ID}`}>
|
||||||
<CorruptableText content={item.achievement.ID}></CorruptableText>
|
<CorruptableText content={item.achievement.ID}></CorruptableText>
|
||||||
<br />
|
<br />
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# Adding Achievements
|
# Adding Achievements
|
||||||
|
|
||||||
* Add a .svg in `./assets/Steam/achievements/real`
|
- Add a .svg in `./assets/Steam/achievements/real`
|
||||||
* Create the achievement in Steam Dev Portal
|
- Create the achievement in Steam Dev Portal
|
||||||
* Run `sh ./assets/Steam/achievements/pack-for-web.sh`
|
- Run `sh ./assets/Steam/achievements/pack-for-web.sh`
|
||||||
* Run `node ./tools/fetch-steam-achievements-data DEVKEYHERE`
|
- Run `node ./tools/fetch-steam-achievements-data DEVKEYHERE`
|
||||||
* Get your key here: https://steamcommunity.com/dev/apikey
|
- Get your key here: https://steamcommunity.com/dev/apikey
|
||||||
* Add an entry in `./src/Achievements/Achievements.ts` -> achievements
|
- Add an entry in `./src/Achievements/Achievements.ts` -> achievements
|
||||||
* Commit `./dist/icons/achievements` & `./src/Achievements/AchievementData.json`
|
- Commit `./dist/icons/achievements` & `./src/Achievements/AchievementData.json`
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { IMap } from "../types";
|
import { IMap } from "../types";
|
||||||
|
|
||||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
|
||||||
import { Faction } from "../Faction/Faction";
|
import { Faction } from "../Faction/Faction";
|
||||||
import { Factions } from "../Faction/Factions";
|
import { Factions } from "../Faction/Factions";
|
||||||
import { numeralWrapper } from "../ui/numeralFormat";
|
import { numeralWrapper } from "../ui/numeralFormat";
|
||||||
@ -410,8 +409,8 @@ export class Augmentation {
|
|||||||
this.info = params.info;
|
this.info = params.info;
|
||||||
this.prereqs = params.prereqs ? params.prereqs : [];
|
this.prereqs = params.prereqs ? params.prereqs : [];
|
||||||
|
|
||||||
this.baseRepRequirement = params.repCost * BitNodeMultipliers.AugmentationRepCost;
|
this.baseRepRequirement = params.repCost;
|
||||||
this.baseCost = params.moneyCost * BitNodeMultipliers.AugmentationMoneyCost;
|
this.baseCost = params.moneyCost;
|
||||||
this.startingCost = this.baseCost;
|
this.startingCost = this.baseCost;
|
||||||
this.factions = params.factions;
|
this.factions = params.factions;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ function getRandomBonus(): any {
|
|||||||
return bonuses[Math.floor(bonuses.length * randomNumber.random())];
|
return bonuses[Math.floor(bonuses.length * randomNumber.random())];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generalAugmentations = [
|
export const initGeneralAugmentations = (): Augmentation[] => [
|
||||||
new Augmentation({
|
new Augmentation({
|
||||||
name: AugmentationNames.HemoRecirculator,
|
name: AugmentationNames.HemoRecirculator,
|
||||||
moneyCost: 4.5e7,
|
moneyCost: 4.5e7,
|
||||||
@ -1484,9 +1484,22 @@ export const generalAugmentations = [
|
|||||||
),
|
),
|
||||||
factions: [FactionNames.TianDiHui],
|
factions: [FactionNames.TianDiHui],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Grafting-exclusive Augmentation
|
||||||
|
new Augmentation({
|
||||||
|
name: AugmentationNames.CongruityImplant,
|
||||||
|
repCost: 0,
|
||||||
|
moneyCost: 50e12,
|
||||||
|
info:
|
||||||
|
"Developed by a pioneer in Grafting research, this implant " +
|
||||||
|
"generates pulses of stability which seem to have a nullifying " +
|
||||||
|
"effect versus the Entropy virus.",
|
||||||
|
stats: <>This Augmentation removes the Entropy virus, and prevents it from affecting you again.</>,
|
||||||
|
factions: [],
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export const bladeburnerAugmentations = [
|
export const initBladeburnerAugmentations = (): Augmentation[] => [
|
||||||
new Augmentation({
|
new Augmentation({
|
||||||
name: AugmentationNames.EsperEyewear,
|
name: AugmentationNames.EsperEyewear,
|
||||||
repCost: 1.25e3,
|
repCost: 1.25e3,
|
||||||
@ -1751,7 +1764,7 @@ export const bladeburnerAugmentations = [
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export const churchOfTheMachineGodAugmentations = [
|
export const initChurchOfTheMachineGodAugmentations = (): Augmentation[] => [
|
||||||
new Augmentation({
|
new Augmentation({
|
||||||
name: AugmentationNames.StaneksGift1,
|
name: AugmentationNames.StaneksGift1,
|
||||||
repCost: 0,
|
repCost: 0,
|
||||||
|
@ -15,9 +15,9 @@ import { clearObject } from "../utils/helpers/clearObject";
|
|||||||
|
|
||||||
import { FactionNames } from "../Faction/data/FactionNames";
|
import { FactionNames } from "../Faction/data/FactionNames";
|
||||||
import {
|
import {
|
||||||
bladeburnerAugmentations,
|
initBladeburnerAugmentations,
|
||||||
churchOfTheMachineGodAugmentations,
|
initChurchOfTheMachineGodAugmentations,
|
||||||
generalAugmentations,
|
initGeneralAugmentations,
|
||||||
initNeuroFluxGovernor,
|
initNeuroFluxGovernor,
|
||||||
initUnstableCircadianModulator,
|
initUnstableCircadianModulator,
|
||||||
} from "./AugmentationCreator";
|
} from "./AugmentationCreator";
|
||||||
@ -49,9 +49,9 @@ function createAugmentations(): void {
|
|||||||
[
|
[
|
||||||
initNeuroFluxGovernor(),
|
initNeuroFluxGovernor(),
|
||||||
initUnstableCircadianModulator(),
|
initUnstableCircadianModulator(),
|
||||||
...generalAugmentations,
|
...initGeneralAugmentations(),
|
||||||
...(factionExists(FactionNames.Bladeburners) ? bladeburnerAugmentations : []),
|
...(factionExists(FactionNames.Bladeburners) ? initBladeburnerAugmentations() : []),
|
||||||
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? churchOfTheMachineGodAugmentations : []),
|
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? initChurchOfTheMachineGodAugmentations() : []),
|
||||||
].map(resetAugmentation);
|
].map(resetAugmentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +141,12 @@ function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special logic for Congruity Implant
|
||||||
|
if (aug.name === AugmentationNames.CongruityImplant && !reapply) {
|
||||||
|
Player.entropy = 0;
|
||||||
|
Player.applyEntropy(Player.entropy);
|
||||||
|
}
|
||||||
|
|
||||||
// Push onto Player's Augmentation list
|
// Push onto Player's Augmentation list
|
||||||
if (!reapply) {
|
if (!reapply) {
|
||||||
const ownedAug = new PlayerOwnedAugmentation(aug.name);
|
const ownedAug = new PlayerOwnedAugmentation(aug.name);
|
||||||
@ -148,8 +154,8 @@ function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function installAugmentations(): boolean {
|
function installAugmentations(force?: boolean): boolean {
|
||||||
if (Player.queuedAugmentations.length == 0) {
|
if (Player.queuedAugmentations.length == 0 && !force) {
|
||||||
dialogBoxCreate("You have not purchased any Augmentations to install!");
|
dialogBoxCreate("You have not purchased any Augmentations to install!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -179,12 +185,14 @@ function installAugmentations(): boolean {
|
|||||||
augmentationList += aug.name + level + "<br>";
|
augmentationList += aug.name + level + "<br>";
|
||||||
}
|
}
|
||||||
Player.queuedAugmentations = [];
|
Player.queuedAugmentations = [];
|
||||||
|
if (!force) {
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"You slowly drift to sleep as scientists put you under in order " +
|
"You slowly drift to sleep as scientists put you under in order " +
|
||||||
"to install the following Augmentations:<br>" +
|
"to install the following Augmentations:<br>" +
|
||||||
augmentationList +
|
augmentationList +
|
||||||
"<br>You wake up in your home...you feel different...",
|
"<br>You wake up in your home...you feel different...",
|
||||||
);
|
);
|
||||||
|
}
|
||||||
prestigeAugmentation();
|
prestigeAugmentation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ export enum AugmentationNames {
|
|||||||
BionicArms = "Bionic Arms",
|
BionicArms = "Bionic Arms",
|
||||||
SNA = "Social Negotiation Assistant (S.N.A)",
|
SNA = "Social Negotiation Assistant (S.N.A)",
|
||||||
HydroflameLeftArm = "Hydroflame Left Arm",
|
HydroflameLeftArm = "Hydroflame Left Arm",
|
||||||
|
CongruityImplant = "nickofolas Congruity Implant",
|
||||||
EsperEyewear = "EsperTech Bladeburner Eyewear",
|
EsperEyewear = "EsperTech Bladeburner Eyewear",
|
||||||
EMS4Recombination = "EMS-4 Recombination",
|
EMS4Recombination = "EMS-4 Recombination",
|
||||||
OrionShoulder = "ORION-MKIV Shoulder",
|
OrionShoulder = "ORION-MKIV Shoulder",
|
||||||
|
@ -135,9 +135,7 @@ export class Action implements IAction {
|
|||||||
for (const decay of Object.keys(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(`Invalid decays when constructing Action ${this.name}. Decay value cannot be greater than 1`);
|
||||||
`Invalid decays when constructing Action ${this.name}. Decay value cannot be greater than 1`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ const actionNames : Array<string> = [
|
|||||||
"Recruitment",
|
"Recruitment",
|
||||||
"Diplomacy",
|
"Diplomacy",
|
||||||
"Hyperbolic Regeneration Chamber",
|
"Hyperbolic Regeneration Chamber",
|
||||||
"Incite Violence"
|
"Incite Violence",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const actionName of actionNames) {
|
for (const actionName of actionNames) {
|
||||||
|
@ -7,8 +7,7 @@ export const Skills: IMap<Skill> = {};
|
|||||||
(function () {
|
(function () {
|
||||||
Skills[SkillNames.BladesIntuition] = new Skill({
|
Skills[SkillNames.BladesIntuition] = new Skill({
|
||||||
name: SkillNames.BladesIntuition,
|
name: SkillNames.BladesIntuition,
|
||||||
desc:
|
desc: "Each level of this skill increases your success chance for all Contracts, Operations, and BlackOps by 3%",
|
||||||
"Each level of this skill increases your success chance for all Contracts, Operations, and BlackOps by 3%",
|
|
||||||
baseCost: 3,
|
baseCost: 3,
|
||||||
costInc: 2.1,
|
costInc: 2.1,
|
||||||
successChanceAll: 3,
|
successChanceAll: 3,
|
||||||
|
@ -17,8 +17,8 @@ export const BlackOperations: {
|
|||||||
Zenyatta, along with the rest of the PMC, is a Synthoid.
|
Zenyatta, along with the rest of the PMC, is a Synthoid.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The goal of {BlackOperationNames.OperationTyphoon} is to find and eliminate Zenyatta and RedWater by any means necessary. After the
|
The goal of {BlackOperationNames.OperationTyphoon} is to find and eliminate Zenyatta and RedWater by any means
|
||||||
task is completed, the actions must be covered up from the general public.
|
necessary. After the task is completed, the actions must be covered up from the general public.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -30,10 +30,10 @@ export const BlackOperations: {
|
|||||||
supporter of Synthoid rights. He must be removed.
|
supporter of Synthoid rights. He must be removed.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The goal of {BlackOperationNames.OperationZero} is to covertly infiltrate AeroCorp and uncover any incriminating evidence or
|
The goal of {BlackOperationNames.OperationZero} is to covertly infiltrate AeroCorp and uncover any incriminating
|
||||||
information against Watataki that will cause him to be removed from his position at AeroCorp. Incriminating
|
evidence or information against Watataki that will cause him to be removed from his position at AeroCorp.
|
||||||
evidence can be fabricated as a last resort. Be warned that AeroCorp has some of the most advanced security
|
Incriminating evidence can be fabricated as a last resort. Be warned that AeroCorp has some of the most advanced
|
||||||
measures in the world.
|
security measures in the world.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -47,8 +47,8 @@ export const BlackOperations: {
|
|||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Samizdat has done a good job of keeping hidden and anonymous. However, we've just received intelligence that
|
Samizdat has done a good job of keeping hidden and anonymous. However, we've just received intelligence that
|
||||||
their base of operations is in {CityName.Ishima}'s underground sewer systems. Your task is to investigate the sewer
|
their base of operations is in {CityName.Ishima}'s underground sewer systems. Your task is to investigate the
|
||||||
systems, and eliminate Samizdat. They must never publish anything again.
|
sewer systems, and eliminate Samizdat. They must never publish anything again.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -61,9 +61,9 @@ export const BlackOperations: {
|
|||||||
dangerous.
|
dangerous.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Your goal is to enter and destroy the Bioengineering department's facility in {CityName.Aevum}. The task is not just to
|
Your goal is to enter and destroy the Bioengineering department's facility in {CityName.Aevum}. The task is not
|
||||||
retire the Synthoids there, but also to destroy any information or research at the facility that is relevant to
|
just to retire the Synthoids there, but also to destroy any information or research at the facility that is
|
||||||
the Synthoids and their goals.
|
relevant to the Synthoids and their goals.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -96,10 +96,10 @@ export const BlackOperations: {
|
|||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
The CIA has just encountered a new security threat. A new criminal group, lead by a shadowy operative who calls
|
The CIA has just encountered a new security threat. A new criminal group, lead by a shadowy operative who calls
|
||||||
himself Juggernaut, has been smuggling drugs and weapons (including suspected bioweapons) into {CityName.Sector12}. We
|
himself Juggernaut, has been smuggling drugs and weapons (including suspected bioweapons) into{" "}
|
||||||
also have reason to believe they tried to break into one of Universal Energy's facilities in order to cause a
|
{CityName.Sector12}. We also have reason to believe they tried to break into one of Universal Energy's
|
||||||
city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented Synthoid, and have thus enlisted our
|
facilities in order to cause a city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented
|
||||||
help.
|
Synthoid, and have thus enlisted our help.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Your mission is to eradicate Juggernaut and his followers.
|
Your mission is to eradicate Juggernaut and his followers.
|
||||||
@ -109,13 +109,13 @@ export const BlackOperations: {
|
|||||||
[BlackOperationNames.OperationRedDragon]: {
|
[BlackOperationNames.OperationRedDragon]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
The {FactionNames.Tetrads} criminal organization is suspected of reverse-engineering the MK-VI Synthoid design. We believe they
|
The {FactionNames.Tetrads} criminal organization is suspected of reverse-engineering the MK-VI Synthoid design.
|
||||||
altered and possibly improved the design and began manufacturing their own Synthoid models in order to bolster
|
We believe they altered and possibly improved the design and began manufacturing their own Synthoid models in
|
||||||
their criminal activities.
|
order to bolster their criminal activities.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Your task is to infiltrate and destroy the {FactionNames.Tetrads}' base of operations in Los Angeles. Intelligence tells us
|
Your task is to infiltrate and destroy the {FactionNames.Tetrads}' base of operations in Los Angeles.
|
||||||
that their base houses one of their Synthoid manufacturing units.
|
Intelligence tells us that their base houses one of their Synthoid manufacturing units.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -138,23 +138,24 @@ export const BlackOperations: {
|
|||||||
[BlackOperationNames.OperationDeckard]: {
|
[BlackOperationNames.OperationDeckard]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
Despite your success in eliminating VitaLife's new android-replicating technology in {BlackOperationNames.OperationK}, we've
|
Despite your success in eliminating VitaLife's new android-replicating technology in{" "}
|
||||||
discovered that a small group of MK-VI Synthoids were able to make off with the schematics and design of the
|
{BlackOperationNames.OperationK}, we've discovered that a small group of MK-VI Synthoids were able to make off
|
||||||
technology before the Operation. It is almost a certainty that these Synthoids are some of the rogue MK-VI ones
|
with the schematics and design of the technology before the Operation. It is almost a certainty that these
|
||||||
from the Synthoid Uprising.
|
Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The goal of {BlackOperationNames.OperationDeckard} is to hunt down these Synthoids and retire them. I don't need to tell you how
|
The goal of {BlackOperationNames.OperationDeckard} is to hunt down these Synthoids and retire them. I don't need
|
||||||
critical this mission is.
|
to tell you how critical this mission is.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
[BlackOperationNames.OperationTyrell]: {
|
[BlackOperationNames.OperationTyrell]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
A week ago {FactionNames.BladeIndustries} reported a small break-in at one of their {CityName.Aevum} Augmentation storage facilities. We
|
A week ago {FactionNames.BladeIndustries} reported a small break-in at one of their {CityName.Aevum}{" "}
|
||||||
figured out that {FactionNames.TheDarkArmy} was behind the heist, and didn't think any more of it. However, we've just
|
Augmentation storage facilities. We figured out that {FactionNames.TheDarkArmy} was behind the heist, and didn't
|
||||||
discovered that several known MK-VI Synthoids were part of that break-in group.
|
think any more of it. However, we've just discovered that several known MK-VI Synthoids were part of that
|
||||||
|
break-in group.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
We cannot have Synthoids upgrading their already-enhanced abilities with Augmentations. Your task is to hunt
|
We cannot have Synthoids upgrading their already-enhanced abilities with Augmentations. Your task is to hunt
|
||||||
@ -165,15 +166,17 @@ export const BlackOperations: {
|
|||||||
[BlackOperationNames.OperationWallace]: {
|
[BlackOperationNames.OperationWallace]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
Based on information gathered from {BlackOperationNames.OperationTyrell}, we've discovered that {FactionNames.TheDarkArmy} was well aware that
|
Based on information gathered from {BlackOperationNames.OperationTyrell}, we've discovered that{" "}
|
||||||
there were Synthoids amongst their ranks. Even worse, we believe that {FactionNames.TheDarkArmy} is working together with
|
{FactionNames.TheDarkArmy} was well aware that there were Synthoids amongst their ranks. Even worse, we believe
|
||||||
other criminal organizations such as {FactionNames.TheSyndicate} and that they are planning some sort of large-scale takeover
|
that {FactionNames.TheDarkArmy} is working together with other criminal organizations such as{" "}
|
||||||
of multiple major cities, most notably {CityName.Aevum}. We suspect that Synthoids have infiltrated the ranks of these
|
{FactionNames.TheSyndicate} and that they are planning some sort of large-scale takeover of multiple major
|
||||||
criminal factions and are trying to stage another Synthoid uprising.
|
cities, most notably {CityName.Aevum}. We suspect that Synthoids have infiltrated the ranks of these criminal
|
||||||
|
factions and are trying to stage another Synthoid uprising.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The best way to deal with this is to prevent it before it even happens. The goal of {BlackOperationNames.OperationWallace} is to
|
The best way to deal with this is to prevent it before it even happens. The goal of{" "}
|
||||||
destroy {FactionNames.TheDarkArmy} and Syndicate factions in {CityName.Aevum} immediately. Leave no survivors.
|
{BlackOperationNames.OperationWallace} is to destroy {FactionNames.TheDarkArmy} and Syndicate factions in{" "}
|
||||||
|
{CityName.Aevum} immediately. Leave no survivors.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -193,18 +196,18 @@ export const BlackOperations: {
|
|||||||
[BlackOperationNames.OperationHyron]: {
|
[BlackOperationNames.OperationHyron]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
Our intelligence tells us that {FactionNames.FulcrumSecretTechnologies} is developing a quantum supercomputer using human brains as
|
Our intelligence tells us that {FactionNames.FulcrumSecretTechnologies} is developing a quantum supercomputer
|
||||||
core processors. This supercomputer is rumored to be able to store vast amounts of data and perform computations
|
using human brains as core processors. This supercomputer is rumored to be able to store vast amounts of data
|
||||||
unmatched by any other supercomputer on the planet. But more importantly, the use of organic human brains means
|
and perform computations unmatched by any other supercomputer on the planet. But more importantly, the use of
|
||||||
that the supercomputer may be able to reason abstractly and become self-aware.
|
organic human brains means that the supercomputer may be able to reason abstractly and become self-aware.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
I do not need to remind you why sentient-level AIs pose a serious threat to all of mankind.
|
I do not need to remind you why sentient-level AIs pose a serious threat to all of mankind.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The research for this project is being conducted at one of {FactionNames.FulcrumSecretTechnologies} secret facilities in {CityName.Aevum},
|
The research for this project is being conducted at one of {FactionNames.FulcrumSecretTechnologies} secret
|
||||||
codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work, and then find and kill the
|
facilities in {CityName.Aevum}, codenamed 'Alpha Ranch'. Infiltrate the compound, delete and destroy the work,
|
||||||
project lead.
|
and then find and kill the project lead.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -213,8 +216,8 @@ export const BlackOperations: {
|
|||||||
<>
|
<>
|
||||||
DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the
|
DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the
|
||||||
people's dreams and subconcious. They do this using broadcast transmitter towers. Based on information from our
|
people's dreams and subconcious. They do this using broadcast transmitter towers. Based on information from our
|
||||||
agents and informants in {CityName.Chongqing}, we have reason to believe that one of the broadcast towers there has been
|
agents and informants in {CityName.Chongqing}, we have reason to believe that one of the broadcast towers there
|
||||||
compromised by Synthoids and is being used to spread pro-Synthoid propaganda.
|
has been compromised by Synthoids and is being used to spread pro-Synthoid propaganda.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
The mission is to destroy this broadcast tower. Speed and stealth are of the utmost importance for this.
|
The mission is to destroy this broadcast tower. Speed and stealth are of the utmost importance for this.
|
||||||
@ -224,36 +227,38 @@ export const BlackOperations: {
|
|||||||
[BlackOperationNames.OperationIonStorm]: {
|
[BlackOperationNames.OperationIonStorm]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
Our analysts have uncovered a gathering of MK-VI Synthoids that have taken up residence in the {CityName.Sector12} Slums.
|
Our analysts have uncovered a gathering of MK-VI Synthoids that have taken up residence in the{" "}
|
||||||
We don't know if they are rogue Synthoids from the Uprising, but we do know that they have been stockpiling
|
{CityName.Sector12} Slums. We don't know if they are rogue Synthoids from the Uprising, but we do know that they
|
||||||
weapons, money, and other resources. This makes them dangerous.
|
have been stockpiling weapons, money, and other resources. This makes them dangerous.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
This is a full-scale assault operation to find and retire all of these Synthoids in the {CityName.Sector12} Slums.
|
This is a full-scale assault operation to find and retire all of these Synthoids in the {CityName.Sector12}{" "}
|
||||||
|
Slums.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
[BlackOperationNames.OperationAnnihilus]: {
|
[BlackOperationNames.OperationAnnihilus]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
Our superiors have ordered us to eradicate everything and everyone in an underground facility located in {CityName.Aevum}.
|
Our superiors have ordered us to eradicate everything and everyone in an underground facility located in{" "}
|
||||||
They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist organization called
|
{CityName.Aevum}. They tell us that the facility houses many dangerous Synthoids and belongs to a terrorist
|
||||||
'{FactionNames.TheCovenant}'. We have no prior intelligence about this organization, so you are going in blind.
|
organization called '{FactionNames.TheCovenant}'. We have no prior intelligence about this organization, so you
|
||||||
|
are going in blind.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
[BlackOperationNames.OperationUltron]: {
|
[BlackOperationNames.OperationUltron]: {
|
||||||
desc: (
|
desc: (
|
||||||
<>
|
<>
|
||||||
{FactionNames.OmniTekIncorporated}, the original designer and manufacturer of Synthoids, has notified us of a malfunction in
|
{FactionNames.OmniTekIncorporated}, the original designer and manufacturer of Synthoids, has notified us of a
|
||||||
their AI design. This malfunction, when triggered, causes MK-VI Synthoids to become radicalized and seek out the
|
malfunction in their AI design. This malfunction, when triggered, causes MK-VI Synthoids to become radicalized
|
||||||
destruction of humanity. They say that this bug affects all MK-VI Synthoids, not just the rogue ones from the
|
and seek out the destruction of humanity. They say that this bug affects all MK-VI Synthoids, not just the rogue
|
||||||
Uprising.
|
ones from the Uprising.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
{FactionNames.OmniTekIncorporated} has also told us they they believe someone has triggered this malfunction in a large group of MK-VI
|
{FactionNames.OmniTekIncorporated} has also told us they they believe someone has triggered this malfunction in
|
||||||
Synthoids, and that these newly-radicalized Synthoids are now amassing in {CityName.Volhaven} to form a terrorist group
|
a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids are now amassing in{" "}
|
||||||
called Ultron.
|
{CityName.Volhaven} to form a terrorist group called Ultron.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Intelligence suggests Ultron is heavily armed and that their members are augmented. We believe Ultron is making
|
Intelligence suggests Ultron is heavily armed and that their members are augmented. We believe Ultron is making
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { CityName } from './../../Locations/data/CityNames';
|
import { CityName } from "./../../Locations/data/CityNames";
|
||||||
export const BladeburnerConstants: {
|
export const BladeburnerConstants: {
|
||||||
CityNames: string[];
|
CityNames: string[];
|
||||||
CyclesPerSecond: number;
|
CyclesPerSecond: number;
|
||||||
@ -28,7 +28,14 @@ export const BladeburnerConstants: {
|
|||||||
HrcHpGain: number;
|
HrcHpGain: number;
|
||||||
HrcStaminaGain: number;
|
HrcStaminaGain: number;
|
||||||
} = {
|
} = {
|
||||||
CityNames: [CityName.Aevum, CityName.Chongqing, CityName.Sector12, CityName.NewTokyo, CityName.Ishima, CityName.Volhaven],
|
CityNames: [
|
||||||
|
CityName.Aevum,
|
||||||
|
CityName.Chongqing,
|
||||||
|
CityName.Sector12,
|
||||||
|
CityName.NewTokyo,
|
||||||
|
CityName.Ishima,
|
||||||
|
CityName.Volhaven,
|
||||||
|
],
|
||||||
CyclesPerSecond: 5, // Game cycle is 200 ms
|
CyclesPerSecond: 5, // Game cycle is 200 ms
|
||||||
|
|
||||||
StaminaGainPerSecond: 0.0085,
|
StaminaGainPerSecond: 0.0085,
|
||||||
|
@ -18,7 +18,10 @@ export function BlackOpPage(props: IProps): React.ReactElement {
|
|||||||
successively by completing the one before it.
|
successively by completing the one before it.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<b>Your ultimate goal to climb through the ranks of {FactionNames.Bladeburners} is to complete all of the Black Ops.</b>
|
<b>
|
||||||
|
Your ultimate goal to climb through the ranks of {FactionNames.Bladeburners} is to complete all of the Black
|
||||||
|
Ops.
|
||||||
|
</b>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Like normal operations, you may use a team for Black Ops. Failing a black op will incur heavy HP and rank
|
Like normal operations, you may use a team for Black Ops. Failing a black op will incur heavy HP and rank
|
||||||
|
@ -44,13 +44,15 @@ export function Stats(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper sx={{ p: 1, overflowY: 'auto', overflowX: 'hidden', wordBreak: 'break-all' }}>
|
<Paper sx={{ p: 1, overflowY: "auto", overflowX: "hidden", wordBreak: "break-all" }}>
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1, maxHeight: '60vh' }}>
|
<Box sx={{ display: "flex", flexDirection: "column", gap: 1, maxHeight: "60vh" }}>
|
||||||
<Box sx={{ alignSelf: 'flex-start', width: '100%' }}>
|
<Box sx={{ alignSelf: "flex-start", width: "100%" }}>
|
||||||
<Button onClick={() => setTravelOpen(true)} sx={{ width: '50%' }}>Travel</Button>
|
<Button onClick={() => setTravelOpen(true)} sx={{ width: "50%" }}>
|
||||||
|
Travel
|
||||||
|
</Button>
|
||||||
<Tooltip title={!inFaction ? <Typography>Rank 25 required.</Typography> : ""}>
|
<Tooltip title={!inFaction ? <Typography>Rank 25 required.</Typography> : ""}>
|
||||||
<span>
|
<span>
|
||||||
<Button disabled={!inFaction} onClick={openFaction} sx={{ width: '50%' }}>
|
<Button disabled={!inFaction} onClick={openFaction} sx={{ width: "50%" }}>
|
||||||
Faction
|
Faction
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
@ -110,8 +112,8 @@ export function Stats(props: IProps): React.ReactElement {
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<Typography>
|
<Typography>
|
||||||
This is your Bladeburner division's estimate of how many Synthoids exist in your current city. An accurate
|
This is your Bladeburner division's estimate of how many Synthoids exist in your current city. An
|
||||||
population count increases success rate estimates.
|
accurate population count increases success rate estimates.
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -159,7 +159,7 @@ export function SlotMachine(props: IProps): React.ReactElement {
|
|||||||
const copy = index.slice();
|
const copy = index.slice();
|
||||||
for (let i = 0; i < copy.length; i++) {
|
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 >= 0) ? copy[i] - 1 : symbols.length - 1;
|
copy[i] = copy[i] - 1 >= 0 ? copy[i] - 1 : symbols.length - 1;
|
||||||
stoppedOne = true;
|
stoppedOne = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import { Employee } from "./Employee";
|
|||||||
import { IndustryUpgrades } from "./IndustryUpgrades";
|
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||||
import { ResearchMap } from "./ResearchMap";
|
import { ResearchMap } from "./ResearchMap";
|
||||||
import { isRelevantMaterial } from "./ui/Helpers";
|
import { isRelevantMaterial } from "./ui/Helpers";
|
||||||
import { CityName } from "src/Locations/data/CityNames";
|
|
||||||
|
|
||||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||||
if (corporation.divisions.find(({ type }) => industry == type))
|
if (corporation.divisions.find(({ type }) => industry == type))
|
||||||
|
@ -435,10 +435,10 @@ export class Industry implements IIndustry {
|
|||||||
const popularityGain = corporation.getDreamSenseGain(),
|
const popularityGain = corporation.getDreamSenseGain(),
|
||||||
awarenessGain = popularityGain * 4;
|
awarenessGain = popularityGain * 4;
|
||||||
if (popularityGain > 0) {
|
if (popularityGain > 0) {
|
||||||
const awareness = this.awareness + (awarenessGain * marketCycles);
|
const awareness = this.awareness + awarenessGain * marketCycles;
|
||||||
this.awareness = Math.min(awareness, Number.MAX_VALUE);
|
this.awareness = Math.min(awareness, Number.MAX_VALUE);
|
||||||
|
|
||||||
const popularity = this.popularity + (popularityGain * marketCycles);
|
const popularity = this.popularity + popularityGain * marketCycles;
|
||||||
this.popularity = Math.min(popularity, Number.MAX_VALUE);
|
this.popularity = Math.min(popularity, Number.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1188,8 @@ export class Industry implements IIndustry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
product.maxsll = 0.5 *
|
product.maxsll =
|
||||||
|
0.5 *
|
||||||
Math.pow(product.rat, 0.65) *
|
Math.pow(product.rat, 0.65) *
|
||||||
marketFactor *
|
marketFactor *
|
||||||
corporation.getSalesMultiplier() *
|
corporation.getSalesMultiplier() *
|
||||||
@ -1281,10 +1282,10 @@ export class Industry implements IIndustry {
|
|||||||
case 1: {
|
case 1: {
|
||||||
//AdVert.Inc,
|
//AdVert.Inc,
|
||||||
const advMult = corporation.getAdvertisingMultiplier() * this.getAdvertisingMultiplier();
|
const advMult = corporation.getAdvertisingMultiplier() * this.getAdvertisingMultiplier();
|
||||||
const awareness = (this.awareness + (3 * advMult)) * (1.01 * advMult);
|
const awareness = (this.awareness + 3 * advMult) * (1.01 * advMult);
|
||||||
this.awareness = Math.min(awareness, Number.MAX_VALUE);
|
this.awareness = Math.min(awareness, Number.MAX_VALUE);
|
||||||
|
|
||||||
const popularity = (this.popularity + (1 * advMult)) * ((1 + getRandomInt(1, 3) / 100) * advMult);
|
const popularity = (this.popularity + 1 * advMult) * ((1 + getRandomInt(1, 3) / 100) * advMult);
|
||||||
this.popularity = Math.min(popularity, Number.MAX_VALUE);
|
this.popularity = Math.min(popularity, Number.MAX_VALUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ export class OfficeSpace {
|
|||||||
let jobCount = this.employees.reduce((acc, employee) => (employee.pos === job ? acc + 1 : acc), 0);
|
let jobCount = this.employees.reduce((acc, employee) => (employee.pos === job ? acc + 1 : acc), 0);
|
||||||
|
|
||||||
for (const employee of this.employees) {
|
for (const employee of this.employees) {
|
||||||
if (jobCount == amount) return true
|
if (jobCount == amount) return true;
|
||||||
if (employee.pos === EmployeePositions.Unassigned && jobCount <= amount) {
|
if (employee.pos === EmployeePositions.Unassigned && jobCount <= amount) {
|
||||||
employee.pos = job;
|
employee.pos = job;
|
||||||
jobCount++;
|
jobCount++;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { CityName } from './../../Locations/data/CityNames';
|
import { CityName } from "./../../Locations/data/CityNames";
|
||||||
const CyclesPerMarketCycle = 50;
|
const CyclesPerMarketCycle = 50;
|
||||||
const AllCorporationStates = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"];
|
const AllCorporationStates = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"];
|
||||||
export const CorporationConstants: {
|
export const CorporationConstants: {
|
||||||
@ -38,7 +38,14 @@ export const CorporationConstants: {
|
|||||||
CyclesPerIndustryStateCycle: CyclesPerMarketCycle / AllCorporationStates.length,
|
CyclesPerIndustryStateCycle: CyclesPerMarketCycle / AllCorporationStates.length,
|
||||||
SecsPerMarketCycle: CyclesPerMarketCycle / 5,
|
SecsPerMarketCycle: CyclesPerMarketCycle / 5,
|
||||||
|
|
||||||
Cities: [CityName.Aevum, CityName.Chongqing, CityName.Sector12, CityName.NewTokyo, CityName.Ishima, CityName.Volhaven],
|
Cities: [
|
||||||
|
CityName.Aevum,
|
||||||
|
CityName.Chongqing,
|
||||||
|
CityName.Sector12,
|
||||||
|
CityName.NewTokyo,
|
||||||
|
CityName.Ishima,
|
||||||
|
CityName.Volhaven,
|
||||||
|
],
|
||||||
|
|
||||||
WarehouseInitialCost: 5e9, //Initial purchase cost of warehouse
|
WarehouseInitialCost: 5e9, //Initial purchase cost of warehouse
|
||||||
WarehouseInitialSize: 100,
|
WarehouseInitialSize: 100,
|
||||||
@ -74,16 +81,6 @@ export const CorporationConstants: {
|
|||||||
"AI Cores",
|
"AI Cores",
|
||||||
"Real Estate",
|
"Real Estate",
|
||||||
],
|
],
|
||||||
FundingRoundShares: [
|
FundingRoundShares: [0.1, 0.35, 0.25, 0.2],
|
||||||
0.1,
|
FundingRoundMultiplier: [4, 3, 3, 2.5],
|
||||||
0.35,
|
|
||||||
0.25,
|
|
||||||
0.2
|
|
||||||
],
|
|
||||||
FundingRoundMultiplier: [
|
|
||||||
4,
|
|
||||||
3,
|
|
||||||
3,
|
|
||||||
2.5
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
@ -6,8 +6,8 @@ import { useCorporation } 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";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import { BuyBackShares } from '../Actions';
|
import { BuyBackShares } from "../Actions";
|
||||||
import { dialogBoxCreate } from '../../ui/React/DialogBox';
|
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||||
import { KEY } from "../../utils/helpers/keyCodes";
|
import { KEY } from "../../utils/helpers/keyCodes";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -40,9 +40,8 @@ export function BuybackSharesModal(props: IProps): React.ReactElement {
|
|||||||
function buy(): void {
|
function buy(): void {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
try {
|
try {
|
||||||
BuyBackShares(corp, player, shares)
|
BuyBackShares(corp, player, shares);
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
props.onClose();
|
props.onClose();
|
||||||
|
@ -30,7 +30,7 @@ export function CityTabs(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tabs variant="fullWidth" value={city} onChange={handleChange} sx={{ maxWidth: '65%' }}>
|
<Tabs variant="fullWidth" value={city} onChange={handleChange} sx={{ maxWidth: "65%" }}>
|
||||||
{Object.values(division.offices).map(
|
{Object.values(division.offices).map(
|
||||||
(office: OfficeSpace | 0) => office !== 0 && <Tab key={office.loc} label={office.loc} value={office.loc} />,
|
(office: OfficeSpace | 0) => office !== 0 && <Tab key={office.loc} label={office.loc} value={office.loc} />,
|
||||||
)}
|
)}
|
||||||
|
@ -38,7 +38,7 @@ export function CorporationRoot(): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Corporation.Provider value={corporation}>
|
<Context.Corporation.Provider value={corporation}>
|
||||||
<Tabs variant="scrollable" value={divisionName} onChange={handleChange} sx={{ maxWidth: '65%' }} scrollButtons>
|
<Tabs variant="scrollable" value={divisionName} onChange={handleChange} sx={{ maxWidth: "65%" }} scrollButtons>
|
||||||
<Tab label={corporation.name} value={"Overview"} />
|
<Tab label={corporation.name} value={"Overview"} />
|
||||||
{corporation.divisions.map((div) => (
|
{corporation.divisions.map((div) => (
|
||||||
<Tab key={div.name} label={div.name} value={div.name} />
|
<Tab key={div.name} label={div.name} value={div.name} />
|
||||||
|
@ -56,9 +56,11 @@ export function CreateCorporationModal(props: IProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<Modal open={props.open} onClose={props.onClose}>
|
<Modal open={props.open} onClose={props.onClose}>
|
||||||
<Typography>
|
<Typography>
|
||||||
Would you like to start a corporation? This will require $150b for registration and initial funding. {player.bitNodeN === 3 && (`This $150b
|
Would you like to start a corporation? This will require $150b for registration and initial funding.{" "}
|
||||||
|
{player.bitNodeN === 3 &&
|
||||||
|
`This $150b
|
||||||
can either be self-funded, or you can obtain the seed money from the government in exchange for 500 million
|
can either be self-funded, or you can obtain the seed money from the government in exchange for 500 million
|
||||||
shares`)}
|
shares`}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
If you would like to start one, please enter a name for your corporation below:
|
If you would like to start one, please enter a name for your corporation below:
|
||||||
|
@ -23,7 +23,9 @@ interface IProps {
|
|||||||
// Create a popup that lets the player manage exports
|
// Create a popup that lets the player manage exports
|
||||||
export function ExportModal(props: IProps): React.ReactElement {
|
export function ExportModal(props: IProps): React.ReactElement {
|
||||||
const corp = useCorporation();
|
const corp = useCorporation();
|
||||||
const possibleDivisions = corp.divisions.filter((division: IIndustry) => isRelevantMaterial(props.mat.name, division));
|
const possibleDivisions = corp.divisions.filter((division: IIndustry) =>
|
||||||
|
isRelevantMaterial(props.mat.name, division),
|
||||||
|
);
|
||||||
if (possibleDivisions.length === 0) throw new Error("Export popup created with no divisions.");
|
if (possibleDivisions.length === 0) throw new Error("Export popup created with no divisions.");
|
||||||
const defaultDivision = possibleDivisions[0];
|
const defaultDivision = possibleDivisions[0];
|
||||||
if (Object.keys(defaultDivision.warehouses).length === 0)
|
if (Object.keys(defaultDivision.warehouses).length === 0)
|
||||||
|
@ -17,7 +17,11 @@ interface IProps {
|
|||||||
export function FindInvestorsModal(props: IProps): React.ReactElement {
|
export function FindInvestorsModal(props: IProps): React.ReactElement {
|
||||||
const corporation = useCorporation();
|
const corporation = useCorporation();
|
||||||
const val = corporation.determineValuation();
|
const val = corporation.determineValuation();
|
||||||
if (corporation.fundingRound >= CorporationConstants.FundingRoundShares.length || corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length) return <></>;
|
if (
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length
|
||||||
|
)
|
||||||
|
return <></>;
|
||||||
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
||||||
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
|
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
|
||||||
const funding = val * percShares * roundMultiplier;
|
const funding = val * percShares * roundMultiplier;
|
||||||
|
@ -18,7 +18,5 @@ export function IndustryProductEquation(props: IProps): React.ReactElement {
|
|||||||
prod.push("Products");
|
prod.push("Products");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <MathJaxWrapper>{"\\(" + reqs.join("+") + `\\Rightarrow ` + prod.join("+") + "\\)"}</MathJaxWrapper>;
|
||||||
<MathJaxWrapper>{"\\(" + reqs.join("+") + `\\Rightarrow ` + prod.join("+") + "\\)"}</MathJaxWrapper>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ interface IProps {
|
|||||||
const useStyles = makeStyles(() =>
|
const useStyles = makeStyles(() =>
|
||||||
createStyles({
|
createStyles({
|
||||||
retainHeight: {
|
retainHeight: {
|
||||||
minHeight: '3em',
|
minHeight: "3em",
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
function WarehouseRoot(props: IProps): React.ReactElement {
|
function WarehouseRoot(props: IProps): React.ReactElement {
|
||||||
@ -127,27 +127,53 @@ function WarehouseRoot(props: IProps): React.ReactElement {
|
|||||||
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 of Object.keys(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")}
|
||||||
|
</>,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let breakdown;
|
let breakdown;
|
||||||
if (breakdownItems && breakdownItems.length > 0) {
|
if (breakdownItems && breakdownItems.length > 0) {
|
||||||
breakdown = breakdownItems.reduce(
|
breakdown = breakdownItems.reduce(
|
||||||
(previous: JSX.Element, current: JSX.Element): JSX.Element => previous && <>{previous}<br />{current}</> || <>{current}</>);
|
(previous: JSX.Element, current: JSX.Element): JSX.Element =>
|
||||||
|
(previous && (
|
||||||
|
<>
|
||||||
|
{previous}
|
||||||
|
<br />
|
||||||
|
{current}
|
||||||
|
</>
|
||||||
|
)) || <>{current}</>,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
breakdown = <>No items in storage.</>
|
breakdown = <>No items in storage.</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<Tooltip title={props.warehouse.sizeUsed !== 0 ? <Typography><>{breakdown}</></Typography> : ""}>
|
<Tooltip
|
||||||
|
title={
|
||||||
|
props.warehouse.sizeUsed !== 0 ? (
|
||||||
|
<Typography>
|
||||||
|
<>{breakdown}</>
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
<Typography color={props.warehouse.sizeUsed >= props.warehouse.size ? "error" : "primary"}>
|
<Typography color={props.warehouse.sizeUsed >= props.warehouse.size ? "error" : "primary"}>
|
||||||
Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
|
Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
|
||||||
{numeralWrapper.formatBigNumber(props.warehouse.size)}
|
{numeralWrapper.formatBigNumber(props.warehouse.size)}
|
||||||
|
@ -112,7 +112,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: '2fr 1fr', m: '5px' }}>
|
<Box sx={{ display: "grid", gridTemplateColumns: "2fr 1fr", m: "5px" }}>
|
||||||
<Box>
|
<Box>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
@ -149,7 +149,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box sx={{ "& button": { width: '100%' } }}>
|
<Box sx={{ "& button": { width: "100%" } }}>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={tutorial ? <Typography>Purchase your required materials to get production started!</Typography> : ""}
|
title={tutorial ? <Typography>Purchase your required materials to get production started!</Typography> : ""}
|
||||||
>
|
>
|
||||||
|
@ -89,7 +89,7 @@ export function Overview({ rerender }: IProps): React.ReactElement {
|
|||||||
<StatsTable rows={multRows} />
|
<StatsTable rows={multRows} />
|
||||||
<br />
|
<br />
|
||||||
<BonusTime />
|
<BonusTime />
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", width: "fit-content" }}>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -16,7 +16,7 @@ import Box from "@mui/material/Box";
|
|||||||
import Collapse from "@mui/material/Collapse";
|
import Collapse from "@mui/material/Collapse";
|
||||||
import ExpandMore from "@mui/icons-material/ExpandMore";
|
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||||
import ExpandLess from "@mui/icons-material/ExpandLess";
|
import ExpandLess from "@mui/icons-material/ExpandLess";
|
||||||
import CheckIcon from '@mui/icons-material/Check';
|
import CheckIcon from "@mui/icons-material/Check";
|
||||||
|
|
||||||
interface INodeProps {
|
interface INodeProps {
|
||||||
n: Node | null;
|
n: Node | null;
|
||||||
@ -66,19 +66,23 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
|
|||||||
>
|
>
|
||||||
{ele}
|
{ele}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
const but = (
|
const but = (
|
||||||
<Box>
|
<Box>
|
||||||
{wrapInTooltip(
|
{wrapInTooltip(
|
||||||
<span>
|
<span>
|
||||||
<Button color={color} disabled={disabled && !n.researched} onClick={research}
|
<Button
|
||||||
style={{ width: '100%', textAlign: 'left', justifyContent: 'unset' }}
|
color={color}
|
||||||
|
disabled={disabled && !n.researched}
|
||||||
|
onClick={research}
|
||||||
|
style={{ width: "100%", textAlign: "left", justifyContent: "unset" }}
|
||||||
>
|
>
|
||||||
{n.researched && (<CheckIcon sx={{ mr: 1 }} />)}{n.text}
|
{n.researched && <CheckIcon sx={{ mr: 1 }} />}
|
||||||
|
{n.text}
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>,
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@ -87,20 +91,29 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Box display="flex" sx={{ border: '1px solid ' + Settings.theme.well }}>
|
<Box display="flex" sx={{ border: "1px solid " + Settings.theme.well }}>
|
||||||
{wrapInTooltip(
|
{wrapInTooltip(
|
||||||
<span style={{ width: '100%' }}>
|
<span style={{ width: "100%" }}>
|
||||||
<Button color={color} disabled={disabled && !n.researched} onClick={research} sx={{
|
<Button
|
||||||
width: '100%',
|
color={color}
|
||||||
textAlign: 'left',
|
disabled={disabled && !n.researched}
|
||||||
justifyContent: 'unset',
|
onClick={research}
|
||||||
borderColor: Settings.theme.button
|
sx={{
|
||||||
}}>
|
width: "100%",
|
||||||
{n.researched && (<CheckIcon sx={{ mr: 1 }} />)}{n.text}
|
textAlign: "left",
|
||||||
|
justifyContent: "unset",
|
||||||
|
borderColor: Settings.theme.button,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{n.researched && <CheckIcon sx={{ mr: 1 }} />}
|
||||||
|
{n.text}
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>,
|
||||||
)}
|
)}
|
||||||
<Button onClick={() => setOpen((old) => !old)} sx={{ borderColor: Settings.theme.button, minWidth: 'fit-content' }}>
|
<Button
|
||||||
|
onClick={() => setOpen((old) => !old)}
|
||||||
|
sx={{ borderColor: Settings.theme.button, minWidth: "fit-content" }}
|
||||||
|
>
|
||||||
{open ? <ExpandLess color="primary" /> : <ExpandMore color="primary" />}
|
{open ? <ExpandLess color="primary" /> : <ExpandMore color="primary" />}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -51,7 +51,7 @@ export function SellSharesModal(props: IProps): React.ReactElement {
|
|||||||
function sell(): void {
|
function sell(): void {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
try {
|
try {
|
||||||
const profit = SellShares(corp, player, shares)
|
const profit = SellShares(corp, player, shares);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
@ -65,7 +65,6 @@ export function SellSharesModal(props: IProps): React.ReactElement {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialogBoxCreate(err + "");
|
dialogBoxCreate(err + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||||
|
@ -5,5 +5,5 @@ export const StanekConstants: {
|
|||||||
} = {
|
} = {
|
||||||
RAMBonus: 0.1,
|
RAMBonus: 0.1,
|
||||||
BaseSize: 9,
|
BaseSize: 9,
|
||||||
MaxSize: 25
|
MaxSize: 25,
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,9 @@ export function buyAllDarkwebItems(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cost > Player.money) {
|
if (cost > Player.money) {
|
||||||
Terminal.error("Not enough money to purchase remaining programs, " + numeralWrapper.formatMoney(cost) + " required");
|
Terminal.error(
|
||||||
|
"Not enough money to purchase remaining programs, " + numeralWrapper.formatMoney(cost) + " required",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import Typography from "@mui/material/Typography";
|
|||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import ButtonGroup from "@mui/material/ButtonGroup";
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
||||||
import { Tooltip } from "@mui/material";
|
import { Tooltip } from "@mui/material";
|
||||||
import LockIcon from '@mui/icons-material/Lock';
|
import LockIcon from "@mui/icons-material/Lock";
|
||||||
import LockOpenIcon from '@mui/icons-material/LockOpen';
|
import LockOpenIcon from "@mui/icons-material/LockOpen";
|
||||||
|
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { achievements } from "../../Achievements/Achievements";
|
import { achievements } from "../../Achievements/Achievements";
|
||||||
@ -21,26 +21,26 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Achievements(props: IProps): React.ReactElement {
|
export function Achievements(props: IProps): React.ReactElement {
|
||||||
const [playerAchievement, setPlayerAchievements] = useState(props.player.achievements.map(m => m.ID));
|
const [playerAchievement, setPlayerAchievements] = useState(props.player.achievements.map((m) => m.ID));
|
||||||
|
|
||||||
function grantAchievement(id: string): void {
|
function grantAchievement(id: string): void {
|
||||||
props.player.giveAchievement(id);
|
props.player.giveAchievement(id);
|
||||||
setPlayerAchievements(props.player.achievements.map(m => m.ID));
|
setPlayerAchievements(props.player.achievements.map((m) => m.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
function grantAllAchievements(): void {
|
function grantAllAchievements(): void {
|
||||||
Object.values(achievements).forEach(a => props.player.giveAchievement(a.ID));
|
Object.values(achievements).forEach((a) => props.player.giveAchievement(a.ID));
|
||||||
setPlayerAchievements(props.player.achievements.map(m => m.ID));
|
setPlayerAchievements(props.player.achievements.map((m) => m.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAchievement(id: string): void {
|
function removeAchievement(id: string): void {
|
||||||
props.player.achievements = props.player.achievements.filter(a => a.ID !== id);
|
props.player.achievements = props.player.achievements.filter((a) => a.ID !== id);
|
||||||
setPlayerAchievements(props.player.achievements.map(m => m.ID));
|
setPlayerAchievements(props.player.achievements.map((m) => m.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAchievements(): void {
|
function clearAchievements(): void {
|
||||||
props.player.achievements = [];
|
props.player.achievements = [];
|
||||||
setPlayerAchievements(props.player.achievements.map(m => m.ID));
|
setPlayerAchievements(props.player.achievements.map((m) => m.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableEngine(): void {
|
function disableEngine(): void {
|
||||||
@ -48,7 +48,7 @@ export function Achievements(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function enableEngine(): void {
|
function enableEngine(): void {
|
||||||
props.engine.Counters.achievementsCounter = 0
|
props.engine.Counters.achievementsCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -60,8 +60,7 @@ export function Achievements(props: IProps): React.ReactElement {
|
|||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td></td>
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<Typography>Achievements:</Typography>
|
<Typography>Achievements:</Typography>
|
||||||
</td>
|
</td>
|
||||||
@ -76,7 +75,8 @@ export function Achievements(props: IProps): React.ReactElement {
|
|||||||
</tr>
|
</tr>
|
||||||
{Object.values(achievements).map((i) => {
|
{Object.values(achievements).map((i) => {
|
||||||
const achieved = playerAchievement.includes(i.ID);
|
const achieved = playerAchievement.includes(i.ID);
|
||||||
return <tr key={"ach-" + i.ID}>
|
return (
|
||||||
|
<tr key={"ach-" + i.ID}>
|
||||||
<td>
|
<td>
|
||||||
{achieved ? (
|
{achieved ? (
|
||||||
<Tooltip title="Achieved">
|
<Tooltip title="Achieved">
|
||||||
@ -89,8 +89,16 @@ export function Achievements(props: IProps): React.ReactElement {
|
|||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Tooltip title={<>{i.ID}<br />{i.Description}</>}>
|
<Tooltip
|
||||||
<Typography color={achieved ? 'primary': 'secondary'}>{i.Name}:</Typography>
|
title={
|
||||||
|
<>
|
||||||
|
{i.ID}
|
||||||
|
<br />
|
||||||
|
{i.Description}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Typography color={achieved ? "primary" : "secondary"}>{i.Name}:</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@ -100,6 +108,7 @@ export function Achievements(props: IProps): React.ReactElement {
|
|||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -37,7 +37,7 @@ export function Factions(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function receiveAllInvites(): void {
|
function receiveAllInvites(): void {
|
||||||
Object.values(FactionNames).forEach(faction => props.player.receiveInvite(faction))
|
Object.values(FactionNames).forEach((faction) => props.player.receiveInvite(faction));
|
||||||
}
|
}
|
||||||
|
|
||||||
function modifyFactionRep(modifier: number): (x: number) => void {
|
function modifyFactionRep(modifier: number): (x: number) => void {
|
||||||
|
@ -46,7 +46,7 @@ export function General(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) throw new ReferenceError('Manually thrown error');
|
if (error) throw new ReferenceError("Manually thrown error");
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -203,7 +203,7 @@ export const getFactionAugmentationsFiltered = (player: IPlayer, faction: Factio
|
|||||||
// Remove special augs
|
// Remove special augs
|
||||||
augs = augs.filter((a) => !a.isSpecial);
|
augs = augs.filter((a) => !a.isSpecial);
|
||||||
|
|
||||||
const blacklist: string[] = [AugmentationNames.NeuroFluxGovernor];
|
const blacklist: string[] = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.CongruityImplant];
|
||||||
|
|
||||||
if (player.bitNodeN !== 2) {
|
if (player.bitNodeN !== 2) {
|
||||||
// TRP is not available outside of BN2 for Gangs
|
// TRP is not available outside of BN2 for Gangs
|
||||||
|
@ -85,8 +85,6 @@ export class FactionInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of all factions and associated info to them.
|
* A map of all factions and associated info to them.
|
||||||
*/
|
*/
|
||||||
@ -143,8 +141,9 @@ export const FactionInfos: IMap<FactionInfo> = {
|
|||||||
[FactionNames.ECorp]: new FactionInfo(
|
[FactionNames.ECorp]: new FactionInfo(
|
||||||
(
|
(
|
||||||
<>
|
<>
|
||||||
{FactionNames.ECorp}'s mission is simple: to connect the world of today with the technology of tomorrow. With our wide range of
|
{FactionNames.ECorp}'s mission is simple: to connect the world of today with the technology of tomorrow. With
|
||||||
Internet-related software and commercial hardware, {FactionNames.ECorp} makes the world's information universally accessible.
|
our wide range of Internet-related software and commercial hardware, {FactionNames.ECorp} makes the world's
|
||||||
|
information universally accessible.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
@ -159,12 +158,13 @@ export const FactionInfos: IMap<FactionInfo> = {
|
|||||||
[FactionNames.MegaCorp]: new FactionInfo(
|
[FactionNames.MegaCorp]: new FactionInfo(
|
||||||
(
|
(
|
||||||
<>
|
<>
|
||||||
{FactionNames.MegaCorp} does what no other dares to do. We imagine. We create. We invent. We create what others have never even
|
{FactionNames.MegaCorp} does what no other dares to do. We imagine. We create. We invent. We create what others
|
||||||
dreamed of. Our work fills the world's needs for food, water, power, and transportation on an unprecedented
|
have never even dreamed of. Our work fills the world's needs for food, water, power, and transportation on an
|
||||||
scale, in ways that no other company can.
|
unprecedented scale, in ways that no other company can.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
In our labs and factories and on the ground with customers, {FactionNames.MegaCorp} is ushering in a new era for the world.
|
In our labs and factories and on the ground with customers, {FactionNames.MegaCorp} is ushering in a new era for
|
||||||
|
the world.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
[],
|
[],
|
||||||
@ -194,7 +194,16 @@ export const FactionInfos: IMap<FactionInfo> = {
|
|||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
|
|
||||||
[FactionNames.BladeIndustries]: new FactionInfo(<>Augmentation is Salvation.</>, [], true, true, true, true, false, true),
|
[FactionNames.BladeIndustries]: new FactionInfo(
|
||||||
|
<>Augmentation is Salvation.</>,
|
||||||
|
[],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
|
||||||
[FactionNames.NWO]: new FactionInfo(
|
[FactionNames.NWO]: new FactionInfo(
|
||||||
(
|
(
|
||||||
@ -486,12 +495,39 @@ export const FactionInfos: IMap<FactionInfo> = {
|
|||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
|
||||||
[FactionNames.SlumSnakes]: new FactionInfo(<>{FactionNames.SlumSnakes} rule!</>, [], false, false, true, true, false, false),
|
[FactionNames.SlumSnakes]: new FactionInfo(
|
||||||
|
<>{FactionNames.SlumSnakes} rule!</>,
|
||||||
|
[],
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
|
||||||
// Earlygame factions - factions the player will prestige with early on that don't belong in other categories.
|
// Earlygame factions - factions the player will prestige with early on that don't belong in other categories.
|
||||||
[FactionNames.Netburners]: new FactionInfo(<>{"~~//*>H4CK||3T 8URN3R5**>?>\\~~"}</>, [], true, true, false, false, false, false),
|
[FactionNames.Netburners]: new FactionInfo(
|
||||||
|
<>{"~~//*>H4CK||3T 8URN3R5**>?>\\~~"}</>,
|
||||||
|
[],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
|
||||||
[FactionNames.TianDiHui]: new FactionInfo(<>Obey Heaven and work righteously.</>, [], true, true, false, true, false, false),
|
[FactionNames.TianDiHui]: new FactionInfo(
|
||||||
|
<>Obey Heaven and work righteously.</>,
|
||||||
|
[],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
|
||||||
[FactionNames.CyberSec]: new FactionInfo(
|
[FactionNames.CyberSec]: new FactionInfo(
|
||||||
(
|
(
|
||||||
@ -517,7 +553,8 @@ export const FactionInfos: IMap<FactionInfo> = {
|
|||||||
It's too bad they won't live. But then again, who does?
|
It's too bad they won't live. But then again, who does?
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
Note that for this faction, reputation can only be gained through {FactionNames.Bladeburners} actions. Completing {FactionNames.Bladeburners}
|
Note that for this faction, reputation can only be gained through {FactionNames.Bladeburners} actions.
|
||||||
|
Completing {FactionNames.Bladeburners}
|
||||||
contracts/operations will increase your reputation.
|
contracts/operations will increase your reputation.
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
|
@ -32,8 +32,6 @@ type IProps = {
|
|||||||
|
|
||||||
export function AugmentationsPage(props: IProps): React.ReactElement {
|
export function AugmentationsPage(props: IProps): React.ReactElement {
|
||||||
const player = use.Player();
|
const player = use.Player();
|
||||||
// Flag for whether the player has a gang with this faction
|
|
||||||
const isPlayersGang = player.inGang() && player.getGangName() === props.faction.name;
|
|
||||||
|
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ import React, { useEffect, useState } from "react";
|
|||||||
|
|
||||||
import { Box, Button, Container, Paper, TableBody, TableRow, Typography } from "@mui/material";
|
import { Box, Button, Container, Paper, TableBody, TableRow, Typography } from "@mui/material";
|
||||||
|
|
||||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
|
||||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { Table, TableCell } from "../../ui/React/Table";
|
import { Table, TableCell } from "../../ui/React/Table";
|
||||||
import { IRouter } from "../../ui/Router";
|
import { IRouter } from "../../ui/Router";
|
||||||
|
@ -59,9 +59,7 @@ export function Info(props: IProps): React.ReactElement {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<MathJaxWrapper>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJaxWrapper>
|
<MathJaxWrapper>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJaxWrapper>
|
||||||
<MathJaxWrapper>
|
<MathJaxWrapper>
|
||||||
{
|
{"\\(\\huge{favor=1+\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"}
|
||||||
"\\(\\huge{favor=1+\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"
|
|
||||||
}
|
|
||||||
</MathJaxWrapper>
|
</MathJaxWrapper>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@ -86,7 +84,6 @@ export function Info(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
<MathJaxWrapper>{"\\(\\huge{r = reputation}\\)"}</MathJaxWrapper>
|
<MathJaxWrapper>{"\\(\\huge{r = reputation}\\)"}</MathJaxWrapper>
|
||||||
<MathJaxWrapper>{"\\(\\huge{\\Delta r = \\Delta r \\times \\frac{100+favor}{100}}\\)"}</MathJaxWrapper>
|
<MathJaxWrapper>{"\\(\\huge{\\Delta r = \\Delta r \\times \\frac{100+favor}{100}}\\)"}</MathJaxWrapper>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FactionNames } from '../Faction/data/FactionNames';
|
import { FactionNames } from "../Faction/data/FactionNames";
|
||||||
import { Reviver } from "../utils/JSONReviver";
|
import { Reviver } from "../utils/JSONReviver";
|
||||||
|
|
||||||
interface GangTerritory {
|
interface GangTerritory {
|
||||||
|
@ -225,7 +225,6 @@ export class Gang implements IGang {
|
|||||||
if (AllGangs[otherGang].territory <= 0) return;
|
if (AllGangs[otherGang].territory <= 0) return;
|
||||||
const territoryGain = calculateTerritoryGain(thisGang, otherGang);
|
const territoryGain = calculateTerritoryGain(thisGang, otherGang);
|
||||||
AllGangs[thisGang].territory += territoryGain;
|
AllGangs[thisGang].territory += territoryGain;
|
||||||
if (AllGangs[thisGang].territory > 0.999) AllGangs[thisGang].territory = 1;
|
|
||||||
AllGangs[otherGang].territory -= territoryGain;
|
AllGangs[otherGang].territory -= territoryGain;
|
||||||
if (thisGang === gangName) {
|
if (thisGang === gangName) {
|
||||||
this.clash(true); // Player won
|
this.clash(true); // Player won
|
||||||
@ -239,9 +238,7 @@ export class Gang implements IGang {
|
|||||||
if (AllGangs[thisGang].territory <= 0) return;
|
if (AllGangs[thisGang].territory <= 0) return;
|
||||||
const territoryGain = calculateTerritoryGain(otherGang, thisGang);
|
const territoryGain = calculateTerritoryGain(otherGang, thisGang);
|
||||||
AllGangs[thisGang].territory -= territoryGain;
|
AllGangs[thisGang].territory -= territoryGain;
|
||||||
if (AllGangs[otherGang].territory < 0.001) AllGangs[otherGang].territory = 0;
|
|
||||||
AllGangs[otherGang].territory += territoryGain;
|
AllGangs[otherGang].territory += territoryGain;
|
||||||
if (AllGangs[otherGang].territory > 0.999) AllGangs[otherGang].territory = 1;
|
|
||||||
if (thisGang === gangName) {
|
if (thisGang === gangName) {
|
||||||
this.clash(false); // Player lost
|
this.clash(false); // Player lost
|
||||||
} else if (otherGang === gangName) {
|
} else if (otherGang === gangName) {
|
||||||
@ -251,6 +248,11 @@ export class Gang implements IGang {
|
|||||||
AllGangs[thisGang].power *= 1 / 1.01;
|
AllGangs[thisGang].power *= 1 / 1.01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const total = Object.values(AllGangs)
|
||||||
|
.map((g) => g.territory)
|
||||||
|
.reduce((p, c) => p + c, 0);
|
||||||
|
Object.values(AllGangs).forEach((g) => (g.territory /= total));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FactionNames } from '../../Faction/data/FactionNames';
|
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||||
export const PowerMultiplier: {
|
export const PowerMultiplier: {
|
||||||
[key: string]: number | undefined;
|
[key: string]: number | undefined;
|
||||||
} = {
|
} = {
|
||||||
|
@ -51,7 +51,7 @@ export function AscensionModal(props: IProps): React.ReactElement {
|
|||||||
<br />
|
<br />
|
||||||
Charisma: x{numeralWrapper.format(res.cha, "0.000")}
|
Charisma: x{numeralWrapper.format(res.cha, "0.000")}
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>,
|
||||||
);
|
);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ function UpgradeButton(props: IUpgradeButtonProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<Tooltip title={<Typography dangerouslySetInnerHTML={{ __html: props.upg.desc }} />}>
|
<Tooltip title={<Typography dangerouslySetInnerHTML={{ __html: props.upg.desc }} />}>
|
||||||
<span>
|
<span>
|
||||||
<Button onClick={onClick} sx={{ display: 'flex', flexDirection: 'column', width: '100%', height: '100%' }}>
|
<Button onClick={onClick} sx={{ display: "flex", flexDirection: "column", width: "100%", height: "100%" }}>
|
||||||
<Typography sx={{ display: 'block' }}>{props.upg.name}</Typography>
|
<Typography sx={{ display: "block" }}>{props.upg.name}</Typography>
|
||||||
<Money money={gang.getUpgradeCost(props.upg)} />
|
<Money money={gang.getUpgradeCost(props.upg)} />
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
@ -113,8 +113,8 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
|
|
||||||
const onChange = (event: SelectChangeEvent<string>): void => {
|
const onChange = (event: SelectChangeEvent<string>): void => {
|
||||||
setCurrentCategory(event.target.value);
|
setCurrentCategory(event.target.value);
|
||||||
rerender()
|
rerender();
|
||||||
}
|
};
|
||||||
|
|
||||||
const weaponUpgrades = filterUpgrades(props.member.upgrades, UpgradeType.Weapon);
|
const weaponUpgrades = filterUpgrades(props.member.upgrades, UpgradeType.Weapon);
|
||||||
const armorUpgrades = filterUpgrades(props.member.upgrades, UpgradeType.Armor);
|
const armorUpgrades = filterUpgrades(props.member.upgrades, UpgradeType.Armor);
|
||||||
@ -123,11 +123,11 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
const augUpgrades = filterUpgrades(props.member.augmentations, UpgradeType.Augmentation);
|
const augUpgrades = filterUpgrades(props.member.augmentations, UpgradeType.Augmentation);
|
||||||
|
|
||||||
const categories: { [key: string]: (GangMemberUpgrade[] | UpgradeType)[] } = {
|
const categories: { [key: string]: (GangMemberUpgrade[] | UpgradeType)[] } = {
|
||||||
'Weapons': [weaponUpgrades, UpgradeType.Weapon],
|
Weapons: [weaponUpgrades, UpgradeType.Weapon],
|
||||||
'Armor': [armorUpgrades, UpgradeType.Armor],
|
Armor: [armorUpgrades, UpgradeType.Armor],
|
||||||
'Vehicles': [vehicleUpgrades, UpgradeType.Vehicle],
|
Vehicles: [vehicleUpgrades, UpgradeType.Vehicle],
|
||||||
'Rootkits': [rootkitUpgrades, UpgradeType.Rootkit],
|
Rootkits: [rootkitUpgrades, UpgradeType.Rootkit],
|
||||||
'Augmentations': [augUpgrades, UpgradeType.Augmentation]
|
Augmentations: [augUpgrades, UpgradeType.Augmentation],
|
||||||
};
|
};
|
||||||
|
|
||||||
const asc = {
|
const asc = {
|
||||||
@ -140,7 +140,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: '1fr 1fr', m: 1, gap: 1 }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "1fr 1fr", m: 1, gap: 1 }}>
|
||||||
<span>
|
<span>
|
||||||
<Typography variant="h5" color="primary">
|
<Typography variant="h5" color="primary">
|
||||||
{props.member.name} ({props.member.task})
|
{props.member.name} ({props.member.task})
|
||||||
@ -149,47 +149,70 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
title={
|
title={
|
||||||
<Typography>
|
<Typography>
|
||||||
Hk: x{numeralWrapper.formatMultiplier(props.member.hack_mult * asc.hack)}(x
|
Hk: x{numeralWrapper.formatMultiplier(props.member.hack_mult * asc.hack)}(x
|
||||||
{numeralWrapper.formatMultiplier(props.member.hack_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.hack)}{" "}
|
{numeralWrapper.formatMultiplier(props.member.hack_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.hack)} Asc)
|
||||||
<br />
|
<br />
|
||||||
St: x{numeralWrapper.formatMultiplier(props.member.str_mult * asc.str)}
|
St: x{numeralWrapper.formatMultiplier(props.member.str_mult * asc.str)}
|
||||||
(x{numeralWrapper.formatMultiplier(props.member.str_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.str)}{" "}
|
(x{numeralWrapper.formatMultiplier(props.member.str_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.str)} Asc)
|
||||||
<br />
|
<br />
|
||||||
Df: x{numeralWrapper.formatMultiplier(props.member.def_mult * asc.def)}
|
Df: x{numeralWrapper.formatMultiplier(props.member.def_mult * asc.def)}
|
||||||
(x{numeralWrapper.formatMultiplier(props.member.def_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.def)}{" "}
|
(x{numeralWrapper.formatMultiplier(props.member.def_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.def)} Asc)
|
||||||
<br />
|
<br />
|
||||||
Dx: x{numeralWrapper.formatMultiplier(props.member.dex_mult * asc.dex)}
|
Dx: x{numeralWrapper.formatMultiplier(props.member.dex_mult * asc.dex)}
|
||||||
(x{numeralWrapper.formatMultiplier(props.member.dex_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.dex)}{" "}
|
(x{numeralWrapper.formatMultiplier(props.member.dex_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.dex)} Asc)
|
||||||
<br />
|
<br />
|
||||||
Ag: x{numeralWrapper.formatMultiplier(props.member.agi_mult * asc.agi)}
|
Ag: x{numeralWrapper.formatMultiplier(props.member.agi_mult * asc.agi)}
|
||||||
(x{numeralWrapper.formatMultiplier(props.member.agi_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.agi)}{" "}
|
(x{numeralWrapper.formatMultiplier(props.member.agi_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.agi)} Asc)
|
||||||
<br />
|
<br />
|
||||||
Ch: x{numeralWrapper.formatMultiplier(props.member.cha_mult * asc.cha)}
|
Ch: x{numeralWrapper.formatMultiplier(props.member.cha_mult * asc.cha)}
|
||||||
(x{numeralWrapper.formatMultiplier(props.member.cha_mult)} Eq, x{numeralWrapper.formatMultiplier(asc.cha)}{" "}
|
(x{numeralWrapper.formatMultiplier(props.member.cha_mult)} Eq, x
|
||||||
Asc)
|
{numeralWrapper.formatMultiplier(asc.cha)} Asc)
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table>
|
<Table>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<StatsRow name="Hacking" color={Settings.theme.hack} data={{ level: props.member.hack, exp: props.member.hack_exp }} />
|
<StatsRow
|
||||||
<StatsRow name="Strength" color={Settings.theme.combat} data={{ level: props.member.str, exp: props.member.str_exp }} />
|
name="Hacking"
|
||||||
<StatsRow name="Defense" color={Settings.theme.combat} data={{ level: props.member.def, exp: props.member.def_exp }} />
|
color={Settings.theme.hack}
|
||||||
<StatsRow name="Dexterity" color={Settings.theme.combat} data={{ level: props.member.dex, exp: props.member.dex_exp }} />
|
data={{ level: props.member.hack, exp: props.member.hack_exp }}
|
||||||
<StatsRow name="Agility" color={Settings.theme.combat} data={{ level: props.member.agi, exp: props.member.agi_exp }} />
|
/>
|
||||||
<StatsRow name="Charisma" color={Settings.theme.cha} data={{ level: props.member.cha, exp: props.member.cha_exp }} />
|
<StatsRow
|
||||||
|
name="Strength"
|
||||||
|
color={Settings.theme.combat}
|
||||||
|
data={{ level: props.member.str, exp: props.member.str_exp }}
|
||||||
|
/>
|
||||||
|
<StatsRow
|
||||||
|
name="Defense"
|
||||||
|
color={Settings.theme.combat}
|
||||||
|
data={{ level: props.member.def, exp: props.member.def_exp }}
|
||||||
|
/>
|
||||||
|
<StatsRow
|
||||||
|
name="Dexterity"
|
||||||
|
color={Settings.theme.combat}
|
||||||
|
data={{ level: props.member.dex, exp: props.member.dex_exp }}
|
||||||
|
/>
|
||||||
|
<StatsRow
|
||||||
|
name="Agility"
|
||||||
|
color={Settings.theme.combat}
|
||||||
|
data={{ level: props.member.agi, exp: props.member.agi_exp }}
|
||||||
|
/>
|
||||||
|
<StatsRow
|
||||||
|
name="Charisma"
|
||||||
|
color={Settings.theme.cha}
|
||||||
|
data={{ level: props.member.cha, exp: props.member.cha_exp }}
|
||||||
|
/>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
<Select onChange={onChange} value={currentCategory} sx={{ width: '100%', mb: 1 }}>
|
<Select onChange={onChange} value={currentCategory} sx={{ width: "100%", mb: 1 }}>
|
||||||
{Object.keys(categories).map((k, i) => (
|
{Object.keys(categories).map((k, i) => (
|
||||||
<MenuItem key={i + 1} value={k}>
|
<MenuItem key={i + 1} value={k}>
|
||||||
<Typography variant="h6">{k}</Typography>
|
<Typography variant="h6">{k}</Typography>
|
||||||
@ -197,32 +220,22 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<Box sx={{ width: '100%' }}>
|
<Box sx={{ width: "100%" }}>
|
||||||
{(categories[currentCategory][0] as GangMemberUpgrade[]).length === 0 && (
|
{(categories[currentCategory][0] as GangMemberUpgrade[]).length === 0 && (
|
||||||
<Typography>
|
<Typography>All upgrades owned!</Typography>
|
||||||
All upgrades owned!
|
|
||||||
</Typography>
|
|
||||||
)}
|
)}
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: '1fr 1fr' }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "1fr 1fr" }}>
|
||||||
{(categories[currentCategory][0] as GangMemberUpgrade[]).map((upg) => (
|
{(categories[currentCategory][0] as GangMemberUpgrade[]).map((upg) => (
|
||||||
<UpgradeButton
|
<UpgradeButton key={upg.name} rerender={rerender} member={props.member} upg={upg} />
|
||||||
key={upg.name}
|
|
||||||
rerender={rerender}
|
|
||||||
member={props.member}
|
|
||||||
upg={upg}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
<NextReveal
|
<NextReveal type={categories[currentCategory][1] as UpgradeType} upgrades={props.member.upgrades} />
|
||||||
type={categories[currentCategory][1] as UpgradeType}
|
|
||||||
upgrades={props.member.upgrades}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
</span>
|
</span>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Typography sx={{ mx: 1 }}>Purchased Upgrades: </Typography>
|
<Typography sx={{ mx: 1 }}>Purchased Upgrades: </Typography>
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: 'repeat(4, 1fr)', m: 1 }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "repeat(4, 1fr)", m: 1 }}>
|
||||||
{props.member.upgrades.map((upg: string) => (
|
{props.member.upgrades.map((upg: string) => (
|
||||||
<PurchasedUpgrade key={upg} upgName={upg} />
|
<PurchasedUpgrade key={upg} upgName={upg} />
|
||||||
))}
|
))}
|
||||||
@ -238,13 +251,11 @@ export function EquipmentsSubpage(): React.ReactElement {
|
|||||||
const gang = useGang();
|
const gang = useGang();
|
||||||
const [filter, setFilter] = useState("");
|
const [filter, setFilter] = useState("");
|
||||||
|
|
||||||
|
|
||||||
const handleFilterChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
const handleFilterChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
||||||
setFilter(event.target.value.toLowerCase());
|
setFilter(event.target.value.toLowerCase());
|
||||||
}
|
};
|
||||||
|
|
||||||
const members = gang.members
|
const members = gang.members.filter((member) => member && member.name.toLowerCase().includes(filter));
|
||||||
.filter((member) => member && member.name.toLowerCase().includes(filter));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -265,13 +276,13 @@ export function EquipmentsSubpage(): React.ReactElement {
|
|||||||
autoFocus
|
autoFocus
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: <SearchIcon />,
|
startAdornment: <SearchIcon />,
|
||||||
spellCheck: false
|
spellCheck: false,
|
||||||
}}
|
}}
|
||||||
placeholder="Filter by member name"
|
placeholder="Filter by member name"
|
||||||
sx={{ m: 1, width: '15%' }}
|
sx={{ m: 1, width: "15%" }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: '1fr 1fr', width: '100%' }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "1fr 1fr", width: "100%" }}>
|
||||||
{members.map((member: GangMember) => (
|
{members.map((member: GangMember) => (
|
||||||
<GangMemberUpgradePanel key={member.name} member={member} />
|
<GangMemberUpgradePanel key={member.name} member={member} />
|
||||||
))}
|
))}
|
||||||
|
@ -16,7 +16,7 @@ interface IProps {
|
|||||||
|
|
||||||
export function GangMemberCard(props: IProps): React.ReactElement {
|
export function GangMemberCard(props: IProps): React.ReactElement {
|
||||||
return (
|
return (
|
||||||
<Box component={Paper} sx={{ width: 'auto' }}>
|
<Box component={Paper} sx={{ width: "auto" }}>
|
||||||
<Box sx={{ m: 1 }}>
|
<Box sx={{ m: 1 }}>
|
||||||
<ListItemText primary={<b>{props.member.name}</b>} />
|
<ListItemText primary={<b>{props.member.name}</b>} />
|
||||||
<GangMemberCardContent member={props.member} />
|
<GangMemberCardContent member={props.member} />
|
||||||
|
@ -26,15 +26,17 @@ export function GangMemberCardContent(props: IProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{props.member.canAscend() && (
|
{props.member.canAscend() && (
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', my: 1 }}>
|
<Box sx={{ display: "flex", justifyContent: "space-between", my: 1 }}>
|
||||||
<Button onClick={() => setAscendOpen(true)} style={{ flexGrow: 1, borderRightWidth: 0 }}>Ascend</Button>
|
<Button onClick={() => setAscendOpen(true)} style={{ flexGrow: 1, borderRightWidth: 0 }}>
|
||||||
|
Ascend
|
||||||
|
</Button>
|
||||||
<AscensionModal
|
<AscensionModal
|
||||||
open={ascendOpen}
|
open={ascendOpen}
|
||||||
onClose={() => setAscendOpen(false)}
|
onClose={() => setAscendOpen(false)}
|
||||||
member={props.member}
|
member={props.member}
|
||||||
onAscend={() => setRerender((old) => !old)}
|
onAscend={() => setRerender((old) => !old)}
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => setHelpOpen(true)} style={{ width: 'fit-content', borderLeftWidth: 0 }}>
|
<Button onClick={() => setHelpOpen(true)} style={{ width: "fit-content", borderLeftWidth: 0 }}>
|
||||||
<HelpIcon />
|
<HelpIcon />
|
||||||
</Button>
|
</Button>
|
||||||
<StaticModal open={helpOpen} onClose={() => setHelpOpen(false)}>
|
<StaticModal open={helpOpen} onClose={() => setHelpOpen(false)}>
|
||||||
@ -53,7 +55,7 @@ export function GangMemberCardContent(props: IProps): React.ReactElement {
|
|||||||
</StaticModal>
|
</StaticModal>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: '1fr 1fr', width: '100%', gap: 1 }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "1fr 1fr", width: "100%", gap: 1 }}>
|
||||||
<GangMemberStats member={props.member} />
|
<GangMemberStats member={props.member} />
|
||||||
<TaskSelector onTaskChange={() => setRerender((old) => !old)} member={props.member} />
|
<TaskSelector onTaskChange={() => setRerender((old) => !old)} member={props.member} />
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -20,7 +20,7 @@ export function GangMemberList(): React.ReactElement {
|
|||||||
|
|
||||||
const handleFilterChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
const handleFilterChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
||||||
setFilter(event.target.value.toLowerCase());
|
setFilter(event.target.value.toLowerCase());
|
||||||
}
|
};
|
||||||
|
|
||||||
const members = gang.members
|
const members = gang.members
|
||||||
.filter((member) => member && member.name.toLowerCase().includes(filter))
|
.filter((member) => member && member.name.toLowerCase().includes(filter))
|
||||||
@ -38,23 +38,18 @@ export function GangMemberList(): React.ReactElement {
|
|||||||
autoFocus
|
autoFocus
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: <SearchIcon />,
|
startAdornment: <SearchIcon />,
|
||||||
spellCheck: false
|
spellCheck: false,
|
||||||
}}
|
}}
|
||||||
placeholder="Filter by member name"
|
placeholder="Filter by member name"
|
||||||
sx={{ m: 1, width: '15%' }}
|
sx={{ m: 1, width: "15%" }}
|
||||||
/>
|
/>
|
||||||
<OptionSwitch
|
<OptionSwitch
|
||||||
checked={ascendOnly}
|
checked={ascendOnly}
|
||||||
onChange={(newValue) => (setAscendOnly(newValue))}
|
onChange={(newValue) => setAscendOnly(newValue)}
|
||||||
text="Show only ascendable"
|
text="Show only ascendable"
|
||||||
tooltip={
|
tooltip={<>Filter the members list by whether or not the member can be ascended.</>}
|
||||||
<>
|
|
||||||
Filter the members list by whether or not the member
|
|
||||||
can be ascended.
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Box display="grid" sx={{ gridTemplateColumns: 'repeat(2, 1fr)' }}>
|
<Box display="grid" sx={{ gridTemplateColumns: "repeat(2, 1fr)" }}>
|
||||||
{members.map((member: GangMember) => (
|
{members.map((member: GangMember) => (
|
||||||
<GangMemberCard key={member.name} member={member} />
|
<GangMemberCard key={member.name} member={member} />
|
||||||
))}
|
))}
|
||||||
|
@ -32,7 +32,7 @@ export function GangRoot(): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Gang.Provider value={gang}>
|
<Context.Gang.Provider value={gang}>
|
||||||
<Tabs variant="fullWidth" value={value} onChange={handleChange} sx={{ minWidth: 'fit-content', maxWidth: '45%' }}>
|
<Tabs variant="fullWidth" value={value} onChange={handleChange} sx={{ minWidth: "fit-content", maxWidth: "45%" }}>
|
||||||
<Tab label="Management" />
|
<Tab label="Management" />
|
||||||
<Tab label="Equipment" />
|
<Tab label="Equipment" />
|
||||||
<Tab label="Territory" />
|
<Tab label="Territory" />
|
||||||
|
@ -25,10 +25,10 @@ export function RecruitButton(props: IProps): React.ReactElement {
|
|||||||
const respect = gang.getRespectNeededToRecruitMember();
|
const respect = gang.getRespectNeededToRecruitMember();
|
||||||
return (
|
return (
|
||||||
<Box display="flex" alignItems="center" sx={{ mx: 1 }}>
|
<Box display="flex" alignItems="center" sx={{ mx: 1 }}>
|
||||||
<Button disabled>
|
<Button disabled>Recruit Gang Member</Button>
|
||||||
Recruit Gang Member
|
<Typography sx={{ ml: 1 }}>
|
||||||
</Button>
|
{numeralWrapper.formatRespect(respect)} respect needed to recruit next member
|
||||||
<Typography sx={{ ml: 1 }}>{numeralWrapper.formatRespect(respect)} respect needed to recruit next member</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,9 @@ export function TaskSelector(props: IProps): React.ReactElement {
|
|||||||
const gang = useGang();
|
const gang = useGang();
|
||||||
const [currentTask, setCurrentTask] = useState(props.member.task);
|
const [currentTask, setCurrentTask] = useState(props.member.task);
|
||||||
|
|
||||||
const contextMember = gang.members.find(member => member.name == props.member.name)
|
const contextMember = gang.members.find((member) => member.name == props.member.name);
|
||||||
if (contextMember &&
|
if (contextMember && contextMember.task != currentTask) {
|
||||||
contextMember.task != currentTask
|
setCurrentTask(contextMember.task);
|
||||||
) {
|
|
||||||
setCurrentTask(contextMember.task)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(event: SelectChangeEvent<string>): void {
|
function onChange(event: SelectChangeEvent<string>): void {
|
||||||
@ -39,7 +37,7 @@ export function TaskSelector(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Select onChange={onChange} value={currentTask} sx={{ width: '100%' }}>
|
<Select onChange={onChange} value={currentTask} sx={{ width: "100%" }}>
|
||||||
<MenuItem key={0} value={"Unassigned"}>
|
<MenuItem key={0} value={"Unassigned"}>
|
||||||
Unassigned
|
Unassigned
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -13,9 +13,7 @@ export const TerritoryInfoModal = ({ open, onClose }: IProps): React.ReactElemen
|
|||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={onClose}>
|
<Modal open={open} onClose={onClose}>
|
||||||
<>
|
<>
|
||||||
<Typography variant='h4'>
|
<Typography variant="h4">Clashing</Typography>
|
||||||
Clashing
|
|
||||||
</Typography>
|
|
||||||
<Typography>
|
<Typography>
|
||||||
Every ~20 seconds, your gang has a chance to 'clash' with other gangs. Your chance to win a clash depends on
|
Every ~20 seconds, your gang has a chance to 'clash' with other gangs. Your chance to win a clash depends on
|
||||||
your gang's power, which is listed in the display below. Your gang's power slowly accumulates over time. The
|
your gang's power, which is listed in the display below. Your gang's power slowly accumulates over time. The
|
||||||
@ -29,21 +27,17 @@ export const TerritoryInfoModal = ({ open, onClose }: IProps): React.ReactElemen
|
|||||||
gang.
|
gang.
|
||||||
</Typography>
|
</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography variant='h4'>
|
<Typography variant="h4">Territory</Typography>
|
||||||
Territory
|
|
||||||
</Typography>
|
|
||||||
<Typography>
|
<Typography>
|
||||||
The amount of territory you have affects all aspects of your Gang members' production, including money, respect,
|
The amount of territory you have affects all aspects of your Gang members' production, including money,
|
||||||
and wanted level. It is very beneficial to have high territory control.
|
respect, and wanted level. It is very beneficial to have high territory control.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
To increase your chances of winning territory, assign gang members to "Territory Warfare". This will build your
|
To increase your chances of winning territory, assign gang members to "Territory Warfare". This will build
|
||||||
gang power. Then, enable "Engage in Territory Warfare" to start fighting over territory.
|
your gang power. Then, enable "Engage in Territory Warfare" to start fighting over territory.
|
||||||
</Typography>
|
</Typography>
|
||||||
<br />
|
<br />
|
||||||
<Typography variant='h4'>
|
<Typography variant="h4">Territory Clash Chance</Typography>
|
||||||
Territory Clash Chance
|
|
||||||
</Typography>
|
|
||||||
<Typography>
|
<Typography>
|
||||||
This percentage represents the chance you have of 'clashing' with another gang. If you do not wish to
|
This percentage represents the chance you have of 'clashing' with another gang. If you do not wish to
|
||||||
gain/lose territory, then keep this percentage at 0% by not engaging in territory warfare.
|
gain/lose territory, then keep this percentage at 0% by not engaging in territory warfare.
|
||||||
@ -51,4 +45,4 @@ export const TerritoryInfoModal = ({ open, onClose }: IProps): React.ReactElemen
|
|||||||
</>
|
</>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
@ -3,16 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import {
|
import { Container, Button, Paper, Box, Tooltip, Switch, FormControlLabel, Typography } from "@mui/material";
|
||||||
Container,
|
|
||||||
Button,
|
|
||||||
Paper,
|
|
||||||
Box,
|
|
||||||
Tooltip,
|
|
||||||
Switch,
|
|
||||||
FormControlLabel,
|
|
||||||
Typography
|
|
||||||
} from "@mui/material";
|
|
||||||
import { Help } from "@mui/icons-material";
|
import { Help } from "@mui/icons-material";
|
||||||
|
|
||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
@ -41,35 +32,51 @@ export function TerritorySubpage(): React.ReactElement {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Box component={Paper} sx={{ p: 1, mb: 1 }}>
|
<Box component={Paper} sx={{ p: 1, mb: 1 }}>
|
||||||
<Typography variant="h6" sx={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
{gang.facName} (Your gang)
|
{gang.facName} (Your gang)
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={<Switch
|
control={
|
||||||
|
<Switch
|
||||||
checked={gang.territoryWarfareEngaged}
|
checked={gang.territoryWarfareEngaged}
|
||||||
onChange={(event) => (gang.territoryWarfareEngaged = event.target.checked)}
|
onChange={(event) => (gang.territoryWarfareEngaged = event.target.checked)}
|
||||||
/>}
|
/>
|
||||||
label={<Tooltip
|
}
|
||||||
title={<Typography>
|
label={
|
||||||
|
<Tooltip
|
||||||
|
title={
|
||||||
|
<Typography>
|
||||||
Engaging in Territory Warfare sets your clash chance to 100%. Disengaging will cause your clash chance
|
Engaging in Territory Warfare sets your clash chance to 100%. Disengaging will cause your clash chance
|
||||||
to gradually decrease until it reaches 0%.
|
to gradually decrease until it reaches 0%.
|
||||||
</Typography>}>
|
</Typography>
|
||||||
|
}
|
||||||
|
>
|
||||||
<Typography>Engage in Territory Warfare</Typography>
|
<Typography>Engage in Territory Warfare</Typography>
|
||||||
</Tooltip>} />
|
</Tooltip>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<br />
|
<br />
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={<Switch
|
control={
|
||||||
|
<Switch
|
||||||
checked={gang.notifyMemberDeath}
|
checked={gang.notifyMemberDeath}
|
||||||
onChange={(event) => (gang.notifyMemberDeath = event.target.checked)}
|
onChange={(event) => (gang.notifyMemberDeath = event.target.checked)}
|
||||||
/>}
|
/>
|
||||||
label={<Tooltip
|
}
|
||||||
title={<Typography>
|
label={
|
||||||
If this is enabled, then you will receive a pop-up notifying you whenever one of your Gang Members dies
|
<Tooltip
|
||||||
in a territory clash.
|
title={
|
||||||
</Typography>}>
|
<Typography>
|
||||||
|
If this is enabled, then you will receive a pop-up notifying you whenever one of your Gang Members
|
||||||
|
dies in a territory clash.
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
>
|
||||||
<Typography>Notify about Gang Member Deaths</Typography>
|
<Typography>Notify about Gang Member Deaths</Typography>
|
||||||
</Tooltip>} />
|
</Tooltip>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<Typography>
|
<Typography>
|
||||||
<b>Territory Clash Chance:</b> {numeralWrapper.formatPercentage(gang.territoryClashChance, 3)} <br />
|
<b>Territory Clash Chance:</b> {numeralWrapper.formatPercentage(gang.territoryClashChance, 3)} <br />
|
||||||
@ -77,7 +84,7 @@ export function TerritorySubpage(): React.ReactElement {
|
|||||||
<b>Territory:</b> {formatTerritory(AllGangs[gang.facName].territory)}% <br />
|
<b>Territory:</b> {formatTerritory(AllGangs[gang.facName].territory)}% <br />
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)' }}>
|
<Box sx={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)" }}>
|
||||||
{gangNames.map((name) => (
|
{gangNames.map((name) => (
|
||||||
<OtherGangTerritory key={name} name={name} />
|
<OtherGangTerritory key={name} name={name} />
|
||||||
))}
|
))}
|
||||||
@ -109,7 +116,7 @@ function OtherGangTerritory(props: ITerritoryProps): React.ReactElement {
|
|||||||
const clashVictoryChance = playerPower / (power + playerPower);
|
const clashVictoryChance = playerPower / (power + playerPower);
|
||||||
return (
|
return (
|
||||||
<Box component={Paper} sx={{ p: 1 }}>
|
<Box component={Paper} sx={{ p: 1 }}>
|
||||||
<Typography variant="h6" sx={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
|
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
{props.name}
|
{props.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -49,7 +49,8 @@ export function calculatePercentMoneyHacked(server: Server, player: IPlayer): nu
|
|||||||
|
|
||||||
const difficultyMult = (100 - server.hackDifficulty) / 100;
|
const difficultyMult = (100 - server.hackDifficulty) / 100;
|
||||||
const skillMult = (player.hacking - (server.requiredHackingSkill - 1)) / player.hacking;
|
const skillMult = (player.hacking - (server.requiredHackingSkill - 1)) / player.hacking;
|
||||||
const percentMoneyHacked = (difficultyMult * skillMult * player.hacking_money_mult * BitNodeMultipliers.ScriptHackMoney) / balanceFactor;
|
const percentMoneyHacked =
|
||||||
|
(difficultyMult * skillMult * player.hacking_money_mult * BitNodeMultipliers.ScriptHackMoney) / balanceFactor;
|
||||||
if (percentMoneyHacked < 0) {
|
if (percentMoneyHacked < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,13 @@ import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"
|
|||||||
import { ObjectValidator, minMax } from "../utils/Validator";
|
import { ObjectValidator, minMax } from "../utils/Validator";
|
||||||
|
|
||||||
export class HacknetNode implements IHacknetNode {
|
export class HacknetNode implements IHacknetNode {
|
||||||
|
|
||||||
static validationData: ObjectValidator<HacknetNode> = {
|
static validationData: ObjectValidator<HacknetNode> = {
|
||||||
cores: minMax(1, 1, HacknetNodeConstants.MaxCores),
|
cores: minMax(1, 1, HacknetNodeConstants.MaxCores),
|
||||||
level: minMax(1, 1, HacknetNodeConstants.MaxLevel),
|
level: minMax(1, 1, HacknetNodeConstants.MaxLevel),
|
||||||
ram: minMax(1, 1, HacknetNodeConstants.MaxRam),
|
ram: minMax(1, 1, HacknetNodeConstants.MaxRam),
|
||||||
onlineTimeSeconds: minMax(0, 0, Infinity),
|
onlineTimeSeconds: minMax(0, 0, Infinity),
|
||||||
totalMoneyGenerated: minMax(0, 0, Infinity)
|
totalMoneyGenerated: minMax(0, 0, Infinity),
|
||||||
}
|
};
|
||||||
|
|
||||||
// Node's number of cores
|
// Node's number of cores
|
||||||
cores = 1;
|
cores = 1;
|
||||||
|
@ -137,7 +137,7 @@ export function HacknetRoot(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
{hasHacknetServers(props.player) && <Button onClick={() => setOpen(true)}>Spend Hashes on Upgrades</Button>}
|
{hasHacknetServers(props.player) && <Button onClick={() => setOpen(true)}>Spend Hashes on Upgrades</Button>}
|
||||||
|
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content', gridTemplateColumns: 'repeat(3, 1fr)' }}>{nodes}</Box>
|
<Box sx={{ display: "grid", width: "fit-content", gridTemplateColumns: "repeat(3, 1fr)" }}>{nodes}</Box>
|
||||||
<HashUpgradeModal open={open} onClose={() => setOpen(false)} />
|
<HashUpgradeModal open={open} onClose={() => setOpen(false)} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { CityName } from './../Locations/data/CityNames';
|
import { CityName } from "./../Locations/data/CityNames";
|
||||||
import { Literature } from "./Literature";
|
import { Literature } from "./Literature";
|
||||||
import { LiteratureNames } from "./data/LiteratureNames";
|
import { LiteratureNames } from "./data/LiteratureNames";
|
||||||
import { IMap } from "../types";
|
import { IMap } from "../types";
|
||||||
|
@ -34,7 +34,7 @@ export function CasinoLocation(props: IProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{game === GameType.None && (
|
{game === GameType.None && (
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>
|
||||||
<Button onClick={() => updateGame(GameType.Coin)}>Play coin flip</Button>
|
<Button onClick={() => updateGame(GameType.Coin)}>Play coin flip</Button>
|
||||||
<Button onClick={() => updateGame(GameType.Slots)}>Play slots</Button>
|
<Button onClick={() => updateGame(GameType.Slots)}>Play slots</Button>
|
||||||
<Button onClick={() => updateGame(GameType.Roulette)}>Play roulette</Button>
|
<Button onClick={() => updateGame(GameType.Roulette)}>Play roulette</Button>
|
||||||
|
@ -228,9 +228,9 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
|||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>
|
||||||
{isEmployedHere && (
|
{isEmployedHere && (
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
|
<Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
|
||||||
<Button onClick={work}>Work</Button>
|
<Button onClick={work}>Work</Button>
|
||||||
<Button onClick={() => setQuitOpen(true)}>Quit</Button>
|
<Button onClick={() => setQuitOpen(true)}>Quit</Button>
|
||||||
<QuitJobModal
|
<QuitJobModal
|
||||||
@ -241,9 +241,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
|||||||
onClose={() => setQuitOpen(false)}
|
onClose={() => setQuitOpen(false)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)}
|
||||||
|
|
||||||
}
|
|
||||||
{company.hasAgentPositions() && (
|
{company.hasAgentPositions() && (
|
||||||
<ApplyToJobButton
|
<ApplyToJobButton
|
||||||
company={company}
|
company={company}
|
||||||
|
@ -31,11 +31,7 @@ export function CoresButton(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip title={<MathJaxWrapper>{`\\(\\large{cost = 10^9 \\cdot 7.5 ^{\\text{cores}}}\\)`}</MathJaxWrapper>}>
|
||||||
title={
|
|
||||||
<MathJaxWrapper>{`\\(\\large{cost = 10^9 \\cdot 7.5 ^{\\text{cores}}}\\)`}</MathJaxWrapper>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span>
|
<span>
|
||||||
<br />
|
<br />
|
||||||
<Typography>
|
<Typography>
|
||||||
|
@ -96,8 +96,13 @@ export function GenericLocation({ loc }: IProps): React.ReactElement {
|
|||||||
<Typography variant="h4" sx={{ mt: 1 }}>
|
<Typography variant="h4" sx={{ mt: 1 }}>
|
||||||
{backdoorInstalled && !Settings.DisableTextEffects ? (
|
{backdoorInstalled && !Settings.DisableTextEffects ? (
|
||||||
<Tooltip title={`Backdoor installed on ${loc.name}.`}>
|
<Tooltip title={`Backdoor installed on ${loc.name}.`}>
|
||||||
<span><CorruptableText content={loc.name} /></span>
|
<span>
|
||||||
</Tooltip>) : loc.name}
|
<CorruptableText content={loc.name} />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
loc.name
|
||||||
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{locContent}
|
{locContent}
|
||||||
</>
|
</>
|
||||||
|
@ -59,7 +59,7 @@ export function GymLocation(props: IProps): React.ReactElement {
|
|||||||
const cost = CONSTANTS.ClassGymBaseCost * calculateCost();
|
const cost = CONSTANTS.ClassGymBaseCost * calculateCost();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>
|
||||||
<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>
|
||||||
|
@ -11,6 +11,7 @@ import { Money } from "../../ui/React/Money";
|
|||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
|
|
||||||
import { MathJaxWrapper } from "../../MathJaxWrapper";
|
import { MathJaxWrapper } from "../../MathJaxWrapper";
|
||||||
|
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
p: IPlayer;
|
p: IPlayer;
|
||||||
@ -30,10 +31,12 @@ export function RamButton(props: IProps): React.ReactElement {
|
|||||||
props.rerender();
|
props.rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bnMult = BitNodeMultipliers.HomeComputerRamCost === 1 ? "" : `\\cdot ${BitNodeMultipliers.HomeComputerRamCost}`;
|
||||||
|
console.log(BitNodeMultipliers.HomeComputerRamCost);
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<MathJaxWrapper>{`\\(\\large{cost = 3.2 \\cdot 10^3 \\cdot 1.58^{log_2{(ram)}}}\\)`}</MathJaxWrapper>
|
<MathJaxWrapper>{`\\(\\large{cost = ram \\cdot 3.2 \\cdot 10^4 \\cdot 1.58^{log_2{(ram)}}} ${bnMult}\\)`}</MathJaxWrapper>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
|
@ -114,7 +114,7 @@ export function SlumsLocation(): React.ReactElement {
|
|||||||
const heistChance = Crimes.Heist.successRate(player);
|
const heistChance = Crimes.Heist.successRate(player);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>
|
||||||
<Tooltip title={<>Attempt to shoplift from a low-end retailer</>}>
|
<Tooltip title={<>Attempt to shoplift from a low-end retailer</>}>
|
||||||
<Button onClick={shoplift}>
|
<Button onClick={shoplift}>
|
||||||
Shoplift ({numeralWrapper.formatPercentage(shopliftChance)} chance of success)
|
Shoplift ({numeralWrapper.formatPercentage(shopliftChance)} chance of success)
|
||||||
|
@ -155,7 +155,11 @@ export function SpecialLocation(props: IProps): React.ReactElement {
|
|||||||
if (!player.canAccessGrafting()) {
|
if (!player.canAccessGrafting()) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
return <Button onClick={handleGrafting} sx={{ my: 5 }}>Enter the secret lab</Button>;
|
return (
|
||||||
|
<Button onClick={handleGrafting} sx={{ my: 5 }}>
|
||||||
|
Enter the secret lab
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCotMG(): void {
|
function handleCotMG(): void {
|
||||||
|
@ -70,9 +70,7 @@ export function TechVendorLocation(props: IProps): React.ReactElement {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>{purchaseServerButtons}</Box>
|
||||||
{purchaseServerButtons}
|
|
||||||
</Box>
|
|
||||||
<br />
|
<br />
|
||||||
<Typography>
|
<Typography>
|
||||||
<i>"You can order bigger servers via scripts. We don't take custom orders in person."</i>
|
<i>"You can order bigger servers via scripts. We don't take custom orders in person."</i>
|
||||||
|
@ -75,7 +75,7 @@ export function UniversityLocation(props: IProps): React.ReactElement {
|
|||||||
const earnCharismaExpTooltip = `Gain charisma experience!`;
|
const earnCharismaExpTooltip = `Gain charisma experience!`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'grid', width: 'fit-content' }}>
|
<Box sx={{ display: "grid", width: "fit-content" }}>
|
||||||
<Tooltip title={earnHackingExpTooltip}>
|
<Tooltip title={earnHackingExpTooltip}>
|
||||||
<Button onClick={study}>Study Computer Science (free)</Button>
|
<Button onClick={study}>Study Computer Science (free)</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import { MathJax, MathJaxContext } from "better-react-mathjax";
|
import { MathJax, MathJaxContext } from "better-react-mathjax";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -10,5 +10,5 @@ export function MathJaxWrapper({ children }: IProps): React.ReactElement {
|
|||||||
<MathJaxContext version={3} src={"dist/ext/MathJax-3.2.0/es5/tex-chtml.js"}>
|
<MathJaxContext version={3} src={"dist/ext/MathJax-3.2.0/es5/tex-chtml.js"}>
|
||||||
<MathJax>{children}</MathJax>
|
<MathJax>{children}</MathJax>
|
||||||
</MathJaxContext>
|
</MathJaxContext>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ export const RamCosts: IMap<any> = {
|
|||||||
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
|
||||||
purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
|
||||||
|
@ -119,7 +119,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.hostname}`);
|
console.warn(`WorkerScript detected NaN for threadcount for ${workerScript.name} on ${workerScript.hostname}`);
|
||||||
threads = 1;
|
threads = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
workerScript.dynamicRamUsage += ramCost;
|
workerScript.dynamicRamUsage += ramCost;
|
||||||
if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
|
if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
|
||||||
throw makeRuntimeRejectMsg(
|
throw makeRuntimeRejectMsg(
|
||||||
@ -521,8 +520,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
sprintf: sprintf,
|
sprintf: sprintf,
|
||||||
vsprintf: vsprintf,
|
vsprintf: vsprintf,
|
||||||
scan: function (_hostname: unknown = workerScript.hostname): string[] {
|
scan: function (_hostname: unknown = workerScript.hostname): string[] {
|
||||||
const hostname = helper.string("scan", "hostname", _hostname);
|
|
||||||
updateDynamicRam("scan", getRamCost(Player, "scan"));
|
updateDynamicRam("scan", getRamCost(Player, "scan"));
|
||||||
|
const hostname = helper.string("scan", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "scan");
|
const server = safeGetServer(hostname, "scan");
|
||||||
const out = [];
|
const out = [];
|
||||||
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
for (let i = 0; i < server.serversOnNetwork.length; i++) {
|
||||||
@ -536,14 +535,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
hack: function (_hostname: unknown, { threads: requestedThreads, stock }: BasicHGWOptions = {}): Promise<number> {
|
hack: function (_hostname: unknown, { threads: requestedThreads, stock }: BasicHGWOptions = {}): Promise<number> {
|
||||||
const hostname = helper.string("hack", "hostname", _hostname);
|
|
||||||
updateDynamicRam("hack", getRamCost(Player, "hack"));
|
updateDynamicRam("hack", getRamCost(Player, "hack"));
|
||||||
|
const hostname = helper.string("hack", "hostname", _hostname);
|
||||||
return hack(hostname, false, { threads: requestedThreads, stock: stock });
|
return hack(hostname, false, { threads: requestedThreads, stock: stock });
|
||||||
},
|
},
|
||||||
hackAnalyzeThreads: function (_hostname: unknown, _hackAmount: unknown): number {
|
hackAnalyzeThreads: function (_hostname: unknown, _hackAmount: unknown): number {
|
||||||
|
updateDynamicRam("hackAnalyzeThreads", getRamCost(Player, "hackAnalyzeThreads"));
|
||||||
const hostname = helper.string("hackAnalyzeThreads", "hostname", _hostname);
|
const hostname = helper.string("hackAnalyzeThreads", "hostname", _hostname);
|
||||||
const hackAmount = helper.number("hackAnalyzeThreads", "hackAmount", _hackAmount);
|
const hackAmount = helper.number("hackAnalyzeThreads", "hackAmount", _hackAmount);
|
||||||
updateDynamicRam("hackAnalyzeThreads", getRamCost(Player, "hackAnalyzeThreads"));
|
|
||||||
|
|
||||||
// Check argument validity
|
// Check argument validity
|
||||||
const server = safeGetServer(hostname, "hackAnalyzeThreads");
|
const server = safeGetServer(hostname, "hackAnalyzeThreads");
|
||||||
@ -573,8 +572,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return hackAmount / Math.floor(server.moneyAvailable * percentHacked);
|
return hackAmount / Math.floor(server.moneyAvailable * percentHacked);
|
||||||
},
|
},
|
||||||
hackAnalyze: function (_hostname: unknown): number {
|
hackAnalyze: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("hackAnalyze", "hostname", _hostname);
|
|
||||||
updateDynamicRam("hackAnalyze", getRamCost(Player, "hackAnalyze"));
|
updateDynamicRam("hackAnalyze", getRamCost(Player, "hackAnalyze"));
|
||||||
|
const hostname = helper.string("hackAnalyze", "hostname", _hostname);
|
||||||
|
|
||||||
const server = safeGetServer(hostname, "hackAnalyze");
|
const server = safeGetServer(hostname, "hackAnalyze");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
@ -585,13 +584,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return calculatePercentMoneyHacked(server, Player);
|
return calculatePercentMoneyHacked(server, Player);
|
||||||
},
|
},
|
||||||
hackAnalyzeSecurity: function (_threads: unknown): number {
|
hackAnalyzeSecurity: function (_threads: unknown): number {
|
||||||
const threads = helper.number("hackAnalyzeSecurity", "threads", _threads);
|
|
||||||
updateDynamicRam("hackAnalyzeSecurity", getRamCost(Player, "hackAnalyzeSecurity"));
|
updateDynamicRam("hackAnalyzeSecurity", getRamCost(Player, "hackAnalyzeSecurity"));
|
||||||
|
const threads = helper.number("hackAnalyzeSecurity", "threads", _threads);
|
||||||
return CONSTANTS.ServerFortifyAmount * threads;
|
return CONSTANTS.ServerFortifyAmount * threads;
|
||||||
},
|
},
|
||||||
hackAnalyzeChance: function (_hostname: unknown): number {
|
hackAnalyzeChance: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("hackAnalyzeChance", "hostname", _hostname);
|
|
||||||
updateDynamicRam("hackAnalyzeChance", getRamCost(Player, "hackAnalyzeChance"));
|
updateDynamicRam("hackAnalyzeChance", getRamCost(Player, "hackAnalyzeChance"));
|
||||||
|
const hostname = helper.string("hackAnalyzeChance", "hostname", _hostname);
|
||||||
|
|
||||||
const server = safeGetServer(hostname, "hackAnalyzeChance");
|
const server = safeGetServer(hostname, "hackAnalyzeChance");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
@ -601,32 +600,32 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
return calculateHackingChance(server, Player);
|
return calculateHackingChance(server, Player);
|
||||||
},
|
},
|
||||||
sleep: async function (_time: unknown = 0): Promise<void> {
|
sleep: async function (_time: unknown = 0): Promise<true> {
|
||||||
const time = helper.number("sleep", "time", _time);
|
|
||||||
updateDynamicRam("sleep", getRamCost(Player, "sleep"));
|
updateDynamicRam("sleep", getRamCost(Player, "sleep"));
|
||||||
|
const time = helper.number("sleep", "time", _time);
|
||||||
if (time === undefined) {
|
if (time === undefined) {
|
||||||
throw makeRuntimeErrorMsg("sleep", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("sleep", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`);
|
workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`);
|
||||||
return netscriptDelay(time, workerScript).then(function () {
|
return netscriptDelay(time, workerScript).then(function () {
|
||||||
return Promise.resolve();
|
return Promise.resolve(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
asleep: function (_time: unknown = 0): Promise<void> {
|
asleep: function (_time: unknown = 0): Promise<true> {
|
||||||
const time = helper.number("asleep", "time", _time);
|
|
||||||
updateDynamicRam("asleep", getRamCost(Player, "asleep"));
|
updateDynamicRam("asleep", getRamCost(Player, "asleep"));
|
||||||
|
const time = helper.number("asleep", "time", _time);
|
||||||
if (time === undefined) {
|
if (time === undefined) {
|
||||||
throw makeRuntimeErrorMsg("asleep", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("asleep", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`);
|
workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`);
|
||||||
return new Promise((resolve) => setTimeout(resolve, time));
|
return new Promise((resolve) => setTimeout(() => resolve(true), time));
|
||||||
},
|
},
|
||||||
grow: async function (
|
grow: async function (
|
||||||
_hostname: unknown,
|
_hostname: unknown,
|
||||||
{ threads: requestedThreads, stock }: BasicHGWOptions = {},
|
{ threads: requestedThreads, stock }: BasicHGWOptions = {},
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const hostname = helper.string("grow", "hostname", _hostname);
|
|
||||||
updateDynamicRam("grow", getRamCost(Player, "grow"));
|
updateDynamicRam("grow", getRamCost(Player, "grow"));
|
||||||
|
const hostname = helper.string("grow", "hostname", _hostname);
|
||||||
const threads = resolveNetscriptRequestedThreads(
|
const threads = resolveNetscriptRequestedThreads(
|
||||||
workerScript,
|
workerScript,
|
||||||
"grow",
|
"grow",
|
||||||
@ -685,10 +684,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
growthAnalyze: function (_hostname: unknown, _growth: unknown, _cores: unknown = 1): number {
|
growthAnalyze: function (_hostname: unknown, _growth: unknown, _cores: unknown = 1): number {
|
||||||
|
updateDynamicRam("growthAnalyze", getRamCost(Player, "growthAnalyze"));
|
||||||
const hostname = helper.string("growthAnalyze", "hostname", _hostname);
|
const hostname = helper.string("growthAnalyze", "hostname", _hostname);
|
||||||
const growth = helper.number("growthAnalyze", "growth", _growth);
|
const growth = helper.number("growthAnalyze", "growth", _growth);
|
||||||
const cores = helper.number("growthAnalyze", "cores", _cores);
|
const cores = helper.number("growthAnalyze", "cores", _cores);
|
||||||
updateDynamicRam("growthAnalyze", getRamCost(Player, "growthAnalyze"));
|
|
||||||
|
|
||||||
// Check argument validity
|
// Check argument validity
|
||||||
const server = safeGetServer(hostname, "growthAnalyze");
|
const server = safeGetServer(hostname, "growthAnalyze");
|
||||||
@ -703,13 +702,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return numCycleForGrowth(server, Number(growth), Player, cores);
|
return numCycleForGrowth(server, Number(growth), Player, cores);
|
||||||
},
|
},
|
||||||
growthAnalyzeSecurity: function (_threads: unknown): number {
|
growthAnalyzeSecurity: function (_threads: unknown): number {
|
||||||
const threads = helper.number("growthAnalyzeSecurity", "threads", _threads);
|
|
||||||
updateDynamicRam("growthAnalyzeSecurity", getRamCost(Player, "growthAnalyzeSecurity"));
|
updateDynamicRam("growthAnalyzeSecurity", getRamCost(Player, "growthAnalyzeSecurity"));
|
||||||
|
const threads = helper.number("growthAnalyzeSecurity", "threads", _threads);
|
||||||
return 2 * CONSTANTS.ServerFortifyAmount * threads;
|
return 2 * CONSTANTS.ServerFortifyAmount * threads;
|
||||||
},
|
},
|
||||||
weaken: async function (_hostname: unknown, { threads: requestedThreads }: BasicHGWOptions = {}): Promise<number> {
|
weaken: async function (_hostname: unknown, { threads: requestedThreads }: BasicHGWOptions = {}): Promise<number> {
|
||||||
const hostname = helper.string("weaken", "hostname", _hostname);
|
|
||||||
updateDynamicRam("weaken", getRamCost(Player, "weaken"));
|
updateDynamicRam("weaken", getRamCost(Player, "weaken"));
|
||||||
|
const hostname = helper.string("weaken", "hostname", _hostname);
|
||||||
const threads = resolveNetscriptRequestedThreads(
|
const threads = resolveNetscriptRequestedThreads(
|
||||||
workerScript,
|
workerScript,
|
||||||
"weaken",
|
"weaken",
|
||||||
@ -762,9 +761,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
weakenAnalyze: function (_threads: unknown, _cores: unknown = 1): number {
|
weakenAnalyze: function (_threads: unknown, _cores: unknown = 1): number {
|
||||||
|
updateDynamicRam("weakenAnalyze", getRamCost(Player, "weakenAnalyze"));
|
||||||
const threads = helper.number("weakenAnalyze", "threads", _threads);
|
const threads = helper.number("weakenAnalyze", "threads", _threads);
|
||||||
const cores = helper.number("weakenAnalyze", "cores", _cores);
|
const cores = helper.number("weakenAnalyze", "cores", _cores);
|
||||||
updateDynamicRam("weakenAnalyze", getRamCost(Player, "weakenAnalyze"));
|
|
||||||
const coreBonus = 1 + (cores - 1) / 16;
|
const coreBonus = 1 + (cores - 1) / 16;
|
||||||
return CONSTANTS.ServerWeakenAmount * threads * coreBonus * BitNodeMultipliers.ServerWeakenRate;
|
return CONSTANTS.ServerWeakenAmount * threads * coreBonus * BitNodeMultipliers.ServerWeakenRate;
|
||||||
},
|
},
|
||||||
@ -789,8 +788,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workerScript.print(argsToString(args));
|
workerScript.print(argsToString(args));
|
||||||
},
|
},
|
||||||
printf: function (_format: unknown, ...args: any[]): void {
|
printf: function (_format: unknown, ...args: any[]): void {
|
||||||
const format = helper.string("printf", "format", _format);
|
|
||||||
updateDynamicRam("printf", getRamCost(Player, "printf"));
|
updateDynamicRam("printf", getRamCost(Player, "printf"));
|
||||||
|
const format = helper.string("printf", "format", _format);
|
||||||
if (typeof format !== "string") {
|
if (typeof format !== "string") {
|
||||||
throw makeRuntimeErrorMsg("printf", "First argument must be string for the format.");
|
throw makeRuntimeErrorMsg("printf", "First argument must be string for the format.");
|
||||||
}
|
}
|
||||||
@ -821,8 +820,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||||
},
|
},
|
||||||
tprintf: function (_format: unknown, ...args: any[]): void {
|
tprintf: function (_format: unknown, ...args: any[]): void {
|
||||||
const format = helper.string("printf", "format", _format);
|
|
||||||
updateDynamicRam("tprintf", getRamCost(Player, "tprintf"));
|
updateDynamicRam("tprintf", getRamCost(Player, "tprintf"));
|
||||||
|
const format = helper.string("printf", "format", _format);
|
||||||
if (typeof format !== "string") {
|
if (typeof format !== "string") {
|
||||||
throw makeRuntimeErrorMsg("tprintf", "First argument must be string for the format.");
|
throw makeRuntimeErrorMsg("tprintf", "First argument must be string for the format.");
|
||||||
}
|
}
|
||||||
@ -851,8 +850,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workerScript.scriptRef.clearLog();
|
workerScript.scriptRef.clearLog();
|
||||||
},
|
},
|
||||||
disableLog: function (_fn: unknown): void {
|
disableLog: function (_fn: unknown): void {
|
||||||
const fn = helper.string("disableLog", "fn", _fn);
|
|
||||||
updateDynamicRam("disableLog", getRamCost(Player, "disableLog"));
|
updateDynamicRam("disableLog", getRamCost(Player, "disableLog"));
|
||||||
|
const fn = helper.string("disableLog", "fn", _fn);
|
||||||
if (fn === "ALL") {
|
if (fn === "ALL") {
|
||||||
for (const fn of Object.keys(possibleLogs)) {
|
for (const fn of Object.keys(possibleLogs)) {
|
||||||
workerScript.disableLogs[fn] = true;
|
workerScript.disableLogs[fn] = true;
|
||||||
@ -866,8 +865,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
enableLog: function (_fn: unknown): void {
|
enableLog: function (_fn: unknown): void {
|
||||||
const fn = helper.string("enableLog", "fn", _fn);
|
|
||||||
updateDynamicRam("enableLog", getRamCost(Player, "enableLog"));
|
updateDynamicRam("enableLog", getRamCost(Player, "enableLog"));
|
||||||
|
const fn = helper.string("enableLog", "fn", _fn);
|
||||||
if (fn === "ALL") {
|
if (fn === "ALL") {
|
||||||
for (const fn of Object.keys(possibleLogs)) {
|
for (const fn of Object.keys(possibleLogs)) {
|
||||||
delete workerScript.disableLogs[fn];
|
delete workerScript.disableLogs[fn];
|
||||||
@ -880,8 +879,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workerScript.log("enableLog", () => `Enabled logging for ${fn}`);
|
workerScript.log("enableLog", () => `Enabled logging for ${fn}`);
|
||||||
},
|
},
|
||||||
isLogEnabled: function (_fn: unknown): boolean {
|
isLogEnabled: function (_fn: unknown): boolean {
|
||||||
const fn = helper.string("isLogEnabled", "fn", _fn);
|
|
||||||
updateDynamicRam("isLogEnabled", getRamCost(Player, "isLogEnabled"));
|
updateDynamicRam("isLogEnabled", getRamCost(Player, "isLogEnabled"));
|
||||||
|
const fn = helper.string("isLogEnabled", "fn", _fn);
|
||||||
if (possibleLogs[fn] === undefined) {
|
if (possibleLogs[fn] === undefined) {
|
||||||
throw makeRuntimeErrorMsg("isLogEnabled", `Invalid argument: ${fn}.`);
|
throw makeRuntimeErrorMsg("isLogEnabled", `Invalid argument: ${fn}.`);
|
||||||
}
|
}
|
||||||
@ -915,8 +914,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
LogBoxEvents.emit(runningScriptObj);
|
LogBoxEvents.emit(runningScriptObj);
|
||||||
},
|
},
|
||||||
nuke: function (_hostname: unknown): boolean {
|
nuke: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("tail", "hostname", _hostname);
|
|
||||||
updateDynamicRam("nuke", getRamCost(Player, "nuke"));
|
updateDynamicRam("nuke", getRamCost(Player, "nuke"));
|
||||||
|
const hostname = helper.string("tail", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("nuke", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("nuke", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
@ -940,8 +939,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
brutessh: function (_hostname: unknown): boolean {
|
brutessh: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("brutessh", "hostname", _hostname);
|
|
||||||
updateDynamicRam("brutessh", getRamCost(Player, "brutessh"));
|
updateDynamicRam("brutessh", getRamCost(Player, "brutessh"));
|
||||||
|
const hostname = helper.string("brutessh", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("brutessh", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("brutessh", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
@ -963,8 +962,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
ftpcrack: function (_hostname: unknown): boolean {
|
ftpcrack: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("ftpcrack", "hostname", _hostname);
|
|
||||||
updateDynamicRam("ftpcrack", getRamCost(Player, "ftpcrack"));
|
updateDynamicRam("ftpcrack", getRamCost(Player, "ftpcrack"));
|
||||||
|
const hostname = helper.string("ftpcrack", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("ftpcrack", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("ftpcrack", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
@ -986,8 +985,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
relaysmtp: function (_hostname: unknown): boolean {
|
relaysmtp: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("relaysmtp", "hostname", _hostname);
|
|
||||||
updateDynamicRam("relaysmtp", getRamCost(Player, "relaysmtp"));
|
updateDynamicRam("relaysmtp", getRamCost(Player, "relaysmtp"));
|
||||||
|
const hostname = helper.string("relaysmtp", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("relaysmtp", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("relaysmtp", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
@ -1009,8 +1008,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
httpworm: function (_hostname: unknown): boolean {
|
httpworm: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("httpworm", "hostname", _hostname);
|
|
||||||
updateDynamicRam("httpworm", getRamCost(Player, "httpworm"));
|
updateDynamicRam("httpworm", getRamCost(Player, "httpworm"));
|
||||||
|
const hostname = helper.string("httpworm", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("httpworm", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("httpworm", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
@ -1032,8 +1031,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
sqlinject: function (_hostname: unknown): boolean {
|
sqlinject: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("sqlinject", "hostname", _hostname);
|
|
||||||
updateDynamicRam("sqlinject", getRamCost(Player, "sqlinject"));
|
updateDynamicRam("sqlinject", getRamCost(Player, "sqlinject"));
|
||||||
|
const hostname = helper.string("sqlinject", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("sqlinject", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("sqlinject", "Takes 1 argument.");
|
||||||
}
|
}
|
||||||
@ -1055,9 +1054,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
run: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
run: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
||||||
|
updateDynamicRam("run", getRamCost(Player, "run"));
|
||||||
const scriptname = helper.string("run", "scriptname", _scriptname);
|
const scriptname = helper.string("run", "scriptname", _scriptname);
|
||||||
const threads = helper.number("run", "threads", _threads);
|
const threads = helper.number("run", "threads", _threads);
|
||||||
updateDynamicRam("run", getRamCost(Player, "run"));
|
|
||||||
if (scriptname === undefined) {
|
if (scriptname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("run", "Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
|
throw makeRuntimeErrorMsg("run", "Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
|
||||||
}
|
}
|
||||||
@ -1072,10 +1071,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return runScriptFromScript(Player, "run", scriptServer, scriptname, args, workerScript, threads);
|
return runScriptFromScript(Player, "run", scriptServer, scriptname, args, workerScript, threads);
|
||||||
},
|
},
|
||||||
exec: function (_scriptname: unknown, _hostname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
exec: function (_scriptname: unknown, _hostname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
||||||
|
updateDynamicRam("exec", getRamCost(Player, "exec"));
|
||||||
const scriptname = helper.string("exec", "scriptname", _scriptname);
|
const scriptname = helper.string("exec", "scriptname", _scriptname);
|
||||||
const hostname = helper.string("exec", "hostname", _hostname);
|
const hostname = helper.string("exec", "hostname", _hostname);
|
||||||
const threads = helper.number("exec", "threads", _threads);
|
const threads = helper.number("exec", "threads", _threads);
|
||||||
updateDynamicRam("exec", getRamCost(Player, "exec"));
|
|
||||||
if (scriptname === undefined || hostname === undefined) {
|
if (scriptname === undefined || hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
|
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
|
||||||
}
|
}
|
||||||
@ -1086,9 +1085,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return runScriptFromScript(Player, "exec", server, scriptname, args, workerScript, threads);
|
return runScriptFromScript(Player, "exec", server, scriptname, args, workerScript, threads);
|
||||||
},
|
},
|
||||||
spawn: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): void {
|
spawn: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): void {
|
||||||
|
updateDynamicRam("spawn", getRamCost(Player, "spawn"));
|
||||||
const scriptname = helper.string("spawn", "scriptname", _scriptname);
|
const scriptname = helper.string("spawn", "scriptname", _scriptname);
|
||||||
const threads = helper.number("spawn", "threads", _threads);
|
const threads = helper.number("spawn", "threads", _threads);
|
||||||
updateDynamicRam("spawn", getRamCost(Player, "spawn"));
|
|
||||||
if (!scriptname || !threads) {
|
if (!scriptname || !threads) {
|
||||||
throw makeRuntimeErrorMsg("spawn", "Usage: spawn(scriptname, threads)");
|
throw makeRuntimeErrorMsg("spawn", "Usage: spawn(scriptname, threads)");
|
||||||
}
|
}
|
||||||
@ -1160,8 +1159,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
killall: function (_hostname: unknown = workerScript.hostname): boolean {
|
killall: function (_hostname: unknown = workerScript.hostname): boolean {
|
||||||
const hostname = helper.string("killall", "hostname", _hostname);
|
|
||||||
updateDynamicRam("killall", getRamCost(Player, "killall"));
|
updateDynamicRam("killall", getRamCost(Player, "killall"));
|
||||||
|
const hostname = helper.string("killall", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
@ -1188,8 +1187,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
scp: async function (scriptname: any, _hostname1: unknown, hostname2?: any): Promise<boolean> {
|
scp: async function (scriptname: any, _hostname1: unknown, hostname2?: any): Promise<boolean> {
|
||||||
const hostname1 = helper.string("scp", "hostname1", _hostname1);
|
|
||||||
updateDynamicRam("scp", getRamCost(Player, "scp"));
|
updateDynamicRam("scp", getRamCost(Player, "scp"));
|
||||||
|
const hostname1 = helper.string("scp", "hostname1", _hostname1);
|
||||||
if (arguments.length !== 2 && arguments.length !== 3) {
|
if (arguments.length !== 2 && arguments.length !== 3) {
|
||||||
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
||||||
}
|
}
|
||||||
@ -1346,9 +1345,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
ls: function (_hostname: unknown, _grep: unknown = ""): string[] {
|
ls: function (_hostname: unknown, _grep: unknown = ""): string[] {
|
||||||
|
updateDynamicRam("ls", getRamCost(Player, "ls"));
|
||||||
const hostname = helper.string("ls", "hostname", _hostname);
|
const hostname = helper.string("ls", "hostname", _hostname);
|
||||||
const grep = helper.string("ls", "grep", _grep);
|
const grep = helper.string("ls", "grep", _grep);
|
||||||
updateDynamicRam("ls", getRamCost(Player, "ls"));
|
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("ls", "Usage: ls(hostname/ip, [grep filter])");
|
throw makeRuntimeErrorMsg("ls", "Usage: ls(hostname/ip, [grep filter])");
|
||||||
}
|
}
|
||||||
@ -1415,8 +1414,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return allFiles;
|
return allFiles;
|
||||||
},
|
},
|
||||||
ps: function (_hostname: unknown = workerScript.hostname): ProcessInfo[] {
|
ps: function (_hostname: unknown = workerScript.hostname): ProcessInfo[] {
|
||||||
const hostname = helper.string("ps", "hostname", _hostname);
|
|
||||||
updateDynamicRam("ps", getRamCost(Player, "ps"));
|
updateDynamicRam("ps", getRamCost(Player, "ps"));
|
||||||
|
const hostname = helper.string("ps", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "ps");
|
const server = safeGetServer(hostname, "ps");
|
||||||
const processes = [];
|
const processes = [];
|
||||||
for (const script of server.runningScripts) {
|
for (const script of server.runningScripts) {
|
||||||
@ -1430,8 +1429,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return processes;
|
return processes;
|
||||||
},
|
},
|
||||||
hasRootAccess: function (_hostname: unknown): boolean {
|
hasRootAccess: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("hasRootAccess", "hostname", _hostname);
|
|
||||||
updateDynamicRam("hasRootAccess", getRamCost(Player, "hasRootAccess"));
|
updateDynamicRam("hasRootAccess", getRamCost(Player, "hasRootAccess"));
|
||||||
|
const hostname = helper.string("hasRootAccess", "hostname", _hostname);
|
||||||
if (hostname === undefined) {
|
if (hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("hasRootAccess", "Takes 1 argument");
|
throw makeRuntimeErrorMsg("hasRootAccess", "Takes 1 argument");
|
||||||
}
|
}
|
||||||
@ -1480,8 +1479,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return copy;
|
return copy;
|
||||||
},
|
},
|
||||||
getServer: function (_hostname: unknown = workerScript.hostname): IServerDef {
|
getServer: function (_hostname: unknown = workerScript.hostname): IServerDef {
|
||||||
const hostname = helper.string("getServer", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServer", getRamCost(Player, "getServer"));
|
updateDynamicRam("getServer", getRamCost(Player, "getServer"));
|
||||||
|
const hostname = helper.string("getServer", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServer");
|
const server = safeGetServer(hostname, "getServer");
|
||||||
const copy = Object.assign({}, server) as any;
|
const copy = Object.assign({}, server) as any;
|
||||||
// These fields should be hidden.
|
// These fields should be hidden.
|
||||||
@ -1504,8 +1503,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return copy;
|
return copy;
|
||||||
},
|
},
|
||||||
getServerMoneyAvailable: function (_hostname: unknown): number {
|
getServerMoneyAvailable: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerMoneyAvailable", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerMoneyAvailable", getRamCost(Player, "getServerMoneyAvailable"));
|
updateDynamicRam("getServerMoneyAvailable", getRamCost(Player, "getServerMoneyAvailable"));
|
||||||
|
const hostname = helper.string("getServerMoneyAvailable", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerMoneyAvailable");
|
const server = safeGetServer(hostname, "getServerMoneyAvailable");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerMoneyAvailable", () => "Cannot be executed on this server.");
|
workerScript.log("getServerMoneyAvailable", () => "Cannot be executed on this server.");
|
||||||
@ -1529,8 +1528,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.moneyAvailable;
|
return server.moneyAvailable;
|
||||||
},
|
},
|
||||||
getServerSecurityLevel: function (_hostname: unknown): number {
|
getServerSecurityLevel: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerSecurityLevel", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerSecurityLevel", getRamCost(Player, "getServerSecurityLevel"));
|
updateDynamicRam("getServerSecurityLevel", getRamCost(Player, "getServerSecurityLevel"));
|
||||||
|
const hostname = helper.string("getServerSecurityLevel", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerSecurityLevel");
|
const server = safeGetServer(hostname, "getServerSecurityLevel");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerSecurityLevel", () => "Cannot be executed on this server.");
|
workerScript.log("getServerSecurityLevel", () => "Cannot be executed on this server.");
|
||||||
@ -1546,8 +1545,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.hackDifficulty;
|
return server.hackDifficulty;
|
||||||
},
|
},
|
||||||
getServerBaseSecurityLevel: function (_hostname: unknown): number {
|
getServerBaseSecurityLevel: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerBaseSecurityLevel", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerBaseSecurityLevel", getRamCost(Player, "getServerBaseSecurityLevel"));
|
updateDynamicRam("getServerBaseSecurityLevel", getRamCost(Player, "getServerBaseSecurityLevel"));
|
||||||
|
const hostname = helper.string("getServerBaseSecurityLevel", "hostname", _hostname);
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"getServerBaseSecurityLevel",
|
"getServerBaseSecurityLevel",
|
||||||
() => `getServerBaseSecurityLevel is deprecated because it's not useful.`,
|
() => `getServerBaseSecurityLevel is deprecated because it's not useful.`,
|
||||||
@ -1567,8 +1566,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.baseDifficulty;
|
return server.baseDifficulty;
|
||||||
},
|
},
|
||||||
getServerMinSecurityLevel: function (_hostname: unknown): number {
|
getServerMinSecurityLevel: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerMinSecurityLevel", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerMinSecurityLevel", getRamCost(Player, "getServerMinSecurityLevel"));
|
updateDynamicRam("getServerMinSecurityLevel", getRamCost(Player, "getServerMinSecurityLevel"));
|
||||||
|
const hostname = helper.string("getServerMinSecurityLevel", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerMinSecurityLevel");
|
const server = safeGetServer(hostname, "getServerMinSecurityLevel");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerMinSecurityLevel", () => "Cannot be executed on this server.");
|
workerScript.log("getServerMinSecurityLevel", () => "Cannot be executed on this server.");
|
||||||
@ -1584,8 +1583,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.minDifficulty;
|
return server.minDifficulty;
|
||||||
},
|
},
|
||||||
getServerRequiredHackingLevel: function (_hostname: unknown): number {
|
getServerRequiredHackingLevel: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerRequiredHackingLevel", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerRequiredHackingLevel", getRamCost(Player, "getServerRequiredHackingLevel"));
|
updateDynamicRam("getServerRequiredHackingLevel", getRamCost(Player, "getServerRequiredHackingLevel"));
|
||||||
|
const hostname = helper.string("getServerRequiredHackingLevel", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerRequiredHackingLevel");
|
const server = safeGetServer(hostname, "getServerRequiredHackingLevel");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerRequiredHackingLevel", () => "Cannot be executed on this server.");
|
workerScript.log("getServerRequiredHackingLevel", () => "Cannot be executed on this server.");
|
||||||
@ -1601,8 +1600,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.requiredHackingSkill;
|
return server.requiredHackingSkill;
|
||||||
},
|
},
|
||||||
getServerMaxMoney: function (_hostname: unknown): number {
|
getServerMaxMoney: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerMaxMoney", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerMaxMoney", getRamCost(Player, "getServerMaxMoney"));
|
updateDynamicRam("getServerMaxMoney", getRamCost(Player, "getServerMaxMoney"));
|
||||||
|
const hostname = helper.string("getServerMaxMoney", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerMaxMoney");
|
const server = safeGetServer(hostname, "getServerMaxMoney");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerMaxMoney", () => "Cannot be executed on this server.");
|
workerScript.log("getServerMaxMoney", () => "Cannot be executed on this server.");
|
||||||
@ -1618,8 +1617,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.moneyMax;
|
return server.moneyMax;
|
||||||
},
|
},
|
||||||
getServerGrowth: function (_hostname: unknown): number {
|
getServerGrowth: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerGrowth", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerGrowth", getRamCost(Player, "getServerGrowth"));
|
updateDynamicRam("getServerGrowth", getRamCost(Player, "getServerGrowth"));
|
||||||
|
const hostname = helper.string("getServerGrowth", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerGrowth");
|
const server = safeGetServer(hostname, "getServerGrowth");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerGrowth", () => "Cannot be executed on this server.");
|
workerScript.log("getServerGrowth", () => "Cannot be executed on this server.");
|
||||||
@ -1632,8 +1631,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.serverGrowth;
|
return server.serverGrowth;
|
||||||
},
|
},
|
||||||
getServerNumPortsRequired: function (_hostname: unknown): number {
|
getServerNumPortsRequired: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerNumPortsRequired", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerNumPortsRequired", getRamCost(Player, "getServerNumPortsRequired"));
|
updateDynamicRam("getServerNumPortsRequired", getRamCost(Player, "getServerNumPortsRequired"));
|
||||||
|
const hostname = helper.string("getServerNumPortsRequired", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerNumPortsRequired");
|
const server = safeGetServer(hostname, "getServerNumPortsRequired");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getServerNumPortsRequired", () => "Cannot be executed on this server.");
|
workerScript.log("getServerNumPortsRequired", () => "Cannot be executed on this server.");
|
||||||
@ -1649,8 +1648,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return server.numOpenPortsRequired;
|
return server.numOpenPortsRequired;
|
||||||
},
|
},
|
||||||
getServerRam: function (_hostname: unknown): [number, number] {
|
getServerRam: function (_hostname: unknown): [number, number] {
|
||||||
const hostname = helper.string("getServerRam", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerRam", getRamCost(Player, "getServerRam"));
|
updateDynamicRam("getServerRam", getRamCost(Player, "getServerRam"));
|
||||||
|
const hostname = helper.string("getServerRam", "hostname", _hostname);
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"getServerRam",
|
"getServerRam",
|
||||||
() => `getServerRam is deprecated in favor of getServerMaxRam / getServerUsedRam`,
|
() => `getServerRam is deprecated in favor of getServerMaxRam / getServerUsedRam`,
|
||||||
@ -1663,28 +1662,28 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return [server.maxRam, server.ramUsed];
|
return [server.maxRam, server.ramUsed];
|
||||||
},
|
},
|
||||||
getServerMaxRam: function (_hostname: unknown): number {
|
getServerMaxRam: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerMaxRam", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerMaxRam", getRamCost(Player, "getServerMaxRam"));
|
updateDynamicRam("getServerMaxRam", getRamCost(Player, "getServerMaxRam"));
|
||||||
|
const hostname = helper.string("getServerMaxRam", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerMaxRam");
|
const server = safeGetServer(hostname, "getServerMaxRam");
|
||||||
workerScript.log("getServerMaxRam", () => `returned ${numeralWrapper.formatRAM(server.maxRam)}`);
|
workerScript.log("getServerMaxRam", () => `returned ${numeralWrapper.formatRAM(server.maxRam)}`);
|
||||||
return server.maxRam;
|
return server.maxRam;
|
||||||
},
|
},
|
||||||
getServerUsedRam: function (_hostname: unknown): number {
|
getServerUsedRam: function (_hostname: unknown): number {
|
||||||
const hostname = helper.string("getServerUsedRam", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getServerUsedRam", getRamCost(Player, "getServerUsedRam"));
|
updateDynamicRam("getServerUsedRam", getRamCost(Player, "getServerUsedRam"));
|
||||||
|
const hostname = helper.string("getServerUsedRam", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getServerUsedRam");
|
const server = safeGetServer(hostname, "getServerUsedRam");
|
||||||
workerScript.log("getServerUsedRam", () => `returned ${numeralWrapper.formatRAM(server.ramUsed)}`);
|
workerScript.log("getServerUsedRam", () => `returned ${numeralWrapper.formatRAM(server.ramUsed)}`);
|
||||||
return server.ramUsed;
|
return server.ramUsed;
|
||||||
},
|
},
|
||||||
serverExists: function (_hostname: unknown): boolean {
|
serverExists: function (_hostname: unknown): boolean {
|
||||||
const hostname = helper.string("serverExists", "hostname", _hostname);
|
|
||||||
updateDynamicRam("serverExists", getRamCost(Player, "serverExists"));
|
updateDynamicRam("serverExists", getRamCost(Player, "serverExists"));
|
||||||
|
const hostname = helper.string("serverExists", "hostname", _hostname);
|
||||||
return GetServer(hostname) !== null;
|
return GetServer(hostname) !== null;
|
||||||
},
|
},
|
||||||
fileExists: function (_filename: unknown, _hostname: unknown = workerScript.hostname): boolean {
|
fileExists: function (_filename: unknown, _hostname: unknown = workerScript.hostname): boolean {
|
||||||
|
updateDynamicRam("fileExists", getRamCost(Player, "fileExists"));
|
||||||
const filename = helper.string("fileExists", "filename", _filename);
|
const filename = helper.string("fileExists", "filename", _filename);
|
||||||
const hostname = helper.string("fileExists", "hostname", _hostname);
|
const hostname = helper.string("fileExists", "hostname", _hostname);
|
||||||
updateDynamicRam("fileExists", getRamCost(Player, "fileExists"));
|
|
||||||
if (filename === undefined) {
|
if (filename === undefined) {
|
||||||
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
||||||
}
|
}
|
||||||
@ -1729,8 +1728,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return getPurchaseServerMaxRam();
|
return getPurchaseServerMaxRam();
|
||||||
},
|
},
|
||||||
getPurchasedServerCost: function (_ram: unknown): number {
|
getPurchasedServerCost: function (_ram: unknown): number {
|
||||||
const ram = helper.number("getPurchasedServerCost", "ram", _ram);
|
|
||||||
updateDynamicRam("getPurchasedServerCost", getRamCost(Player, "getPurchasedServerCost"));
|
updateDynamicRam("getPurchasedServerCost", getRamCost(Player, "getPurchasedServerCost"));
|
||||||
|
const ram = helper.number("getPurchasedServerCost", "ram", _ram);
|
||||||
|
|
||||||
const cost = getPurchaseServerCost(ram);
|
const cost = getPurchaseServerCost(ram);
|
||||||
if (cost === Infinity) {
|
if (cost === Infinity) {
|
||||||
@ -1741,10 +1740,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return cost;
|
return cost;
|
||||||
},
|
},
|
||||||
purchaseServer: function (_name: unknown, _ram: unknown): string {
|
purchaseServer: function (_name: unknown, _ram: unknown): string {
|
||||||
|
updateDynamicRam("purchaseServer", getRamCost(Player, "purchaseServer"));
|
||||||
const name = helper.string("purchaseServer", "name", _name);
|
const name = helper.string("purchaseServer", "name", _name);
|
||||||
const ram = helper.number("purchaseServer", "ram", _ram);
|
const ram = helper.number("purchaseServer", "ram", _ram);
|
||||||
if (arguments.length !== 2) throw makeRuntimeErrorMsg("purchaseServer", "Takes 2 arguments");
|
if (arguments.length !== 2) throw makeRuntimeErrorMsg("purchaseServer", "Takes 2 arguments");
|
||||||
updateDynamicRam("purchaseServer", getRamCost(Player, "purchaseServer"));
|
|
||||||
let hostnameStr = String(name);
|
let hostnameStr = String(name);
|
||||||
hostnameStr = hostnameStr.replace(/\s+/g, "");
|
hostnameStr = hostnameStr.replace(/\s+/g, "");
|
||||||
if (hostnameStr == "") {
|
if (hostnameStr == "") {
|
||||||
@ -1805,8 +1804,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return newServ.hostname;
|
return newServ.hostname;
|
||||||
},
|
},
|
||||||
deleteServer: function (_name: unknown): boolean {
|
deleteServer: function (_name: unknown): boolean {
|
||||||
const name = helper.string("purchaseServer", "name", _name);
|
|
||||||
updateDynamicRam("deleteServer", getRamCost(Player, "deleteServer"));
|
updateDynamicRam("deleteServer", getRamCost(Player, "deleteServer"));
|
||||||
|
const name = helper.string("purchaseServer", "name", _name);
|
||||||
let hostnameStr = String(name);
|
let hostnameStr = String(name);
|
||||||
hostnameStr = hostnameStr.replace(/\s\s+/g, "");
|
hostnameStr = hostnameStr.replace(/\s\s+/g, "");
|
||||||
const server = GetServer(hostnameStr);
|
const server = GetServer(hostnameStr);
|
||||||
@ -1890,8 +1889,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
writePort: function (_port: unknown, data: any = ""): Promise<any> {
|
writePort: function (_port: unknown, data: any = ""): Promise<any> {
|
||||||
const port = helper.number("writePort", "port", _port);
|
|
||||||
updateDynamicRam("writePort", getRamCost(Player, "writePort"));
|
updateDynamicRam("writePort", getRamCost(Player, "writePort"));
|
||||||
|
const port = helper.number("writePort", "port", _port);
|
||||||
if (typeof data !== "string" && typeof data !== "number") {
|
if (typeof data !== "string" && typeof data !== "number") {
|
||||||
throw makeRuntimeErrorMsg(
|
throw makeRuntimeErrorMsg(
|
||||||
"writePort",
|
"writePort",
|
||||||
@ -1902,9 +1901,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return Promise.resolve(iport.write(data));
|
return Promise.resolve(iport.write(data));
|
||||||
},
|
},
|
||||||
write: function (_port: unknown, data: any = "", _mode: unknown = "a"): Promise<void> {
|
write: function (_port: unknown, data: any = "", _mode: unknown = "a"): Promise<void> {
|
||||||
|
updateDynamicRam("write", getRamCost(Player, "write"));
|
||||||
const port = helper.string("write", "port", _port);
|
const port = helper.string("write", "port", _port);
|
||||||
const mode = helper.string("write", "mode", _mode);
|
const mode = helper.string("write", "mode", _mode);
|
||||||
updateDynamicRam("write", getRamCost(Player, "write"));
|
|
||||||
if (isString(port)) {
|
if (isString(port)) {
|
||||||
// Write to script or text file
|
// Write to script or text file
|
||||||
let fn = port;
|
let fn = port;
|
||||||
@ -1957,8 +1956,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
tryWritePort: function (_port: unknown, data: any = ""): Promise<any> {
|
tryWritePort: function (_port: unknown, data: any = ""): Promise<any> {
|
||||||
let port = helper.number("tryWritePort", "port", _port);
|
|
||||||
updateDynamicRam("tryWritePort", getRamCost(Player, "tryWritePort"));
|
updateDynamicRam("tryWritePort", getRamCost(Player, "tryWritePort"));
|
||||||
|
let port = helper.number("tryWritePort", "port", _port);
|
||||||
if (typeof data !== "string" && typeof data !== "number") {
|
if (typeof data !== "string" && typeof data !== "number") {
|
||||||
throw makeRuntimeErrorMsg(
|
throw makeRuntimeErrorMsg(
|
||||||
"tryWritePort",
|
"tryWritePort",
|
||||||
@ -1983,16 +1982,16 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
readPort: function (_port: unknown): any {
|
readPort: function (_port: unknown): any {
|
||||||
const port = helper.number("readPort", "port", _port);
|
|
||||||
updateDynamicRam("readPort", getRamCost(Player, "readPort"));
|
updateDynamicRam("readPort", getRamCost(Player, "readPort"));
|
||||||
|
const port = helper.number("readPort", "port", _port);
|
||||||
// Read from port
|
// Read from port
|
||||||
const iport = helper.getValidPort("readPort", port);
|
const iport = helper.getValidPort("readPort", port);
|
||||||
const x = iport.read();
|
const x = iport.read();
|
||||||
return x;
|
return x;
|
||||||
},
|
},
|
||||||
read: function (_port: unknown): string {
|
read: function (_port: unknown): string {
|
||||||
const port = helper.string("read", "port", _port);
|
|
||||||
updateDynamicRam("read", getRamCost(Player, "read"));
|
updateDynamicRam("read", getRamCost(Player, "read"));
|
||||||
|
const port = helper.string("read", "port", _port);
|
||||||
if (isString(port)) {
|
if (isString(port)) {
|
||||||
// Read from script or text file
|
// Read from script or text file
|
||||||
const fn = port;
|
const fn = port;
|
||||||
@ -2021,15 +2020,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
peek: function (_port: unknown): any {
|
peek: function (_port: unknown): any {
|
||||||
const port = helper.number("peek", "port", _port);
|
|
||||||
updateDynamicRam("peek", getRamCost(Player, "peek"));
|
updateDynamicRam("peek", getRamCost(Player, "peek"));
|
||||||
|
const port = helper.number("peek", "port", _port);
|
||||||
const iport = helper.getValidPort("peek", port);
|
const iport = helper.getValidPort("peek", port);
|
||||||
const x = iport.peek();
|
const x = iport.peek();
|
||||||
return x;
|
return x;
|
||||||
},
|
},
|
||||||
clear: function (_file: unknown): void {
|
clear: function (_file: unknown): void {
|
||||||
const file = helper.string("peek", "file", _file);
|
|
||||||
updateDynamicRam("clear", getRamCost(Player, "clear"));
|
updateDynamicRam("clear", getRamCost(Player, "clear"));
|
||||||
|
const file = helper.string("peek", "file", _file);
|
||||||
if (isString(file)) {
|
if (isString(file)) {
|
||||||
// Clear text file
|
// Clear text file
|
||||||
const fn = file;
|
const fn = file;
|
||||||
@ -2046,21 +2045,21 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearPort: function (_port: unknown): void {
|
clearPort: function (_port: unknown): void {
|
||||||
const port = helper.number("clearPort", "port", _port);
|
|
||||||
updateDynamicRam("clearPort", getRamCost(Player, "clearPort"));
|
updateDynamicRam("clearPort", getRamCost(Player, "clearPort"));
|
||||||
|
const port = helper.number("clearPort", "port", _port);
|
||||||
// Clear port
|
// Clear port
|
||||||
const iport = helper.getValidPort("clearPort", port);
|
const iport = helper.getValidPort("clearPort", port);
|
||||||
iport.clear();
|
iport.clear();
|
||||||
},
|
},
|
||||||
getPortHandle: function (_port: unknown): IPort {
|
getPortHandle: function (_port: unknown): IPort {
|
||||||
const port = helper.number("getPortHandle", "port", _port);
|
|
||||||
updateDynamicRam("getPortHandle", getRamCost(Player, "getPortHandle"));
|
updateDynamicRam("getPortHandle", getRamCost(Player, "getPortHandle"));
|
||||||
|
const port = helper.number("getPortHandle", "port", _port);
|
||||||
const iport = helper.getValidPort("getPortHandle", port);
|
const iport = helper.getValidPort("getPortHandle", port);
|
||||||
return iport;
|
return iport;
|
||||||
},
|
},
|
||||||
rm: function (_fn: unknown, hostname: any): boolean {
|
rm: function (_fn: unknown, hostname: any): boolean {
|
||||||
const fn = helper.string("rm", "fn", _fn);
|
|
||||||
updateDynamicRam("rm", getRamCost(Player, "rm"));
|
updateDynamicRam("rm", getRamCost(Player, "rm"));
|
||||||
|
const fn = helper.string("rm", "fn", _fn);
|
||||||
|
|
||||||
if (hostname == null || hostname === "") {
|
if (hostname == null || hostname === "") {
|
||||||
hostname = workerScript.hostname;
|
hostname = workerScript.hostname;
|
||||||
@ -2075,9 +2074,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return status.res;
|
return status.res;
|
||||||
},
|
},
|
||||||
scriptRunning: function (_scriptname: unknown, _hostname: unknown): boolean {
|
scriptRunning: function (_scriptname: unknown, _hostname: unknown): boolean {
|
||||||
|
updateDynamicRam("scriptRunning", getRamCost(Player, "scriptRunning"));
|
||||||
const scriptname = helper.string("scriptRunning", "scriptname", _scriptname);
|
const scriptname = helper.string("scriptRunning", "scriptname", _scriptname);
|
||||||
const hostname = helper.string("scriptRunning", "hostname", _hostname);
|
const hostname = helper.string("scriptRunning", "hostname", _hostname);
|
||||||
updateDynamicRam("scriptRunning", getRamCost(Player, "scriptRunning"));
|
|
||||||
const server = safeGetServer(hostname, "scriptRunning");
|
const server = safeGetServer(hostname, "scriptRunning");
|
||||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||||
if (server.runningScripts[i].filename == scriptname) {
|
if (server.runningScripts[i].filename == scriptname) {
|
||||||
@ -2087,9 +2086,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
scriptKill: function (_scriptname: unknown, _hostname: unknown): boolean {
|
scriptKill: function (_scriptname: unknown, _hostname: unknown): boolean {
|
||||||
|
updateDynamicRam("scriptKill", getRamCost(Player, "scriptKill"));
|
||||||
const scriptname = helper.string("scriptKill", "scriptname", _scriptname);
|
const scriptname = helper.string("scriptKill", "scriptname", _scriptname);
|
||||||
const hostname = helper.string("scriptKill", "hostname", _hostname);
|
const hostname = helper.string("scriptKill", "hostname", _hostname);
|
||||||
updateDynamicRam("scriptKill", getRamCost(Player, "scriptKill"));
|
|
||||||
const server = safeGetServer(hostname, "scriptKill");
|
const server = safeGetServer(hostname, "scriptKill");
|
||||||
let suc = false;
|
let suc = false;
|
||||||
for (let i = 0; i < server.runningScripts.length; i++) {
|
for (let i = 0; i < server.runningScripts.length; i++) {
|
||||||
@ -2106,9 +2105,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return workerScript.name;
|
return workerScript.name;
|
||||||
},
|
},
|
||||||
getScriptRam: function (_scriptname: unknown, _hostname: unknown = workerScript.hostname): number {
|
getScriptRam: function (_scriptname: unknown, _hostname: unknown = workerScript.hostname): number {
|
||||||
|
updateDynamicRam("getScriptRam", getRamCost(Player, "getScriptRam"));
|
||||||
const scriptname = helper.string("getScriptRam", "scriptname", _scriptname);
|
const scriptname = helper.string("getScriptRam", "scriptname", _scriptname);
|
||||||
const hostname = helper.string("getScriptRam", "hostname", _hostname);
|
const hostname = helper.string("getScriptRam", "hostname", _hostname);
|
||||||
updateDynamicRam("getScriptRam", getRamCost(Player, "getScriptRam"));
|
|
||||||
const server = safeGetServer(hostname, "getScriptRam");
|
const server = safeGetServer(hostname, "getScriptRam");
|
||||||
for (let i = 0; i < server.scripts.length; ++i) {
|
for (let i = 0; i < server.scripts.length; ++i) {
|
||||||
if (server.scripts[i].filename == scriptname) {
|
if (server.scripts[i].filename == scriptname) {
|
||||||
@ -2146,8 +2145,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
getHackTime: function (_hostname: unknown = workerScript.hostname): number {
|
getHackTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||||
const hostname = helper.string("getHackTime", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getHackTime", getRamCost(Player, "getHackTime"));
|
updateDynamicRam("getHackTime", getRamCost(Player, "getHackTime"));
|
||||||
|
const hostname = helper.string("getHackTime", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getHackTime");
|
const server = safeGetServer(hostname, "getHackTime");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getHackTime", () => "invalid for this kind of server");
|
workerScript.log("getHackTime", () => "invalid for this kind of server");
|
||||||
@ -2160,8 +2159,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return calculateHackingTime(server, Player) * 1000;
|
return calculateHackingTime(server, Player) * 1000;
|
||||||
},
|
},
|
||||||
getGrowTime: function (_hostname: unknown = workerScript.hostname): number {
|
getGrowTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||||
const hostname = helper.string("getGrowTime", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getGrowTime", getRamCost(Player, "getGrowTime"));
|
updateDynamicRam("getGrowTime", getRamCost(Player, "getGrowTime"));
|
||||||
|
const hostname = helper.string("getGrowTime", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getGrowTime");
|
const server = safeGetServer(hostname, "getGrowTime");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getGrowTime", () => "invalid for this kind of server");
|
workerScript.log("getGrowTime", () => "invalid for this kind of server");
|
||||||
@ -2174,8 +2173,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return calculateGrowTime(server, Player) * 1000;
|
return calculateGrowTime(server, Player) * 1000;
|
||||||
},
|
},
|
||||||
getWeakenTime: function (_hostname: unknown = workerScript.hostname): number {
|
getWeakenTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||||
const hostname = helper.string("getWeakenTime", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getWeakenTime", getRamCost(Player, "getWeakenTime"));
|
updateDynamicRam("getWeakenTime", getRamCost(Player, "getWeakenTime"));
|
||||||
|
const hostname = helper.string("getWeakenTime", "hostname", _hostname);
|
||||||
const server = safeGetServer(hostname, "getWeakenTime");
|
const server = safeGetServer(hostname, "getWeakenTime");
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
workerScript.log("getWeakenTime", () => "invalid for this kind of server");
|
workerScript.log("getWeakenTime", () => "invalid for this kind of server");
|
||||||
@ -2239,9 +2238,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
nFormat: function (_n: unknown, _format: unknown): string {
|
nFormat: function (_n: unknown, _format: unknown): string {
|
||||||
|
updateDynamicRam("nFormat", getRamCost(Player, "nFormat"));
|
||||||
const n = helper.number("nFormat", "n", _n);
|
const n = helper.number("nFormat", "n", _n);
|
||||||
const format = helper.string("nFormat", "format", _format);
|
const format = helper.string("nFormat", "format", _format);
|
||||||
updateDynamicRam("nFormat", getRamCost(Player, "nFormat"));
|
|
||||||
if (isNaN(n)) {
|
if (isNaN(n)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -2249,9 +2248,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return numeralWrapper.format(n, format);
|
return numeralWrapper.format(n, format);
|
||||||
},
|
},
|
||||||
tFormat: function (_milliseconds: unknown, _milliPrecision: unknown = false): string {
|
tFormat: function (_milliseconds: unknown, _milliPrecision: unknown = false): string {
|
||||||
|
updateDynamicRam("tFormat", getRamCost(Player, "tFormat"));
|
||||||
const milliseconds = helper.number("tFormat", "milliseconds", _milliseconds);
|
const milliseconds = helper.number("tFormat", "milliseconds", _milliseconds);
|
||||||
const milliPrecision = helper.boolean(_milliPrecision);
|
const milliPrecision = helper.boolean(_milliPrecision);
|
||||||
updateDynamicRam("tFormat", getRamCost(Player, "tFormat"));
|
|
||||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||||
},
|
},
|
||||||
getTimeSinceLastAug: function (): number {
|
getTimeSinceLastAug: function (): number {
|
||||||
@ -2259,21 +2258,21 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
return Player.playtimeSinceLastAug;
|
return Player.playtimeSinceLastAug;
|
||||||
},
|
},
|
||||||
alert: function (_message: unknown): void {
|
alert: function (_message: unknown): void {
|
||||||
const message = helper.string("alert", "message", _message);
|
|
||||||
updateDynamicRam("alert", getRamCost(Player, "alert"));
|
updateDynamicRam("alert", getRamCost(Player, "alert"));
|
||||||
|
const message = helper.string("alert", "message", _message);
|
||||||
dialogBoxCreate(message);
|
dialogBoxCreate(message);
|
||||||
},
|
},
|
||||||
toast: function (_message: unknown, _variant: unknown = "success", duration: any = 2000): void {
|
toast: function (_message: unknown, _variant: unknown = "success", duration: any = 2000): void {
|
||||||
|
updateDynamicRam("toast", getRamCost(Player, "toast"));
|
||||||
const message = helper.string("toast", "message", _message);
|
const message = helper.string("toast", "message", _message);
|
||||||
const variant = helper.string("toast", "variant", _variant);
|
const variant = helper.string("toast", "variant", _variant);
|
||||||
updateDynamicRam("toast", getRamCost(Player, "toast"));
|
|
||||||
if (!["success", "info", "warning", "error"].includes(variant))
|
if (!["success", "info", "warning", "error"].includes(variant))
|
||||||
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
|
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
|
||||||
SnackbarEvents.emit(message, variant as any, duration);
|
SnackbarEvents.emit(message, variant as any, duration);
|
||||||
},
|
},
|
||||||
prompt: function (_txt: unknown, options?: { type?: string; options?: string[] }): Promise<boolean | string> {
|
prompt: function (_txt: unknown, options?: { type?: string; options?: string[] }): Promise<boolean | string> {
|
||||||
const txt = helper.string("toast", "txt", _txt);
|
|
||||||
updateDynamicRam("prompt", getRamCost(Player, "prompt"));
|
updateDynamicRam("prompt", getRamCost(Player, "prompt"));
|
||||||
|
const txt = helper.string("toast", "txt", _txt);
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
PromptEvent.emit({
|
PromptEvent.emit({
|
||||||
@ -2288,10 +2287,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
_target: unknown,
|
_target: unknown,
|
||||||
_hostname: unknown = workerScript.hostname,
|
_hostname: unknown = workerScript.hostname,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
|
updateDynamicRam("wget", getRamCost(Player, "wget"));
|
||||||
const url = helper.string("wget", "url", _url);
|
const url = helper.string("wget", "url", _url);
|
||||||
const target = helper.string("wget", "target", _target);
|
const target = helper.string("wget", "target", _target);
|
||||||
const hostname = helper.string("wget", "hostname", _hostname);
|
const hostname = helper.string("wget", "hostname", _hostname);
|
||||||
updateDynamicRam("wget", getRamCost(Player, "wget"));
|
|
||||||
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
||||||
workerScript.log("wget", () => `Invalid target file: '${target}'. Must be a script or text file.`);
|
workerScript.log("wget", () => `Invalid target file: '${target}'. Must be a script or text file.`);
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
@ -2450,10 +2449,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}; // Wrap the user function to prevent WorkerScript leaking as 'this'
|
}; // Wrap the user function to prevent WorkerScript leaking as 'this'
|
||||||
},
|
},
|
||||||
mv: function (_host: unknown, _source: unknown, _destination: unknown): void {
|
mv: function (_host: unknown, _source: unknown, _destination: unknown): void {
|
||||||
|
updateDynamicRam("mv", getRamCost(Player, "mv"));
|
||||||
const host = helper.string("mv", "host", _host);
|
const host = helper.string("mv", "host", _host);
|
||||||
const source = helper.string("mv", "source", _source);
|
const source = helper.string("mv", "source", _source);
|
||||||
const destination = helper.string("mv", "destination", _destination);
|
const destination = helper.string("mv", "destination", _destination);
|
||||||
updateDynamicRam("mv", getRamCost(Player, "mv"));
|
|
||||||
|
|
||||||
if (!isValidFilePath(source)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${source}'`);
|
if (!isValidFilePath(source)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${source}'`);
|
||||||
if (!isValidFilePath(destination)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${destination}'`);
|
if (!isValidFilePath(destination)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${destination}'`);
|
||||||
|
@ -56,53 +56,56 @@ export function NetscriptBladeburner(
|
|||||||
return actionObj;
|
return actionObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRam = (funcName: string): void =>
|
||||||
|
helper.updateDynamicRam(funcName, getRamCost(player, "bladeburner", funcName));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getContractNames: function (): string[] {
|
getContractNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getContractNames", getRamCost(player, "bladeburner", "getContractNames"));
|
updateRam("getContractNames");
|
||||||
checkBladeburnerAccess("getContractNames");
|
checkBladeburnerAccess("getContractNames");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getContractNamesNetscriptFn();
|
return bladeburner.getContractNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
getOperationNames: function (): string[] {
|
getOperationNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getOperationNames", getRamCost(player, "bladeburner", "getOperationNames"));
|
updateRam("getOperationNames");
|
||||||
checkBladeburnerAccess("getOperationNames");
|
checkBladeburnerAccess("getOperationNames");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getOperationNamesNetscriptFn();
|
return bladeburner.getOperationNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
getBlackOpNames: function (): string[] {
|
getBlackOpNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getBlackOpNames", getRamCost(player, "bladeburner", "getBlackOpNames"));
|
updateRam("getBlackOpNames");
|
||||||
checkBladeburnerAccess("getBlackOpNames");
|
checkBladeburnerAccess("getBlackOpNames");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getBlackOpNamesNetscriptFn();
|
return bladeburner.getBlackOpNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
getBlackOpRank: function (_blackOpName: unknown): number {
|
getBlackOpRank: function (_blackOpName: unknown): number {
|
||||||
|
updateRam("getBlackOpRank");
|
||||||
const blackOpName = helper.string("getBlackOpRank", "blackOpName", _blackOpName);
|
const blackOpName = helper.string("getBlackOpRank", "blackOpName", _blackOpName);
|
||||||
helper.updateDynamicRam("getBlackOpRank", getRamCost(player, "bladeburner", "getBlackOpRank"));
|
|
||||||
checkBladeburnerAccess("getBlackOpRank");
|
checkBladeburnerAccess("getBlackOpRank");
|
||||||
const action: any = getBladeburnerActionObject("getBlackOpRank", "blackops", blackOpName);
|
const action: any = getBladeburnerActionObject("getBlackOpRank", "blackops", blackOpName);
|
||||||
return action.reqdRank;
|
return action.reqdRank;
|
||||||
},
|
},
|
||||||
getGeneralActionNames: function (): string[] {
|
getGeneralActionNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getGeneralActionNames", getRamCost(player, "bladeburner", "getGeneralActionNames"));
|
updateRam("getGeneralActionNames");
|
||||||
checkBladeburnerAccess("getGeneralActionNames");
|
checkBladeburnerAccess("getGeneralActionNames");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getGeneralActionNamesNetscriptFn();
|
return bladeburner.getGeneralActionNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
getSkillNames: function (): string[] {
|
getSkillNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getSkillNames", getRamCost(player, "bladeburner", "getSkillNames"));
|
updateRam("getSkillNames");
|
||||||
checkBladeburnerAccess("getSkillNames");
|
checkBladeburnerAccess("getSkillNames");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getSkillNamesNetscriptFn();
|
return bladeburner.getSkillNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
startAction: function (_type: unknown, _name: unknown): boolean {
|
startAction: function (_type: unknown, _name: unknown): boolean {
|
||||||
|
updateRam("startAction");
|
||||||
const type = helper.string("startAction", "type", _type);
|
const type = helper.string("startAction", "type", _type);
|
||||||
const name = helper.string("startAction", "name", _name);
|
const name = helper.string("startAction", "name", _name);
|
||||||
helper.updateDynamicRam("startAction", getRamCost(player, "bladeburner", "startAction"));
|
|
||||||
checkBladeburnerAccess("startAction");
|
checkBladeburnerAccess("startAction");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -113,23 +116,23 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
stopBladeburnerAction: function (): void {
|
stopBladeburnerAction: function (): void {
|
||||||
helper.updateDynamicRam("stopBladeburnerAction", getRamCost(player, "bladeburner", "stopBladeburnerAction"));
|
updateRam("stopBladeburnerAction");
|
||||||
checkBladeburnerAccess("stopBladeburnerAction");
|
checkBladeburnerAccess("stopBladeburnerAction");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.resetAction();
|
return bladeburner.resetAction();
|
||||||
},
|
},
|
||||||
getCurrentAction: function (): BladeburnerCurAction {
|
getCurrentAction: function (): BladeburnerCurAction {
|
||||||
helper.updateDynamicRam("getCurrentAction", getRamCost(player, "bladeburner", "getCurrentAction"));
|
updateRam("getCurrentAction");
|
||||||
checkBladeburnerAccess("getCurrentAction");
|
checkBladeburnerAccess("getCurrentAction");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.getTypeAndNameFromActionId(bladeburner.action);
|
return bladeburner.getTypeAndNameFromActionId(bladeburner.action);
|
||||||
},
|
},
|
||||||
getActionTime: function (_type: unknown, _name: unknown): number {
|
getActionTime: function (_type: unknown, _name: unknown): number {
|
||||||
|
updateRam("getActionTime");
|
||||||
const type = helper.string("getActionTime", "type", _type);
|
const type = helper.string("getActionTime", "type", _type);
|
||||||
const name = helper.string("getActionTime", "name", _name);
|
const name = helper.string("getActionTime", "name", _name);
|
||||||
helper.updateDynamicRam("getActionTime", getRamCost(player, "bladeburner", "getActionTime"));
|
|
||||||
checkBladeburnerAccess("getActionTime");
|
checkBladeburnerAccess("getActionTime");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -147,12 +150,9 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getActionEstimatedSuccessChance: function (_type: unknown, _name: unknown): [number, number] {
|
getActionEstimatedSuccessChance: function (_type: unknown, _name: unknown): [number, number] {
|
||||||
|
updateRam("getActionEstimatedSuccessChance");
|
||||||
const type = helper.string("getActionEstimatedSuccessChance", "type", _type);
|
const type = helper.string("getActionEstimatedSuccessChance", "type", _type);
|
||||||
const name = helper.string("getActionEstimatedSuccessChance", "name", _name);
|
const name = helper.string("getActionEstimatedSuccessChance", "name", _name);
|
||||||
helper.updateDynamicRam(
|
|
||||||
"getActionEstimatedSuccessChance",
|
|
||||||
getRamCost(player, "bladeburner", "getActionEstimatedSuccessChance"),
|
|
||||||
);
|
|
||||||
checkBladeburnerAccess("getActionEstimatedSuccessChance");
|
checkBladeburnerAccess("getActionEstimatedSuccessChance");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -170,10 +170,10 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getActionRepGain: function (_type: unknown, _name: unknown, _level: unknown): number {
|
getActionRepGain: function (_type: unknown, _name: unknown, _level: unknown): number {
|
||||||
|
updateRam("getActionRepGain");
|
||||||
const type = helper.string("getActionRepGain", "type", _type);
|
const type = helper.string("getActionRepGain", "type", _type);
|
||||||
const name = helper.string("getActionRepGain", "name", _name);
|
const name = helper.string("getActionRepGain", "name", _name);
|
||||||
const level = helper.number("getActionRepGain", "level", _level);
|
const level = helper.number("getActionRepGain", "level", _level);
|
||||||
helper.updateDynamicRam("getActionRepGain", getRamCost(player, "bladeburner", "getActionRepGain"));
|
|
||||||
checkBladeburnerAccess("getActionRepGain");
|
checkBladeburnerAccess("getActionRepGain");
|
||||||
const action = getBladeburnerActionObject("getActionRepGain", type, name);
|
const action = getBladeburnerActionObject("getActionRepGain", type, name);
|
||||||
let rewardMultiplier;
|
let rewardMultiplier;
|
||||||
@ -186,9 +186,9 @@ export function NetscriptBladeburner(
|
|||||||
return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank;
|
return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank;
|
||||||
},
|
},
|
||||||
getActionCountRemaining: function (_type: unknown, _name: unknown): number {
|
getActionCountRemaining: function (_type: unknown, _name: unknown): number {
|
||||||
|
updateRam("getActionCountRemaining");
|
||||||
const type = helper.string("getActionCountRemaining", "type", _type);
|
const type = helper.string("getActionCountRemaining", "type", _type);
|
||||||
const name = helper.string("getActionCountRemaining", "name", _name);
|
const name = helper.string("getActionCountRemaining", "name", _name);
|
||||||
helper.updateDynamicRam("getActionCountRemaining", getRamCost(player, "bladeburner", "getActionCountRemaining"));
|
|
||||||
checkBladeburnerAccess("getActionCountRemaining");
|
checkBladeburnerAccess("getActionCountRemaining");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -199,43 +199,43 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getActionMaxLevel: function (_type: unknown, _name: unknown): number {
|
getActionMaxLevel: function (_type: unknown, _name: unknown): number {
|
||||||
|
updateRam("getActionMaxLevel");
|
||||||
const type = helper.string("getActionMaxLevel", "type", _type);
|
const type = helper.string("getActionMaxLevel", "type", _type);
|
||||||
const name = helper.string("getActionMaxLevel", "name", _name);
|
const name = helper.string("getActionMaxLevel", "name", _name);
|
||||||
helper.updateDynamicRam("getActionMaxLevel", getRamCost(player, "bladeburner", "getActionMaxLevel"));
|
|
||||||
checkBladeburnerAccess("getActionMaxLevel");
|
checkBladeburnerAccess("getActionMaxLevel");
|
||||||
const action = getBladeburnerActionObject("getActionMaxLevel", type, name);
|
const action = getBladeburnerActionObject("getActionMaxLevel", type, name);
|
||||||
return action.maxLevel;
|
return action.maxLevel;
|
||||||
},
|
},
|
||||||
getActionCurrentLevel: function (_type: unknown, _name: unknown): number {
|
getActionCurrentLevel: function (_type: unknown, _name: unknown): number {
|
||||||
|
updateRam("getActionCurrentLevel");
|
||||||
const type = helper.string("getActionCurrentLevel", "type", _type);
|
const type = helper.string("getActionCurrentLevel", "type", _type);
|
||||||
const name = helper.string("getActionCurrentLevel", "name", _name);
|
const name = helper.string("getActionCurrentLevel", "name", _name);
|
||||||
helper.updateDynamicRam("getActionCurrentLevel", getRamCost(player, "bladeburner", "getActionCurrentLevel"));
|
|
||||||
checkBladeburnerAccess("getActionCurrentLevel");
|
checkBladeburnerAccess("getActionCurrentLevel");
|
||||||
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
||||||
return action.level;
|
return action.level;
|
||||||
},
|
},
|
||||||
getActionAutolevel: function (_type: unknown, _name: unknown): boolean {
|
getActionAutolevel: function (_type: unknown, _name: unknown): boolean {
|
||||||
|
updateRam("getActionAutolevel");
|
||||||
const type = helper.string("getActionAutolevel", "type", _type);
|
const type = helper.string("getActionAutolevel", "type", _type);
|
||||||
const name = helper.string("getActionAutolevel", "name", _name);
|
const name = helper.string("getActionAutolevel", "name", _name);
|
||||||
helper.updateDynamicRam("getActionAutolevel", getRamCost(player, "bladeburner", "getActionAutolevel"));
|
|
||||||
checkBladeburnerAccess("getActionAutolevel");
|
checkBladeburnerAccess("getActionAutolevel");
|
||||||
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
||||||
return action.autoLevel;
|
return action.autoLevel;
|
||||||
},
|
},
|
||||||
setActionAutolevel: function (_type: unknown, _name: unknown, _autoLevel: unknown = true): void {
|
setActionAutolevel: function (_type: unknown, _name: unknown, _autoLevel: unknown = true): void {
|
||||||
|
updateRam("setActionAutolevel");
|
||||||
const type = helper.string("setActionAutolevel", "type", _type);
|
const type = helper.string("setActionAutolevel", "type", _type);
|
||||||
const name = helper.string("setActionAutolevel", "name", _name);
|
const name = helper.string("setActionAutolevel", "name", _name);
|
||||||
const autoLevel = helper.boolean(_autoLevel);
|
const autoLevel = helper.boolean(_autoLevel);
|
||||||
helper.updateDynamicRam("setActionAutolevel", getRamCost(player, "bladeburner", "setActionAutolevel"));
|
|
||||||
checkBladeburnerAccess("setActionAutolevel");
|
checkBladeburnerAccess("setActionAutolevel");
|
||||||
const action = getBladeburnerActionObject("setActionAutolevel", type, name);
|
const action = getBladeburnerActionObject("setActionAutolevel", type, name);
|
||||||
action.autoLevel = autoLevel;
|
action.autoLevel = autoLevel;
|
||||||
},
|
},
|
||||||
setActionLevel: function (_type: unknown, _name: unknown, _level: unknown = 1): void {
|
setActionLevel: function (_type: unknown, _name: unknown, _level: unknown = 1): void {
|
||||||
|
updateRam("setActionLevel");
|
||||||
const type = helper.string("setActionLevel", "type", _type);
|
const type = helper.string("setActionLevel", "type", _type);
|
||||||
const name = helper.string("setActionLevel", "name", _name);
|
const name = helper.string("setActionLevel", "name", _name);
|
||||||
const level = helper.number("setActionLevel", "level", _level);
|
const level = helper.number("setActionLevel", "level", _level);
|
||||||
helper.updateDynamicRam("setActionLevel", getRamCost(player, "bladeburner", "setActionLevel"));
|
|
||||||
checkBladeburnerAccess("setActionLevel");
|
checkBladeburnerAccess("setActionLevel");
|
||||||
const action = getBladeburnerActionObject("setActionLevel", type, name);
|
const action = getBladeburnerActionObject("setActionLevel", type, name);
|
||||||
if (level < 1 || level > action.maxLevel) {
|
if (level < 1 || level > action.maxLevel) {
|
||||||
@ -247,22 +247,22 @@ export function NetscriptBladeburner(
|
|||||||
action.level = level;
|
action.level = level;
|
||||||
},
|
},
|
||||||
getRank: function (): number {
|
getRank: function (): number {
|
||||||
helper.updateDynamicRam("getRank", getRamCost(player, "bladeburner", "getRank"));
|
updateRam("getRank");
|
||||||
checkBladeburnerAccess("getRank");
|
checkBladeburnerAccess("getRank");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.rank;
|
return bladeburner.rank;
|
||||||
},
|
},
|
||||||
getSkillPoints: function (): number {
|
getSkillPoints: function (): number {
|
||||||
helper.updateDynamicRam("getSkillPoints", getRamCost(player, "bladeburner", "getSkillPoints"));
|
updateRam("getSkillPoints");
|
||||||
checkBladeburnerAccess("getSkillPoints");
|
checkBladeburnerAccess("getSkillPoints");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.skillPoints;
|
return bladeburner.skillPoints;
|
||||||
},
|
},
|
||||||
getSkillLevel: function (_skillName: unknown): number {
|
getSkillLevel: function (_skillName: unknown): number {
|
||||||
|
updateRam("getSkillLevel");
|
||||||
const skillName = helper.string("getSkillLevel", "skillName", _skillName);
|
const skillName = helper.string("getSkillLevel", "skillName", _skillName);
|
||||||
helper.updateDynamicRam("getSkillLevel", getRamCost(player, "bladeburner", "getSkillLevel"));
|
|
||||||
checkBladeburnerAccess("getSkillLevel");
|
checkBladeburnerAccess("getSkillLevel");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -273,8 +273,8 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getSkillUpgradeCost: function (_skillName: unknown): number {
|
getSkillUpgradeCost: function (_skillName: unknown): number {
|
||||||
|
updateRam("getSkillUpgradeCost");
|
||||||
const skillName = helper.string("getSkillUpgradeCost", "skillName", _skillName);
|
const skillName = helper.string("getSkillUpgradeCost", "skillName", _skillName);
|
||||||
helper.updateDynamicRam("getSkillUpgradeCost", getRamCost(player, "bladeburner", "getSkillUpgradeCost"));
|
|
||||||
checkBladeburnerAccess("getSkillUpgradeCost");
|
checkBladeburnerAccess("getSkillUpgradeCost");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -285,8 +285,8 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
upgradeSkill: function (_skillName: unknown): boolean {
|
upgradeSkill: function (_skillName: unknown): boolean {
|
||||||
|
updateRam("upgradeSkill");
|
||||||
const skillName = helper.string("upgradeSkill", "skillName", _skillName);
|
const skillName = helper.string("upgradeSkill", "skillName", _skillName);
|
||||||
helper.updateDynamicRam("upgradeSkill", getRamCost(player, "bladeburner", "upgradeSkill"));
|
|
||||||
checkBladeburnerAccess("upgradeSkill");
|
checkBladeburnerAccess("upgradeSkill");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -297,9 +297,9 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getTeamSize: function (_type: unknown, _name: unknown): number {
|
getTeamSize: function (_type: unknown, _name: unknown): number {
|
||||||
|
updateRam("getTeamSize");
|
||||||
const type = helper.string("getTeamSize", "type", _type);
|
const type = helper.string("getTeamSize", "type", _type);
|
||||||
const name = helper.string("getTeamSize", "name", _name);
|
const name = helper.string("getTeamSize", "name", _name);
|
||||||
helper.updateDynamicRam("getTeamSize", getRamCost(player, "bladeburner", "getTeamSize"));
|
|
||||||
checkBladeburnerAccess("getTeamSize");
|
checkBladeburnerAccess("getTeamSize");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -310,10 +310,10 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setTeamSize: function (_type: unknown, _name: unknown, _size: unknown): number {
|
setTeamSize: function (_type: unknown, _name: unknown, _size: unknown): number {
|
||||||
|
updateRam("setTeamSize");
|
||||||
const type = helper.string("setTeamSize", "type", _type);
|
const type = helper.string("setTeamSize", "type", _type);
|
||||||
const name = helper.string("setTeamSize", "name", _name);
|
const name = helper.string("setTeamSize", "name", _name);
|
||||||
const size = helper.number("setTeamSize", "size", _size);
|
const size = helper.number("setTeamSize", "size", _size);
|
||||||
helper.updateDynamicRam("setTeamSize", getRamCost(player, "bladeburner", "setTeamSize"));
|
|
||||||
checkBladeburnerAccess("setTeamSize");
|
checkBladeburnerAccess("setTeamSize");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
@ -324,11 +324,8 @@ export function NetscriptBladeburner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getCityEstimatedPopulation: function (_cityName: unknown): number {
|
getCityEstimatedPopulation: function (_cityName: unknown): number {
|
||||||
|
updateRam("getCityEstimatedPopulation");
|
||||||
const cityName = helper.string("getCityEstimatedPopulation", "cityName", _cityName);
|
const cityName = helper.string("getCityEstimatedPopulation", "cityName", _cityName);
|
||||||
helper.updateDynamicRam(
|
|
||||||
"getCityEstimatedPopulation",
|
|
||||||
getRamCost(player, "bladeburner", "getCityEstimatedPopulation"),
|
|
||||||
);
|
|
||||||
checkBladeburnerAccess("getCityEstimatedPopulation");
|
checkBladeburnerAccess("getCityEstimatedPopulation");
|
||||||
checkBladeburnerCity("getCityEstimatedPopulation", cityName);
|
checkBladeburnerCity("getCityEstimatedPopulation", cityName);
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
@ -336,8 +333,8 @@ export function NetscriptBladeburner(
|
|||||||
return bladeburner.cities[cityName].popEst;
|
return bladeburner.cities[cityName].popEst;
|
||||||
},
|
},
|
||||||
getCityCommunities: function (_cityName: unknown): number {
|
getCityCommunities: function (_cityName: unknown): number {
|
||||||
|
updateRam("getCityCommunities");
|
||||||
const cityName = helper.string("getCityCommunities", "cityName", _cityName);
|
const cityName = helper.string("getCityCommunities", "cityName", _cityName);
|
||||||
helper.updateDynamicRam("getCityCommunities", getRamCost(player, "bladeburner", "getCityCommunities"));
|
|
||||||
checkBladeburnerAccess("getCityCommunities");
|
checkBladeburnerAccess("getCityCommunities");
|
||||||
checkBladeburnerCity("getCityCommunities", cityName);
|
checkBladeburnerCity("getCityCommunities", cityName);
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
@ -345,8 +342,8 @@ export function NetscriptBladeburner(
|
|||||||
return bladeburner.cities[cityName].comms;
|
return bladeburner.cities[cityName].comms;
|
||||||
},
|
},
|
||||||
getCityChaos: function (_cityName: unknown): number {
|
getCityChaos: function (_cityName: unknown): number {
|
||||||
|
updateRam("getCityChaos");
|
||||||
const cityName = helper.string("getCityChaos", "cityName", _cityName);
|
const cityName = helper.string("getCityChaos", "cityName", _cityName);
|
||||||
helper.updateDynamicRam("getCityChaos", getRamCost(player, "bladeburner", "getCityChaos"));
|
|
||||||
checkBladeburnerAccess("getCityChaos");
|
checkBladeburnerAccess("getCityChaos");
|
||||||
checkBladeburnerCity("getCityChaos", cityName);
|
checkBladeburnerCity("getCityChaos", cityName);
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
@ -354,15 +351,15 @@ export function NetscriptBladeburner(
|
|||||||
return bladeburner.cities[cityName].chaos;
|
return bladeburner.cities[cityName].chaos;
|
||||||
},
|
},
|
||||||
getCity: function (): string {
|
getCity: function (): string {
|
||||||
helper.updateDynamicRam("getCity", getRamCost(player, "bladeburner", "getCity"));
|
updateRam("getCity");
|
||||||
checkBladeburnerAccess("getCityChaos");
|
checkBladeburnerAccess("getCityChaos");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.city;
|
return bladeburner.city;
|
||||||
},
|
},
|
||||||
switchCity: function (_cityName: unknown): boolean {
|
switchCity: function (_cityName: unknown): boolean {
|
||||||
|
updateRam("switchCity");
|
||||||
const cityName = helper.string("switchCity", "cityName", _cityName);
|
const cityName = helper.string("switchCity", "cityName", _cityName);
|
||||||
helper.updateDynamicRam("switchCity", getRamCost(player, "bladeburner", "switchCity"));
|
|
||||||
checkBladeburnerAccess("switchCity");
|
checkBladeburnerAccess("switchCity");
|
||||||
checkBladeburnerCity("switchCity", cityName);
|
checkBladeburnerCity("switchCity", cityName);
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
@ -371,21 +368,21 @@ export function NetscriptBladeburner(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getStamina: function (): [number, number] {
|
getStamina: function (): [number, number] {
|
||||||
helper.updateDynamicRam("getStamina", getRamCost(player, "bladeburner", "getStamina"));
|
updateRam("getStamina");
|
||||||
checkBladeburnerAccess("getStamina");
|
checkBladeburnerAccess("getStamina");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return [bladeburner.stamina, bladeburner.maxStamina];
|
return [bladeburner.stamina, bladeburner.maxStamina];
|
||||||
},
|
},
|
||||||
joinBladeburnerFaction: function (): boolean {
|
joinBladeburnerFaction: function (): boolean {
|
||||||
helper.updateDynamicRam("joinBladeburnerFaction", getRamCost(player, "bladeburner", "joinBladeburnerFaction"));
|
updateRam("joinBladeburnerFaction");
|
||||||
checkBladeburnerAccess("joinBladeburnerFaction", true);
|
checkBladeburnerAccess("joinBladeburnerFaction", true);
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
return bladeburner.joinBladeburnerFactionNetscriptFn(workerScript);
|
return bladeburner.joinBladeburnerFactionNetscriptFn(workerScript);
|
||||||
},
|
},
|
||||||
joinBladeburnerDivision: function (): boolean {
|
joinBladeburnerDivision: function (): boolean {
|
||||||
helper.updateDynamicRam("joinBladeburnerDivision", getRamCost(player, "bladeburner", "joinBladeburnerDivision"));
|
updateRam("joinBladeburnerDivision");
|
||||||
if (player.bitNodeN === 7 || player.sourceFileLvl(7) > 0) {
|
if (player.bitNodeN === 7 || player.sourceFileLvl(7) > 0) {
|
||||||
if (player.bitNodeN === 8) {
|
if (player.bitNodeN === 8) {
|
||||||
return false;
|
return false;
|
||||||
@ -413,7 +410,7 @@ export function NetscriptBladeburner(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getBonusTime: function (): number {
|
getBonusTime: function (): number {
|
||||||
helper.updateDynamicRam("getBonusTime", getRamCost(player, "bladeburner", "getBonusTime"));
|
updateRam("getBonusTime");
|
||||||
checkBladeburnerAccess("getBonusTime");
|
checkBladeburnerAccess("getBonusTime");
|
||||||
const bladeburner = player.bladeburner;
|
const bladeburner = player.bladeburner;
|
||||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
|
@ -24,6 +24,9 @@ export function NetscriptCodingContract(
|
|||||||
return contract;
|
return contract;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRam = (funcName: string): void =>
|
||||||
|
helper.updateDynamicRam(funcName, getRamCost(player, "codingcontract", funcName));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attempt: function (
|
attempt: function (
|
||||||
answer: any,
|
answer: any,
|
||||||
@ -31,9 +34,9 @@ export function NetscriptCodingContract(
|
|||||||
_hostname: unknown = workerScript.hostname,
|
_hostname: unknown = workerScript.hostname,
|
||||||
{ returnReward }: CodingAttemptOptions = { returnReward: false },
|
{ returnReward }: CodingAttemptOptions = { returnReward: false },
|
||||||
): boolean | string {
|
): boolean | string {
|
||||||
|
updateRam("attempt");
|
||||||
const filename = helper.string("attempt", "filename", _filename);
|
const filename = helper.string("attempt", "filename", _filename);
|
||||||
const hostname = helper.string("attempt", "hostname", _hostname);
|
const hostname = helper.string("attempt", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("attempt", getRamCost(player, "codingcontract", "attempt"));
|
|
||||||
const contract = getCodingContract("attempt", hostname, filename);
|
const contract = getCodingContract("attempt", hostname, filename);
|
||||||
|
|
||||||
// Convert answer to string. If the answer is a 2D array, then we have to
|
// Convert answer to string. If the answer is a 2D array, then we have to
|
||||||
@ -83,16 +86,16 @@ export function NetscriptCodingContract(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getContractType: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
getContractType: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
||||||
|
updateRam("getContractType");
|
||||||
const filename = helper.string("getContractType", "filename", _filename);
|
const filename = helper.string("getContractType", "filename", _filename);
|
||||||
const hostname = helper.string("getContractType", "hostname", _hostname);
|
const hostname = helper.string("getContractType", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("getContractType", getRamCost(player, "codingcontract", "getContractType"));
|
|
||||||
const contract = getCodingContract("getContractType", hostname, filename);
|
const contract = getCodingContract("getContractType", hostname, filename);
|
||||||
return contract.getType();
|
return contract.getType();
|
||||||
},
|
},
|
||||||
getData: function (_filename: unknown, _hostname: unknown = workerScript.hostname): any {
|
getData: function (_filename: unknown, _hostname: unknown = workerScript.hostname): any {
|
||||||
|
updateRam("getData");
|
||||||
const filename = helper.string("getContractType", "filename", _filename);
|
const filename = helper.string("getContractType", "filename", _filename);
|
||||||
const hostname = helper.string("getContractType", "hostname", _hostname);
|
const hostname = helper.string("getContractType", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("getData", getRamCost(player, "codingcontract", "getData"));
|
|
||||||
const contract = getCodingContract("getData", hostname, filename);
|
const contract = getCodingContract("getData", hostname, filename);
|
||||||
const data = contract.getData();
|
const data = contract.getData();
|
||||||
if (data.constructor === Array) {
|
if (data.constructor === Array) {
|
||||||
@ -112,16 +115,16 @@ export function NetscriptCodingContract(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getDescription: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
getDescription: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
||||||
|
updateRam("getDescription");
|
||||||
const filename = helper.string("getDescription", "filename", _filename);
|
const filename = helper.string("getDescription", "filename", _filename);
|
||||||
const hostname = helper.string("getDescription", "hostname", _hostname);
|
const hostname = helper.string("getDescription", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("getDescription", getRamCost(player, "codingcontract", "getDescription"));
|
|
||||||
const contract = getCodingContract("getDescription", hostname, filename);
|
const contract = getCodingContract("getDescription", hostname, filename);
|
||||||
return contract.getDescription();
|
return contract.getDescription();
|
||||||
},
|
},
|
||||||
getNumTriesRemaining: function (_filename: unknown, _hostname: unknown = workerScript.hostname): number {
|
getNumTriesRemaining: function (_filename: unknown, _hostname: unknown = workerScript.hostname): number {
|
||||||
|
updateRam("getNumTriesRemaining");
|
||||||
const filename = helper.string("getNumTriesRemaining", "filename", _filename);
|
const filename = helper.string("getNumTriesRemaining", "filename", _filename);
|
||||||
const hostname = helper.string("getNumTriesRemaining", "hostname", _hostname);
|
const hostname = helper.string("getNumTriesRemaining", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("getNumTriesRemaining", getRamCost(player, "codingcontract", "getNumTriesRemaining"));
|
|
||||||
const contract = getCodingContract("getNumTriesRemaining", hostname, filename);
|
const contract = getCodingContract("getNumTriesRemaining", hostname, filename);
|
||||||
return contract.getMaxNumTries() - contract.tries;
|
return contract.getMaxNumTries() - contract.tries;
|
||||||
},
|
},
|
||||||
|
@ -47,10 +47,12 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return task;
|
return task;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRam = (funcName: string): void => helper.updateDynamicRam(funcName, getRamCost(player, "gang", funcName));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
createGang: function (_faction: unknown): boolean {
|
createGang: function (_faction: unknown): boolean {
|
||||||
|
updateRam("createGang");
|
||||||
const faction = helper.string("createGang", "faction", _faction);
|
const faction = helper.string("createGang", "faction", _faction);
|
||||||
helper.updateDynamicRam("createGang", getRamCost(player, "gang", "createGang"));
|
|
||||||
// this list is copied from Faction/ui/Root.tsx
|
// this list is copied from Faction/ui/Root.tsx
|
||||||
|
|
||||||
if (!player.canAccessGang() || !GangConstants.Names.includes(faction)) return false;
|
if (!player.canAccessGang() || !GangConstants.Names.includes(faction)) return false;
|
||||||
@ -62,18 +64,18 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
inGang: function (): boolean {
|
inGang: function (): boolean {
|
||||||
helper.updateDynamicRam("inGang", getRamCost(player, "gang", "inGang"));
|
updateRam("inGang");
|
||||||
return player.inGang();
|
return player.inGang();
|
||||||
},
|
},
|
||||||
getMemberNames: function (): string[] {
|
getMemberNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getMemberNames", getRamCost(player, "gang", "getMemberNames"));
|
updateRam("getMemberNames");
|
||||||
checkGangApiAccess("getMemberNames");
|
checkGangApiAccess("getMemberNames");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
return gang.members.map((member) => member.name);
|
return gang.members.map((member) => member.name);
|
||||||
},
|
},
|
||||||
getGangInformation: function (): GangGenInfo {
|
getGangInformation: function (): GangGenInfo {
|
||||||
helper.updateDynamicRam("getGangInformation", getRamCost(player, "gang", "getGangInformation"));
|
updateRam("getGangInformation");
|
||||||
checkGangApiAccess("getGangInformation");
|
checkGangApiAccess("getGangInformation");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -93,7 +95,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
getOtherGangInformation: function (): GangOtherInfo {
|
getOtherGangInformation: function (): GangOtherInfo {
|
||||||
helper.updateDynamicRam("getOtherGangInformation", getRamCost(player, "gang", "getOtherGangInformation"));
|
updateRam("getOtherGangInformation");
|
||||||
checkGangApiAccess("getOtherGangInformation");
|
checkGangApiAccess("getOtherGangInformation");
|
||||||
const cpy: any = {};
|
const cpy: any = {};
|
||||||
for (const gang of Object.keys(AllGangs)) {
|
for (const gang of Object.keys(AllGangs)) {
|
||||||
@ -103,8 +105,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return cpy;
|
return cpy;
|
||||||
},
|
},
|
||||||
getMemberInformation: function (_memberName: unknown): GangMemberInfo {
|
getMemberInformation: function (_memberName: unknown): GangMemberInfo {
|
||||||
|
updateRam("getMemberInformation");
|
||||||
const memberName = helper.string("getMemberInformation", "memberName", _memberName);
|
const memberName = helper.string("getMemberInformation", "memberName", _memberName);
|
||||||
helper.updateDynamicRam("getMemberInformation", getRamCost(player, "gang", "getMemberInformation"));
|
|
||||||
checkGangApiAccess("getMemberInformation");
|
checkGangApiAccess("getMemberInformation");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -157,15 +159,15 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
canRecruitMember: function (): boolean {
|
canRecruitMember: function (): boolean {
|
||||||
helper.updateDynamicRam("canRecruitMember", getRamCost(player, "gang", "canRecruitMember"));
|
updateRam("canRecruitMember");
|
||||||
checkGangApiAccess("canRecruitMember");
|
checkGangApiAccess("canRecruitMember");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
return gang.canRecruitMember();
|
return gang.canRecruitMember();
|
||||||
},
|
},
|
||||||
recruitMember: function (_memberName: unknown): boolean {
|
recruitMember: function (_memberName: unknown): boolean {
|
||||||
|
updateRam("recruitMember");
|
||||||
const memberName = helper.string("recruitMember", "memberName", _memberName);
|
const memberName = helper.string("recruitMember", "memberName", _memberName);
|
||||||
helper.updateDynamicRam("recruitMember", getRamCost(player, "gang", "recruitMember"));
|
|
||||||
checkGangApiAccess("recruitMember");
|
checkGangApiAccess("recruitMember");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -179,7 +181,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return recruited;
|
return recruited;
|
||||||
},
|
},
|
||||||
getTaskNames: function (): string[] {
|
getTaskNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getTaskNames", getRamCost(player, "gang", "getTaskNames"));
|
updateRam("getTaskNames");
|
||||||
checkGangApiAccess("getTaskNames");
|
checkGangApiAccess("getTaskNames");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -188,9 +190,9 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return tasks;
|
return tasks;
|
||||||
},
|
},
|
||||||
setMemberTask: function (_memberName: unknown, _taskName: unknown): boolean {
|
setMemberTask: function (_memberName: unknown, _taskName: unknown): boolean {
|
||||||
|
updateRam("setMemberTask");
|
||||||
const memberName = helper.string("setMemberTask", "memberName", _memberName);
|
const memberName = helper.string("setMemberTask", "memberName", _memberName);
|
||||||
const taskName = helper.string("setMemberTask", "taskName", _taskName);
|
const taskName = helper.string("setMemberTask", "taskName", _taskName);
|
||||||
helper.updateDynamicRam("setMemberTask", getRamCost(player, "gang", "setMemberTask"));
|
|
||||||
checkGangApiAccess("setMemberTask");
|
checkGangApiAccess("setMemberTask");
|
||||||
const member = getGangMember("setMemberTask", memberName);
|
const member = getGangMember("setMemberTask", memberName);
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
@ -219,8 +221,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return success;
|
return success;
|
||||||
},
|
},
|
||||||
getTaskStats: function (_taskName: unknown): GangTaskStats {
|
getTaskStats: function (_taskName: unknown): GangTaskStats {
|
||||||
|
updateRam("getTaskStats");
|
||||||
const taskName = helper.string("getTaskStats", "taskName", _taskName);
|
const taskName = helper.string("getTaskStats", "taskName", _taskName);
|
||||||
helper.updateDynamicRam("getTaskStats", getRamCost(player, "gang", "getTaskStats"));
|
|
||||||
checkGangApiAccess("getTaskStats");
|
checkGangApiAccess("getTaskStats");
|
||||||
const task = getGangTask("getTaskStats", taskName);
|
const task = getGangTask("getTaskStats", taskName);
|
||||||
const copy = Object.assign({}, task);
|
const copy = Object.assign({}, task);
|
||||||
@ -228,13 +230,13 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return copy;
|
return copy;
|
||||||
},
|
},
|
||||||
getEquipmentNames: function (): string[] {
|
getEquipmentNames: function (): string[] {
|
||||||
helper.updateDynamicRam("getEquipmentNames", getRamCost(player, "gang", "getEquipmentNames"));
|
updateRam("getEquipmentNames");
|
||||||
checkGangApiAccess("getEquipmentNames");
|
checkGangApiAccess("getEquipmentNames");
|
||||||
return Object.keys(GangMemberUpgrades);
|
return Object.keys(GangMemberUpgrades);
|
||||||
},
|
},
|
||||||
getEquipmentCost: function (_equipName: any): number {
|
getEquipmentCost: function (_equipName: any): number {
|
||||||
|
updateRam("getEquipmentCost");
|
||||||
const equipName = helper.string("getEquipmentCost", "equipName", _equipName);
|
const equipName = helper.string("getEquipmentCost", "equipName", _equipName);
|
||||||
helper.updateDynamicRam("getEquipmentCost", getRamCost(player, "gang", "getEquipmentCost"));
|
|
||||||
checkGangApiAccess("getEquipmentCost");
|
checkGangApiAccess("getEquipmentCost");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -243,16 +245,16 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return gang.getUpgradeCost(upg);
|
return gang.getUpgradeCost(upg);
|
||||||
},
|
},
|
||||||
getEquipmentType: function (_equipName: unknown): string {
|
getEquipmentType: function (_equipName: unknown): string {
|
||||||
|
updateRam("getEquipmentType");
|
||||||
const equipName = helper.string("getEquipmentType", "equipName", _equipName);
|
const equipName = helper.string("getEquipmentType", "equipName", _equipName);
|
||||||
helper.updateDynamicRam("getEquipmentType", getRamCost(player, "gang", "getEquipmentType"));
|
|
||||||
checkGangApiAccess("getEquipmentType");
|
checkGangApiAccess("getEquipmentType");
|
||||||
const upg = GangMemberUpgrades[equipName];
|
const upg = GangMemberUpgrades[equipName];
|
||||||
if (upg == null) return "";
|
if (upg == null) return "";
|
||||||
return upg.getType();
|
return upg.getType();
|
||||||
},
|
},
|
||||||
getEquipmentStats: function (_equipName: unknown): EquipmentStats {
|
getEquipmentStats: function (_equipName: unknown): EquipmentStats {
|
||||||
|
updateRam("getEquipmentStats");
|
||||||
const equipName = helper.string("getEquipmentStats", "equipName", _equipName);
|
const equipName = helper.string("getEquipmentStats", "equipName", _equipName);
|
||||||
helper.updateDynamicRam("getEquipmentStats", getRamCost(player, "gang", "getEquipmentStats"));
|
|
||||||
checkGangApiAccess("getEquipmentStats");
|
checkGangApiAccess("getEquipmentStats");
|
||||||
const equipment = GangMemberUpgrades[equipName];
|
const equipment = GangMemberUpgrades[equipName];
|
||||||
if (!equipment) {
|
if (!equipment) {
|
||||||
@ -262,9 +264,9 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return Object.assign({}, typecheck) as any;
|
return Object.assign({}, typecheck) as any;
|
||||||
},
|
},
|
||||||
purchaseEquipment: function (_memberName: unknown, _equipName: unknown): boolean {
|
purchaseEquipment: function (_memberName: unknown, _equipName: unknown): boolean {
|
||||||
|
updateRam("purchaseEquipment");
|
||||||
const memberName = helper.string("purchaseEquipment", "memberName", _memberName);
|
const memberName = helper.string("purchaseEquipment", "memberName", _memberName);
|
||||||
const equipName = helper.string("purchaseEquipment", "equipName", _equipName);
|
const equipName = helper.string("purchaseEquipment", "equipName", _equipName);
|
||||||
helper.updateDynamicRam("purchaseEquipment", getRamCost(player, "gang", "purchaseEquipment"));
|
|
||||||
checkGangApiAccess("purchaseEquipment");
|
checkGangApiAccess("purchaseEquipment");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -284,8 +286,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
ascendMember: function (_memberName: unknown): GangMemberAscension | undefined {
|
ascendMember: function (_memberName: unknown): GangMemberAscension | undefined {
|
||||||
|
updateRam("ascendMember");
|
||||||
const memberName = helper.string("ascendMember", "memberName", _memberName);
|
const memberName = helper.string("ascendMember", "memberName", _memberName);
|
||||||
helper.updateDynamicRam("ascendMember", getRamCost(player, "gang", "ascendMember"));
|
|
||||||
checkGangApiAccess("ascendMember");
|
checkGangApiAccess("ascendMember");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -294,8 +296,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return gang.ascendMember(member, workerScript);
|
return gang.ascendMember(member, workerScript);
|
||||||
},
|
},
|
||||||
getAscensionResult: function (_memberName: unknown): GangMemberAscension | undefined {
|
getAscensionResult: function (_memberName: unknown): GangMemberAscension | undefined {
|
||||||
|
updateRam("getAscensionResult");
|
||||||
const memberName = helper.string("getAscensionResult", "memberName", _memberName);
|
const memberName = helper.string("getAscensionResult", "memberName", _memberName);
|
||||||
helper.updateDynamicRam("getAscensionResult", getRamCost(player, "gang", "getAscensionResult"));
|
|
||||||
checkGangApiAccess("getAscensionResult");
|
checkGangApiAccess("getAscensionResult");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -307,8 +309,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
setTerritoryWarfare: function (_engage: unknown): void {
|
setTerritoryWarfare: function (_engage: unknown): void {
|
||||||
|
updateRam("setTerritoryWarfare");
|
||||||
const engage = helper.boolean(_engage);
|
const engage = helper.boolean(_engage);
|
||||||
helper.updateDynamicRam("setTerritoryWarfare", getRamCost(player, "gang", "setTerritoryWarfare"));
|
|
||||||
checkGangApiAccess("setTerritoryWarfare");
|
checkGangApiAccess("setTerritoryWarfare");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -321,8 +323,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getChanceToWinClash: function (_otherGang: unknown): number {
|
getChanceToWinClash: function (_otherGang: unknown): number {
|
||||||
|
updateRam("getChanceToWinClash");
|
||||||
const otherGang = helper.string("getChanceToWinClash", "otherGang", _otherGang);
|
const otherGang = helper.string("getChanceToWinClash", "otherGang", _otherGang);
|
||||||
helper.updateDynamicRam("getChanceToWinClash", getRamCost(player, "gang", "getChanceToWinClash"));
|
|
||||||
checkGangApiAccess("getChanceToWinClash");
|
checkGangApiAccess("getChanceToWinClash");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
@ -336,7 +338,7 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
|||||||
return playerPower / (otherPower + playerPower);
|
return playerPower / (otherPower + playerPower);
|
||||||
},
|
},
|
||||||
getBonusTime: function (): number {
|
getBonusTime: function (): number {
|
||||||
helper.updateDynamicRam("getBonusTime", getRamCost(player, "gang", "getBonusTime"));
|
updateRam("getBonusTime");
|
||||||
checkGangApiAccess("getBonusTime");
|
checkGangApiAccess("getBonusTime");
|
||||||
const gang = player.gang;
|
const gang = player.gang;
|
||||||
if (gang === null) throw new Error("Should not be called without Gang");
|
if (gang === null) throw new Error("Should not be called without Gang");
|
||||||
|
@ -20,10 +20,13 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRam = (funcName: string): void =>
|
||||||
|
helper.updateDynamicRam(funcName, getRamCost(player, "grafting", funcName));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getAugmentationGraftPrice: (_augName: unknown): number => {
|
getAugmentationGraftPrice: (_augName: unknown): number => {
|
||||||
|
updateRam("getAugmentationGraftPrice");
|
||||||
const augName = helper.string("getAugmentationGraftPrice", "augName", _augName);
|
const augName = helper.string("getAugmentationGraftPrice", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationGraftPrice", getRamCost(player, "grafting", "getAugmentationGraftPrice"));
|
|
||||||
checkGraftingAPIAccess("getAugmentationGraftPrice");
|
checkGraftingAPIAccess("getAugmentationGraftPrice");
|
||||||
if (!Augmentations.hasOwnProperty(augName)) {
|
if (!Augmentations.hasOwnProperty(augName)) {
|
||||||
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`);
|
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`);
|
||||||
@ -33,8 +36,8 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
|
|||||||
},
|
},
|
||||||
|
|
||||||
getAugmentationGraftTime: (_augName: string): number => {
|
getAugmentationGraftTime: (_augName: string): number => {
|
||||||
|
updateRam("getAugmentationGraftTime");
|
||||||
const augName = helper.string("getAugmentationGraftTime", "augName", _augName);
|
const augName = helper.string("getAugmentationGraftTime", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationGraftTime", getRamCost(player, "grafting", "getAugmentationGraftTime"));
|
|
||||||
checkGraftingAPIAccess("getAugmentationGraftTime");
|
checkGraftingAPIAccess("getAugmentationGraftTime");
|
||||||
if (!Augmentations.hasOwnProperty(augName)) {
|
if (!Augmentations.hasOwnProperty(augName)) {
|
||||||
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`);
|
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`);
|
||||||
@ -44,9 +47,9 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
|
|||||||
},
|
},
|
||||||
|
|
||||||
graftAugmentation: (_augName: string, _focus: unknown = true): boolean => {
|
graftAugmentation: (_augName: string, _focus: unknown = true): boolean => {
|
||||||
|
updateRam("graftAugmentation");
|
||||||
const augName = helper.string("graftAugmentation", "augName", _augName);
|
const augName = helper.string("graftAugmentation", "augName", _augName);
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("graftAugmentation", getRamCost(player, "grafting", "graftAugmentation"));
|
|
||||||
checkGraftingAPIAccess("graftAugmentation");
|
checkGraftingAPIAccess("graftAugmentation");
|
||||||
if (player.city !== CityName.NewTokyo) {
|
if (player.city !== CityName.NewTokyo) {
|
||||||
throw helper.makeRuntimeErrorMsg(
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
@ -6,7 +6,6 @@ import { startWorkerScript } from "../NetscriptWorker";
|
|||||||
import { Augmentation } from "../Augmentation/Augmentation";
|
import { Augmentation } from "../Augmentation/Augmentation";
|
||||||
import { Augmentations } from "../Augmentation/Augmentations";
|
import { Augmentations } from "../Augmentation/Augmentations";
|
||||||
import { augmentationExists, installAugmentations } from "../Augmentation/AugmentationHelpers";
|
import { augmentationExists, installAugmentations } from "../Augmentation/AugmentationHelpers";
|
||||||
import { prestigeAugmentation } from "../Prestige";
|
|
||||||
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
||||||
import { killWorkerScript } from "../Netscript/killWorkerScript";
|
import { killWorkerScript } from "../Netscript/killWorkerScript";
|
||||||
import { CONSTANTS } from "../Constants";
|
import { CONSTANTS } from "../Constants";
|
||||||
@ -96,10 +95,12 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRam = (funcName: string): void => helper.updateDynamicRam(funcName, getRamCost(player, funcName));
|
||||||
return {
|
return {
|
||||||
getOwnedAugmentations: function (_purchased: unknown = false): string[] {
|
getOwnedAugmentations: function (_purchased: unknown = false): string[] {
|
||||||
|
updateRam("getOwnedAugmentations");
|
||||||
const purchased = helper.boolean(_purchased);
|
const purchased = helper.boolean(_purchased);
|
||||||
helper.updateDynamicRam("getOwnedAugmentations", getRamCost(player, "getOwnedAugmentations"));
|
|
||||||
helper.checkSingularityAccess("getOwnedAugmentations");
|
helper.checkSingularityAccess("getOwnedAugmentations");
|
||||||
const res = [];
|
const res = [];
|
||||||
for (let i = 0; i < player.augmentations.length; ++i) {
|
for (let i = 0; i < player.augmentations.length; ++i) {
|
||||||
@ -113,52 +114,52 @@ export function NetscriptSingularity(
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
getAugmentationsFromFaction: function (_facName: unknown): string[] {
|
getAugmentationsFromFaction: function (_facName: unknown): string[] {
|
||||||
|
updateRam("getAugmentationsFromFaction");
|
||||||
const facName = helper.string("getAugmentationsFromFaction", "facName", _facName);
|
const facName = helper.string("getAugmentationsFromFaction", "facName", _facName);
|
||||||
helper.updateDynamicRam("getAugmentationsFromFaction", getRamCost(player, "getAugmentationsFromFaction"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationsFromFaction");
|
helper.checkSingularityAccess("getAugmentationsFromFaction");
|
||||||
const faction = getFaction("getAugmentationsFromFaction", facName);
|
const faction = getFaction("getAugmentationsFromFaction", facName);
|
||||||
|
|
||||||
return getFactionAugmentationsFiltered(player, faction);
|
return getFactionAugmentationsFiltered(player, faction);
|
||||||
},
|
},
|
||||||
getAugmentationCost: function (_augName: unknown): [number, number] {
|
getAugmentationCost: function (_augName: unknown): [number, number] {
|
||||||
|
updateRam("getAugmentationCost");
|
||||||
const augName = helper.string("getAugmentationCost", "augName", _augName);
|
const augName = helper.string("getAugmentationCost", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationCost", getRamCost(player, "getAugmentationCost"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationCost");
|
helper.checkSingularityAccess("getAugmentationCost");
|
||||||
const aug = getAugmentation("getAugmentationCost", augName);
|
const aug = getAugmentation("getAugmentationCost", augName);
|
||||||
return [aug.baseRepRequirement, aug.baseCost];
|
return [aug.baseRepRequirement, aug.baseCost];
|
||||||
},
|
},
|
||||||
getAugmentationPrereq: function (_augName: unknown): string[] {
|
getAugmentationPrereq: function (_augName: unknown): string[] {
|
||||||
|
updateRam("getAugmentationPrereq");
|
||||||
const augName = helper.string("getAugmentationPrereq", "augName", _augName);
|
const augName = helper.string("getAugmentationPrereq", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationPrereq", getRamCost(player, "getAugmentationPrereq"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationPrereq");
|
helper.checkSingularityAccess("getAugmentationPrereq");
|
||||||
const aug = getAugmentation("getAugmentationPrereq", augName);
|
const aug = getAugmentation("getAugmentationPrereq", augName);
|
||||||
return aug.prereqs.slice();
|
return aug.prereqs.slice();
|
||||||
},
|
},
|
||||||
getAugmentationPrice: function (_augName: unknown): number {
|
getAugmentationPrice: function (_augName: unknown): number {
|
||||||
|
updateRam("getAugmentationPrice");
|
||||||
const augName = helper.string("getAugmentationPrice", "augName", _augName);
|
const augName = helper.string("getAugmentationPrice", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationPrice", getRamCost(player, "getAugmentationPrice"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationPrice");
|
helper.checkSingularityAccess("getAugmentationPrice");
|
||||||
const aug = getAugmentation("getAugmentationPrice", augName);
|
const aug = getAugmentation("getAugmentationPrice", augName);
|
||||||
return aug.baseCost;
|
return aug.baseCost;
|
||||||
},
|
},
|
||||||
getAugmentationRepReq: function (_augName: unknown): number {
|
getAugmentationRepReq: function (_augName: unknown): number {
|
||||||
|
updateRam("getAugmentationRepReq");
|
||||||
const augName = helper.string("getAugmentationRepReq", "augName", _augName);
|
const augName = helper.string("getAugmentationRepReq", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationRepReq", getRamCost(player, "getAugmentationRepReq"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationRepReq");
|
helper.checkSingularityAccess("getAugmentationRepReq");
|
||||||
const aug = getAugmentation("getAugmentationRepReq", augName);
|
const aug = getAugmentation("getAugmentationRepReq", augName);
|
||||||
return aug.baseRepRequirement;
|
return aug.baseRepRequirement;
|
||||||
},
|
},
|
||||||
getAugmentationStats: function (_augName: unknown): AugmentationStats {
|
getAugmentationStats: function (_augName: unknown): AugmentationStats {
|
||||||
|
updateRam("getAugmentationStats");
|
||||||
const augName = helper.string("getAugmentationStats", "augName", _augName);
|
const augName = helper.string("getAugmentationStats", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationStats", getRamCost(player, "getAugmentationStats"));
|
|
||||||
helper.checkSingularityAccess("getAugmentationStats");
|
helper.checkSingularityAccess("getAugmentationStats");
|
||||||
const aug = getAugmentation("getAugmentationStats", augName);
|
const aug = getAugmentation("getAugmentationStats", augName);
|
||||||
return Object.assign({}, aug.mults);
|
return Object.assign({}, aug.mults);
|
||||||
},
|
},
|
||||||
purchaseAugmentation: function (_facName: unknown, _augName: unknown): boolean {
|
purchaseAugmentation: function (_facName: unknown, _augName: unknown): boolean {
|
||||||
|
updateRam("purchaseAugmentation");
|
||||||
const facName = helper.string("purchaseAugmentation", "facName", _facName);
|
const facName = helper.string("purchaseAugmentation", "facName", _facName);
|
||||||
const augName = helper.string("purchaseAugmentation", "augName", _augName);
|
const augName = helper.string("purchaseAugmentation", "augName", _augName);
|
||||||
helper.updateDynamicRam("purchaseAugmentation", getRamCost(player, "purchaseAugmentation"));
|
|
||||||
helper.checkSingularityAccess("purchaseAugmentation");
|
helper.checkSingularityAccess("purchaseAugmentation");
|
||||||
const fac = getFaction("purchaseAugmentation", facName);
|
const fac = getFaction("purchaseAugmentation", facName);
|
||||||
const aug = getAugmentation("purchaseAugmentation", augName);
|
const aug = getAugmentation("purchaseAugmentation", augName);
|
||||||
@ -204,13 +205,13 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
softReset: function (_cbScript: unknown): void {
|
softReset: function (_cbScript: unknown): void {
|
||||||
|
updateRam("softReset");
|
||||||
const cbScript = helper.string("softReset", "cbScript", _cbScript);
|
const cbScript = helper.string("softReset", "cbScript", _cbScript);
|
||||||
helper.updateDynamicRam("softReset", getRamCost(player, "softReset"));
|
|
||||||
helper.checkSingularityAccess("softReset");
|
helper.checkSingularityAccess("softReset");
|
||||||
|
|
||||||
workerScript.log("softReset", () => "Soft resetting. This will cause this script to be killed");
|
workerScript.log("softReset", () => "Soft resetting. This will cause this script to be killed");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
prestigeAugmentation();
|
installAugmentations(true);
|
||||||
runAfterReset(cbScript);
|
runAfterReset(cbScript);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
@ -219,8 +220,8 @@ export function NetscriptSingularity(
|
|||||||
killWorkerScript(workerScript);
|
killWorkerScript(workerScript);
|
||||||
},
|
},
|
||||||
installAugmentations: function (_cbScript: unknown): boolean {
|
installAugmentations: function (_cbScript: unknown): boolean {
|
||||||
|
updateRam("installAugmentations");
|
||||||
const cbScript = helper.string("installAugmentations", "cbScript", _cbScript);
|
const cbScript = helper.string("installAugmentations", "cbScript", _cbScript);
|
||||||
helper.updateDynamicRam("installAugmentations", getRamCost(player, "installAugmentations"));
|
|
||||||
helper.checkSingularityAccess("installAugmentations");
|
helper.checkSingularityAccess("installAugmentations");
|
||||||
|
|
||||||
if (player.queuedAugmentations.length === 0) {
|
if (player.queuedAugmentations.length === 0) {
|
||||||
@ -243,8 +244,8 @@ export function NetscriptSingularity(
|
|||||||
},
|
},
|
||||||
|
|
||||||
goToLocation: function (_locationName: unknown): boolean {
|
goToLocation: function (_locationName: unknown): boolean {
|
||||||
|
updateRam("goToLocation");
|
||||||
const locationName = helper.string("goToLocation", "locationName", _locationName);
|
const locationName = helper.string("goToLocation", "locationName", _locationName);
|
||||||
helper.updateDynamicRam("goToLocation", getRamCost(player, "goToLocation"));
|
|
||||||
helper.checkSingularityAccess("goToLocation");
|
helper.checkSingularityAccess("goToLocation");
|
||||||
const location = Object.values(Locations).find((l) => l.name === locationName);
|
const location = Object.values(Locations).find((l) => l.name === locationName);
|
||||||
if (!location) {
|
if (!location) {
|
||||||
@ -260,10 +261,10 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
universityCourse: function (_universityName: unknown, _className: unknown, _focus: unknown = true): boolean {
|
universityCourse: function (_universityName: unknown, _className: unknown, _focus: unknown = true): boolean {
|
||||||
|
updateRam("universityCourse");
|
||||||
const universityName = helper.string("universityCourse", "universityName", _universityName);
|
const universityName = helper.string("universityCourse", "universityName", _universityName);
|
||||||
const className = helper.string("universityCourse", "className", _className);
|
const className = helper.string("universityCourse", "className", _className);
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("universityCourse", getRamCost(player, "universityCourse"));
|
|
||||||
helper.checkSingularityAccess("universityCourse");
|
helper.checkSingularityAccess("universityCourse");
|
||||||
const wasFocusing = player.focus;
|
const wasFocusing = player.focus;
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
@ -351,10 +352,10 @@ export function NetscriptSingularity(
|
|||||||
},
|
},
|
||||||
|
|
||||||
gymWorkout: function (_gymName: unknown, _stat: unknown, _focus: unknown = true): boolean {
|
gymWorkout: function (_gymName: unknown, _stat: unknown, _focus: unknown = true): boolean {
|
||||||
|
updateRam("gymWorkout");
|
||||||
const gymName = helper.string("gymWorkout", "gymName", _gymName);
|
const gymName = helper.string("gymWorkout", "gymName", _gymName);
|
||||||
const stat = helper.string("gymWorkout", "stat", _stat);
|
const stat = helper.string("gymWorkout", "stat", _stat);
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("gymWorkout", getRamCost(player, "gymWorkout"));
|
|
||||||
helper.checkSingularityAccess("gymWorkout");
|
helper.checkSingularityAccess("gymWorkout");
|
||||||
const wasFocusing = player.focus;
|
const wasFocusing = player.focus;
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
@ -466,8 +467,8 @@ export function NetscriptSingularity(
|
|||||||
},
|
},
|
||||||
|
|
||||||
travelToCity: function (_cityName: unknown): boolean {
|
travelToCity: function (_cityName: unknown): boolean {
|
||||||
|
updateRam("travelToCity");
|
||||||
const cityName = helper.city("travelToCity", "cityName", _cityName);
|
const cityName = helper.city("travelToCity", "cityName", _cityName);
|
||||||
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
|
||||||
helper.checkSingularityAccess("travelToCity");
|
helper.checkSingularityAccess("travelToCity");
|
||||||
|
|
||||||
switch (cityName) {
|
switch (cityName) {
|
||||||
@ -492,7 +493,7 @@ export function NetscriptSingularity(
|
|||||||
},
|
},
|
||||||
|
|
||||||
purchaseTor: function (): boolean {
|
purchaseTor: function (): boolean {
|
||||||
helper.updateDynamicRam("purchaseTor", getRamCost(player, "purchaseTor"));
|
updateRam("purchaseTor");
|
||||||
helper.checkSingularityAccess("purchaseTor");
|
helper.checkSingularityAccess("purchaseTor");
|
||||||
|
|
||||||
if (player.hasTorRouter()) {
|
if (player.hasTorRouter()) {
|
||||||
@ -524,8 +525,8 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
purchaseProgram: function (_programName: unknown): boolean {
|
purchaseProgram: function (_programName: unknown): boolean {
|
||||||
|
updateRam("purchaseProgram");
|
||||||
const programName = helper.string("purchaseProgram", "programName", _programName).toLowerCase();
|
const programName = helper.string("purchaseProgram", "programName", _programName).toLowerCase();
|
||||||
helper.updateDynamicRam("purchaseProgram", getRamCost(player, "purchaseProgram"));
|
|
||||||
helper.checkSingularityAccess("purchaseProgram");
|
helper.checkSingularityAccess("purchaseProgram");
|
||||||
|
|
||||||
if (!player.hasTorRouter()) {
|
if (!player.hasTorRouter()) {
|
||||||
@ -562,13 +563,13 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getCurrentServer: function (): string {
|
getCurrentServer: function (): string {
|
||||||
helper.updateDynamicRam("getCurrentServer", getRamCost(player, "getCurrentServer"));
|
updateRam("getCurrentServer");
|
||||||
helper.checkSingularityAccess("getCurrentServer");
|
helper.checkSingularityAccess("getCurrentServer");
|
||||||
return player.getCurrentServer().hostname;
|
return player.getCurrentServer().hostname;
|
||||||
},
|
},
|
||||||
connect: function (_hostname: unknown): boolean {
|
connect: function (_hostname: unknown): boolean {
|
||||||
|
updateRam("connect");
|
||||||
const hostname = helper.string("purchaseProgram", "hostname", _hostname);
|
const hostname = helper.string("purchaseProgram", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("connect", getRamCost(player, "connect"));
|
|
||||||
helper.checkSingularityAccess("connect");
|
helper.checkSingularityAccess("connect");
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
throw helper.makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
throw helper.makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`);
|
||||||
@ -603,13 +604,13 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
manualHack: function (): Promise<number> {
|
manualHack: function (): Promise<number> {
|
||||||
helper.updateDynamicRam("manualHack", getRamCost(player, "manualHack"));
|
updateRam("manualHack");
|
||||||
helper.checkSingularityAccess("manualHack");
|
helper.checkSingularityAccess("manualHack");
|
||||||
const server = player.getCurrentServer();
|
const server = player.getCurrentServer();
|
||||||
return helper.hack(server.hostname, true);
|
return helper.hack(server.hostname, true);
|
||||||
},
|
},
|
||||||
installBackdoor: function (): Promise<void> {
|
installBackdoor: function (): Promise<void> {
|
||||||
helper.updateDynamicRam("installBackdoor", getRamCost(player, "installBackdoor"));
|
updateRam("installBackdoor");
|
||||||
helper.checkSingularityAccess("installBackdoor");
|
helper.checkSingularityAccess("installBackdoor");
|
||||||
const baseserver = player.getCurrentServer();
|
const baseserver = player.getCurrentServer();
|
||||||
if (!(baseserver instanceof Server)) {
|
if (!(baseserver instanceof Server)) {
|
||||||
@ -642,13 +643,13 @@ export function NetscriptSingularity(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
isFocused: function (): boolean {
|
isFocused: function (): boolean {
|
||||||
helper.updateDynamicRam("isFocused", getRamCost(player, "isFocused"));
|
updateRam("isFocused");
|
||||||
helper.checkSingularityAccess("isFocused");
|
helper.checkSingularityAccess("isFocused");
|
||||||
return player.focus;
|
return player.focus;
|
||||||
},
|
},
|
||||||
setFocus: function (_focus: unknown): boolean {
|
setFocus: function (_focus: unknown): boolean {
|
||||||
|
updateRam("setFocus");
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("setFocus", getRamCost(player, "setFocus"));
|
|
||||||
helper.checkSingularityAccess("setFocus");
|
helper.checkSingularityAccess("setFocus");
|
||||||
if (!player.isWorking) {
|
if (!player.isWorking) {
|
||||||
throw helper.makeRuntimeErrorMsg("setFocus", "Not currently working");
|
throw helper.makeRuntimeErrorMsg("setFocus", "Not currently working");
|
||||||
@ -676,7 +677,7 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getStats: function (): PlayerSkills {
|
getStats: function (): PlayerSkills {
|
||||||
helper.updateDynamicRam("getStats", getRamCost(player, "getStats"));
|
updateRam("getStats");
|
||||||
helper.checkSingularityAccess("getStats");
|
helper.checkSingularityAccess("getStats");
|
||||||
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
||||||
|
|
||||||
@ -691,7 +692,7 @@ export function NetscriptSingularity(
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
getCharacterInformation: function (): CharacterInfo {
|
getCharacterInformation: function (): CharacterInfo {
|
||||||
helper.updateDynamicRam("getCharacterInformation", getRamCost(player, "getCharacterInformation"));
|
updateRam("getCharacterInformation");
|
||||||
helper.checkSingularityAccess("getCharacterInformation");
|
helper.checkSingularityAccess("getCharacterInformation");
|
||||||
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
||||||
|
|
||||||
@ -741,7 +742,7 @@ export function NetscriptSingularity(
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
hospitalize: function (): void {
|
hospitalize: function (): void {
|
||||||
helper.updateDynamicRam("hospitalize", getRamCost(player, "hospitalize"));
|
updateRam("hospitalize");
|
||||||
helper.checkSingularityAccess("hospitalize");
|
helper.checkSingularityAccess("hospitalize");
|
||||||
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
||||||
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
||||||
@ -750,12 +751,12 @@ export function NetscriptSingularity(
|
|||||||
player.hospitalize();
|
player.hospitalize();
|
||||||
},
|
},
|
||||||
isBusy: function (): boolean {
|
isBusy: function (): boolean {
|
||||||
helper.updateDynamicRam("isBusy", getRamCost(player, "isBusy"));
|
updateRam("isBusy");
|
||||||
helper.checkSingularityAccess("isBusy");
|
helper.checkSingularityAccess("isBusy");
|
||||||
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
||||||
},
|
},
|
||||||
stopAction: function (): boolean {
|
stopAction: function (): boolean {
|
||||||
helper.updateDynamicRam("stopAction", getRamCost(player, "stopAction"));
|
updateRam("stopAction");
|
||||||
helper.checkSingularityAccess("stopAction");
|
helper.checkSingularityAccess("stopAction");
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
if (player.focus) {
|
if (player.focus) {
|
||||||
@ -769,7 +770,7 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
upgradeHomeCores: function (): boolean {
|
upgradeHomeCores: function (): boolean {
|
||||||
helper.updateDynamicRam("upgradeHomeCores", getRamCost(player, "upgradeHomeCores"));
|
updateRam("upgradeHomeCores");
|
||||||
helper.checkSingularityAccess("upgradeHomeCores");
|
helper.checkSingularityAccess("upgradeHomeCores");
|
||||||
|
|
||||||
// Check if we're at max cores
|
// Check if we're at max cores
|
||||||
@ -799,13 +800,13 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getUpgradeHomeCoresCost: function (): number {
|
getUpgradeHomeCoresCost: function (): number {
|
||||||
helper.updateDynamicRam("getUpgradeHomeCoresCost", getRamCost(player, "getUpgradeHomeCoresCost"));
|
updateRam("getUpgradeHomeCoresCost");
|
||||||
helper.checkSingularityAccess("getUpgradeHomeCoresCost");
|
helper.checkSingularityAccess("getUpgradeHomeCoresCost");
|
||||||
|
|
||||||
return player.getUpgradeHomeCoresCost();
|
return player.getUpgradeHomeCoresCost();
|
||||||
},
|
},
|
||||||
upgradeHomeRam: function (): boolean {
|
upgradeHomeRam: function (): boolean {
|
||||||
helper.updateDynamicRam("upgradeHomeRam", getRamCost(player, "upgradeHomeRam"));
|
updateRam("upgradeHomeRam");
|
||||||
helper.checkSingularityAccess("upgradeHomeRam");
|
helper.checkSingularityAccess("upgradeHomeRam");
|
||||||
|
|
||||||
// Check if we're at max RAM
|
// Check if we're at max RAM
|
||||||
@ -838,15 +839,15 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getUpgradeHomeRamCost: function (): number {
|
getUpgradeHomeRamCost: function (): number {
|
||||||
helper.updateDynamicRam("getUpgradeHomeRamCost", getRamCost(player, "getUpgradeHomeRamCost"));
|
updateRam("getUpgradeHomeRamCost");
|
||||||
helper.checkSingularityAccess("getUpgradeHomeRamCost");
|
helper.checkSingularityAccess("getUpgradeHomeRamCost");
|
||||||
|
|
||||||
return player.getUpgradeHomeRamCost();
|
return player.getUpgradeHomeRamCost();
|
||||||
},
|
},
|
||||||
workForCompany: function (_companyName: unknown, _focus: unknown = true): boolean {
|
workForCompany: function (_companyName: unknown, _focus: unknown = true): boolean {
|
||||||
|
updateRam("workForCompany");
|
||||||
let companyName = helper.string("workForCompany", "companyName", _companyName);
|
let companyName = helper.string("workForCompany", "companyName", _companyName);
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("workForCompany", getRamCost(player, "workForCompany"));
|
|
||||||
helper.checkSingularityAccess("workForCompany");
|
helper.checkSingularityAccess("workForCompany");
|
||||||
|
|
||||||
// Sanitize input
|
// Sanitize input
|
||||||
@ -900,9 +901,9 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
applyToCompany: function (_companyName: unknown, _field: unknown): boolean {
|
applyToCompany: function (_companyName: unknown, _field: unknown): boolean {
|
||||||
|
updateRam("applyToCompany");
|
||||||
const companyName = helper.string("applyToCompany", "companyName", _companyName);
|
const companyName = helper.string("applyToCompany", "companyName", _companyName);
|
||||||
const field = helper.string("applyToCompany", "field", _field);
|
const field = helper.string("applyToCompany", "field", _field);
|
||||||
helper.updateDynamicRam("applyToCompany", getRamCost(player, "applyToCompany"));
|
|
||||||
helper.checkSingularityAccess("applyToCompany");
|
helper.checkSingularityAccess("applyToCompany");
|
||||||
getCompany("applyToCompany", companyName);
|
getCompany("applyToCompany", companyName);
|
||||||
|
|
||||||
@ -972,22 +973,22 @@ export function NetscriptSingularity(
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
getCompanyRep: function (_companyName: unknown): number {
|
getCompanyRep: function (_companyName: unknown): number {
|
||||||
|
updateRam("getCompanyRep");
|
||||||
const companyName = helper.string("getCompanyRep", "companyName", _companyName);
|
const companyName = helper.string("getCompanyRep", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyRep", getRamCost(player, "getCompanyRep"));
|
|
||||||
helper.checkSingularityAccess("getCompanyRep");
|
helper.checkSingularityAccess("getCompanyRep");
|
||||||
const company = getCompany("getCompanyRep", companyName);
|
const company = getCompany("getCompanyRep", companyName);
|
||||||
return company.playerReputation;
|
return company.playerReputation;
|
||||||
},
|
},
|
||||||
getCompanyFavor: function (_companyName: unknown): number {
|
getCompanyFavor: function (_companyName: unknown): number {
|
||||||
|
updateRam("getCompanyFavor");
|
||||||
const companyName = helper.string("getCompanyFavor", "companyName", _companyName);
|
const companyName = helper.string("getCompanyFavor", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyFavor", getRamCost(player, "getCompanyFavor"));
|
|
||||||
helper.checkSingularityAccess("getCompanyFavor");
|
helper.checkSingularityAccess("getCompanyFavor");
|
||||||
const company = getCompany("getCompanyFavor", companyName);
|
const company = getCompany("getCompanyFavor", companyName);
|
||||||
return company.favor;
|
return company.favor;
|
||||||
},
|
},
|
||||||
getCompanyFavorGain: function (_companyName: unknown): number {
|
getCompanyFavorGain: function (_companyName: unknown): number {
|
||||||
|
updateRam("getCompanyFavorGain");
|
||||||
const companyName = helper.string("getCompanyFavorGain", "companyName", _companyName);
|
const companyName = helper.string("getCompanyFavorGain", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyFavorGain", getRamCost(player, "getCompanyFavorGain"));
|
|
||||||
helper.checkSingularityAccess("getCompanyFavorGain");
|
helper.checkSingularityAccess("getCompanyFavorGain");
|
||||||
const company = getCompany("getCompanyFavorGain", companyName);
|
const company = getCompany("getCompanyFavorGain", companyName);
|
||||||
return company.getFavorGain();
|
return company.getFavorGain();
|
||||||
@ -999,8 +1000,8 @@ export function NetscriptSingularity(
|
|||||||
return player.factionInvitations.slice();
|
return player.factionInvitations.slice();
|
||||||
},
|
},
|
||||||
joinFaction: function (_facName: unknown): boolean {
|
joinFaction: function (_facName: unknown): boolean {
|
||||||
|
updateRam("joinFaction");
|
||||||
const facName = helper.string("joinFaction", "facName", _facName);
|
const facName = helper.string("joinFaction", "facName", _facName);
|
||||||
helper.updateDynamicRam("joinFaction", getRamCost(player, "joinFaction"));
|
|
||||||
helper.checkSingularityAccess("joinFaction");
|
helper.checkSingularityAccess("joinFaction");
|
||||||
getFaction("joinFaction", facName);
|
getFaction("joinFaction", facName);
|
||||||
|
|
||||||
@ -1023,10 +1024,10 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
workForFaction: function (_facName: unknown, _type: unknown, _focus: unknown = true): boolean {
|
workForFaction: function (_facName: unknown, _type: unknown, _focus: unknown = true): boolean {
|
||||||
|
updateRam("workForFaction");
|
||||||
const facName = helper.string("workForFaction", "facName", _facName);
|
const facName = helper.string("workForFaction", "facName", _facName);
|
||||||
const type = helper.string("workForFaction", "type", _type);
|
const type = helper.string("workForFaction", "type", _type);
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("workForFaction", getRamCost(player, "workForFaction"));
|
|
||||||
helper.checkSingularityAccess("workForFaction");
|
helper.checkSingularityAccess("workForFaction");
|
||||||
getFaction("workForFaction", facName);
|
getFaction("workForFaction", facName);
|
||||||
|
|
||||||
@ -1104,34 +1105,35 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
|
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getFactionRep: function (_facName: unknown): number {
|
getFactionRep: function (_facName: unknown): number {
|
||||||
|
updateRam("getFactionRep");
|
||||||
const facName = helper.string("getFactionRep", "facName", _facName);
|
const facName = helper.string("getFactionRep", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionRep", getRamCost(player, "getFactionRep"));
|
|
||||||
helper.checkSingularityAccess("getFactionRep");
|
helper.checkSingularityAccess("getFactionRep");
|
||||||
const faction = getFaction("getFactionRep", facName);
|
const faction = getFaction("getFactionRep", facName);
|
||||||
return faction.playerReputation;
|
return faction.playerReputation;
|
||||||
},
|
},
|
||||||
getFactionFavor: function (_facName: unknown): number {
|
getFactionFavor: function (_facName: unknown): number {
|
||||||
|
updateRam("getFactionFavor");
|
||||||
const facName = helper.string("getFactionRep", "facName", _facName);
|
const facName = helper.string("getFactionRep", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionFavor", getRamCost(player, "getFactionFavor"));
|
|
||||||
helper.checkSingularityAccess("getFactionFavor");
|
helper.checkSingularityAccess("getFactionFavor");
|
||||||
const faction = getFaction("getFactionFavor", facName);
|
const faction = getFaction("getFactionFavor", facName);
|
||||||
return faction.favor;
|
return faction.favor;
|
||||||
},
|
},
|
||||||
getFactionFavorGain: function (_facName: unknown): number {
|
getFactionFavorGain: function (_facName: unknown): number {
|
||||||
|
updateRam("getFactionFavorGain");
|
||||||
const facName = helper.string("getFactionFavorGain", "facName", _facName);
|
const facName = helper.string("getFactionFavorGain", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionFavorGain", getRamCost(player, "getFactionFavorGain"));
|
|
||||||
helper.checkSingularityAccess("getFactionFavorGain");
|
helper.checkSingularityAccess("getFactionFavorGain");
|
||||||
const faction = getFaction("getFactionFavorGain", facName);
|
const faction = getFaction("getFactionFavorGain", facName);
|
||||||
return faction.getFavorGain();
|
return faction.getFavorGain();
|
||||||
},
|
},
|
||||||
donateToFaction: function (_facName: unknown, _amt: unknown): boolean {
|
donateToFaction: function (_facName: unknown, _amt: unknown): boolean {
|
||||||
|
updateRam("donateToFaction");
|
||||||
const facName = helper.string("donateToFaction", "facName", _facName);
|
const facName = helper.string("donateToFaction", "facName", _facName);
|
||||||
const amt = helper.number("donateToFaction", "amt", _amt);
|
const amt = helper.number("donateToFaction", "amt", _amt);
|
||||||
helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction"));
|
|
||||||
helper.checkSingularityAccess("donateToFaction");
|
helper.checkSingularityAccess("donateToFaction");
|
||||||
const faction = getFaction("donateToFaction", facName);
|
const faction = getFaction("donateToFaction", facName);
|
||||||
if (!player.factions.includes(faction.name)) {
|
if (!player.factions.includes(faction.name)) {
|
||||||
@ -1178,9 +1180,9 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
createProgram: function (_programName: unknown, _focus: unknown = true): boolean {
|
createProgram: function (_programName: unknown, _focus: unknown = true): boolean {
|
||||||
|
updateRam("createProgram");
|
||||||
const programName = helper.string("createProgram", "programName", _programName).toLowerCase();
|
const programName = helper.string("createProgram", "programName", _programName).toLowerCase();
|
||||||
const focus = helper.boolean(_focus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("createProgram", getRamCost(player, "createProgram"));
|
|
||||||
helper.checkSingularityAccess("createProgram");
|
helper.checkSingularityAccess("createProgram");
|
||||||
|
|
||||||
const wasFocusing = player.focus;
|
const wasFocusing = player.focus;
|
||||||
@ -1227,8 +1229,8 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
commitCrime: function (_crimeRoughName: unknown): number {
|
commitCrime: function (_crimeRoughName: unknown): number {
|
||||||
|
updateRam("commitCrime");
|
||||||
const crimeRoughName = helper.string("commitCrime", "crimeRoughName", _crimeRoughName);
|
const crimeRoughName = helper.string("commitCrime", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("commitCrime", getRamCost(player, "commitCrime"));
|
|
||||||
helper.checkSingularityAccess("commitCrime");
|
helper.checkSingularityAccess("commitCrime");
|
||||||
|
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
@ -1248,8 +1250,8 @@ export function NetscriptSingularity(
|
|||||||
return crime.commit(Router, player, 1, workerScript);
|
return crime.commit(Router, player, 1, workerScript);
|
||||||
},
|
},
|
||||||
getCrimeChance: function (_crimeRoughName: unknown): number {
|
getCrimeChance: function (_crimeRoughName: unknown): number {
|
||||||
|
updateRam("getCrimeChance");
|
||||||
const crimeRoughName = helper.string("getCrimeChance", "crimeRoughName", _crimeRoughName);
|
const crimeRoughName = helper.string("getCrimeChance", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("getCrimeChance", getRamCost(player, "getCrimeChance"));
|
|
||||||
helper.checkSingularityAccess("getCrimeChance");
|
helper.checkSingularityAccess("getCrimeChance");
|
||||||
|
|
||||||
const crime = findCrime(crimeRoughName.toLowerCase());
|
const crime = findCrime(crimeRoughName.toLowerCase());
|
||||||
@ -1260,8 +1262,8 @@ export function NetscriptSingularity(
|
|||||||
return crime.successRate(player);
|
return crime.successRate(player);
|
||||||
},
|
},
|
||||||
getCrimeStats: function (_crimeRoughName: unknown): CrimeStats {
|
getCrimeStats: function (_crimeRoughName: unknown): CrimeStats {
|
||||||
|
updateRam("getCrimeStats");
|
||||||
const crimeRoughName = helper.string("getCrimeStats", "crimeRoughName", _crimeRoughName);
|
const crimeRoughName = helper.string("getCrimeStats", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("getCrimeStats", getRamCost(player, "getCrimeStats"));
|
|
||||||
helper.checkSingularityAccess("getCrimeStats");
|
helper.checkSingularityAccess("getCrimeStats");
|
||||||
|
|
||||||
const crime = findCrime(crimeRoughName.toLowerCase());
|
const crime = findCrime(crimeRoughName.toLowerCase());
|
||||||
@ -1272,7 +1274,7 @@ export function NetscriptSingularity(
|
|||||||
return Object.assign({}, crime);
|
return Object.assign({}, crime);
|
||||||
},
|
},
|
||||||
getDarkwebPrograms: function (): string[] {
|
getDarkwebPrograms: function (): string[] {
|
||||||
helper.updateDynamicRam("getDarkwebPrograms", getRamCost(player, "getDarkwebPrograms"));
|
updateRam("getDarkwebPrograms");
|
||||||
helper.checkSingularityAccess("getDarkwebPrograms");
|
helper.checkSingularityAccess("getDarkwebPrograms");
|
||||||
|
|
||||||
// If we don't have Tor, log it and return [] (empty list)
|
// If we don't have Tor, log it and return [] (empty list)
|
||||||
@ -1283,8 +1285,8 @@ export function NetscriptSingularity(
|
|||||||
return Object.values(DarkWebItems).map((p) => p.program);
|
return Object.values(DarkWebItems).map((p) => p.program);
|
||||||
},
|
},
|
||||||
getDarkwebProgramCost: function (_programName: unknown): number {
|
getDarkwebProgramCost: function (_programName: unknown): number {
|
||||||
|
updateRam("getDarkwebProgramCost");
|
||||||
const programName = helper.string("getDarkwebProgramCost", "programName", _programName).toLowerCase();
|
const programName = helper.string("getDarkwebProgramCost", "programName", _programName).toLowerCase();
|
||||||
helper.updateDynamicRam("getDarkwebProgramCost", getRamCost(player, "getDarkwebProgramCost"));
|
|
||||||
helper.checkSingularityAccess("getDarkwebProgramCost");
|
helper.checkSingularityAccess("getDarkwebProgramCost");
|
||||||
|
|
||||||
// If we don't have Tor, log it and return -1
|
// If we don't have Tor, log it and return -1
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user