diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index b90db4145..ef0221169 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -4,28 +4,28 @@ on: workflow_dispatch: inputs: version: - description: 'Version (format: x.y.z)' + description: "Version (format: x.y.z)" required: true versionNumber: - description: 'Version Number (for saves migration)' + description: "Version Number (for saves migration)" required: true changelog: - description: 'Changelog (url that points to RAW markdown)' - default: '' + description: "Changelog (url that points to RAW markdown)" + default: "" buildApp: - description: 'Include Application Build' + description: "Include Application Build" type: boolean - default: 'true' + default: "true" required: true buildDoc: - description: 'Include Documentation Build' + description: "Include Documentation Build" type: boolean - default: 'true' + default: "true" required: true prepareRelease: - description: 'Prepare Draft Release' + description: "Prepare Draft Release" type: boolean - default: 'true' + default: "true" required: true jobs: @@ -46,7 +46,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16.13.1 - cache: 'npm' + cache: "npm" - name: Install NPM dependencies for version updater working-directory: ./tools/bump-version run: npm ci diff --git a/.github/workflows/check-for-generated-files.yml b/.github/workflows/check-for-generated-files.yml index 233f8eda5..ad9dfefd6 100644 --- a/.github/workflows/check-for-generated-files.yml +++ b/.github/workflows/check-for-generated-files.yml @@ -58,7 +58,7 @@ jobs: - name: Get Comment Body id: get-comment-body - if : steps.get-warnings.outputs.has_warnings == 'true' + if: steps.get-warnings.outputs.has_warnings == 'true' run: | cat warnings.txt > comment.txt echo "" >> comment.txt @@ -73,12 +73,12 @@ jobs: echo ::set-output name=body::$body - name: Add github comment on problem - if : steps.get-warnings.outputs.has_warnings == 'true' + if: steps.get-warnings.outputs.has_warnings == 'true' uses: peter-evans/commit-comment@v1 with: body: ${{ steps.get-comment-body.outputs.body }} - name: Flag as error - if : steps.get-warnings.outputs.has_warnings == 'true' + if: steps.get-warnings.outputs.has_warnings == 'true' run: | COMMIT_WARNINGS=$(cat warnings.txt) echo "::warning:: $COMMIT_WARNINGS" diff --git a/.github/workflows/fetch-changes.yml b/.github/workflows/fetch-changes.yml index 594e8a13b..1a66635f2 100644 --- a/.github/workflows/fetch-changes.yml +++ b/.github/workflows/fetch-changes.yml @@ -3,10 +3,10 @@ on: workflow_dispatch: inputs: fromCommit: - description: 'From Commit SHA (full-length)' + description: "From Commit SHA (full-length)" required: true toCommit: - description: 'To Commit SHA (full-length, if omitted will use latest)' + description: "To Commit SHA (full-length, if omitted will use latest)" jobs: fetchChangelog: @@ -17,7 +17,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16.13.1 - cache: 'npm' + cache: "npm" - name: Install NPM dependencies working-directory: ./tools/fetch-changelog run: npm ci diff --git a/doc/BN14.md b/doc/BN14.md index eca71c49c..691f2dbd7 100644 --- a/doc/BN14.md +++ b/doc/BN14.md @@ -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 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) - Some sort of math twist that requires some thinking, like (-2)^c1 alters between positive and negative. diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 71ec878f8..593055e26 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -115,7 +115,6 @@ Fork and clone the repo - 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` - ## Running locally. 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. Saving a file will reload the game automatically. - ### How to build the electron app Tested on Node v16.13.1 (LTS) on Windows diff --git a/doc/FAQ.md b/doc/FAQ.md index 6cefffc3c..bacb67b69 100644 --- a/doc/FAQ.md +++ b/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! 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: - * In the menu, "Reloads" -> "Reload & Kill All Scripts". - * If this does not work, when launching the game, use the kill all script options. + +- On Browser: Stick `?noScript` at the end of the URL +- On Steam: + - 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 ### **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 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** + 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). @@ -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. - * on Linux: `~/.config/bitburner/logs/main.log` - * on macOS: `~/Library/Logs/bitburner/main.log` - * on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\logs\main.log` +- on Linux: `~/.config/bitburner/logs/main.log` +- on macOS: `~/Library/Logs/bitburner/main.log` +- on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\logs\main.log` ### Config (using [electron-store](https://github.com/sindresorhus/electron-store#readme)) Configuration file will be written to disk in the application data directory. - * on Linux: `~/.config/bitburner/config.json` - * on macOS: `~/Library/Application\ Support/bitburner/config.json` - * on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\config.json` +- on Linux: `~/.config/bitburner/config.json` +- on macOS: `~/Library/Application\ Support/bitburner/config.json` +- on Windows: `%USERPROFILE%\AppData\Roaming\bitburner\config.json` --- diff --git a/electron/achievements.js b/electron/achievements.js index 26bfc7a6c..635e61d48 100644 --- a/electron/achievements.js +++ b/electron/achievements.js @@ -6,18 +6,18 @@ async function enableAchievementsInterval(window) { // If the Steam API could not be initialized on game start, we'll abort this. if (global.greenworksError) return; - // This is backward but the game fills in an array called `document.achievements` and we retrieve it from + // This is backward but the game fills in an array called `document.achievements` and we retrieve it from // here. Hey if it works it works. const steamAchievements = greenworks.getAchievementNames(); 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)}`); const intervalID = setInterval(async () => { try { const playerAchievements = await window.webContents.executeJavaScript("document.achievements"); for (const ach of playerAchievements) { if (!steamAchievements.includes(ach)) continue; // Don't try activating achievements that don't exist Steam-side - if (playerAchieved.includes(ach)) continue; // Don't spam achievements that have already been recorded + if (playerAchieved.includes(ach)) continue; // Don't spam achievements that have already been recorded log.info(`Granting Steam achievement ${ach}`); greenworks.activateAchievement(ach, () => undefined); playerAchieved.push(ach); @@ -26,7 +26,7 @@ async function enableAchievementsInterval(window) { log.error(error); // The interval probably did not get cleared after a window kill - log.warn('Clearing achievements timer'); + log.warn("Clearing achievements timer"); clearInterval(intervalID); return; } @@ -36,10 +36,14 @@ async function enableAchievementsInterval(window) { function checkSteamAchievement(name) { return new Promise((resolve) => { - greenworks.getAchievement(name, playerHas => resolve(playerHas ? name : ""), err => { - log.warn(`Failed to get Steam achievement ${name} status: ${err}`); - resolve(""); - }); + greenworks.getAchievement( + name, + (playerHas) => resolve(playerHas ? name : ""), + (err) => { + log.warn(`Failed to get Steam achievement ${name} status: ${err}`); + resolve(""); + }, + ); }); } @@ -50,5 +54,6 @@ function disableAchievementsInterval(window) { } module.exports = { - enableAchievementsInterval, disableAchievementsInterval -} + enableAchievementsInterval, + disableAchievementsInterval, +}; diff --git a/electron/api-server.js b/electron/api-server.js index 54b72108a..39cee2d0c 100644 --- a/electron/api-server.js +++ b/electron/api-server.js @@ -12,25 +12,27 @@ async function initialize(win) { window = win; server = http.createServer(async function (req, res) { let body = ""; - res.setHeader('Content-Type', 'application/json'); + res.setHeader("Content-Type", "application/json"); req.on("data", (chunk) => { body += chunk.toString(); // convert Buffer to string }); req.on("end", async () => { - const providedToken = req.headers?.authorization?.replace('Bearer ', '') ?? ''; + const providedToken = req.headers?.authorization?.replace("Bearer ", "") ?? ""; const isValid = providedToken === getAuthenticationToken(); if (isValid) { - log.debug('Valid authentication token'); + log.debug("Valid authentication token"); } else { - log.log('Invalid authentication token'); + log.log("Invalid authentication token"); res.writeHead(401); - res.end(JSON.stringify({ - success: false, - msg: 'Invalid authentication token' - })); + res.end( + JSON.stringify({ + success: false, + msg: "Invalid authentication token", + }), + ); return; } @@ -40,16 +42,18 @@ async function initialize(win) { } catch (error) { log.warn(`Invalid body data`); res.writeHead(400); - res.end(JSON.stringify({ - success: false, - msg: 'Invalid body data' - })); + res.end( + JSON.stringify({ + success: false, + msg: "Invalid body data", + }), + ); return; } let result; - switch(req.method) { + switch (req.method) { // Request files case "GET": result = await window.webContents.executeJavaScript(`document.getFiles()`); @@ -62,10 +66,12 @@ async function initialize(win) { if (!data) { log.warn(`Invalid script update request - No data`); res.writeHead(400); - res.end(JSON.stringify({ - success: false, - msg: 'Invalid script update request - No data' - })); + res.end( + JSON.stringify({ + success: false, + msg: "Invalid script update request - No data", + }), + ); return; } @@ -84,19 +90,20 @@ async function initialize(win) { log.warn(`Api Server Error`, result.msg); } - res.end(JSON.stringify({ - success: result.res, - msg: result.msg, - data: result.data - })); - + res.end( + JSON.stringify({ + success: result.res, + msg: result.msg, + data: result.data, + }), + ); }); }); - const autostart = config.get('autostart', false); + const autostart = config.get("autostart", false); if (autostart) { try { - await enable() + await enable(); } catch (error) { return Promise.reject(error); } @@ -105,15 +112,14 @@ async function initialize(win) { return Promise.resolve(); } - function enable() { if (isListening()) { - log.warn('API server already listening'); + log.warn("API server already listening"); return Promise.resolve(); } - const port = config.get('port', 9990); - const host = config.get('host', '127.0.0.1'); + const port = config.get("port", 9990); + const host = config.get("host", "127.0.0.1"); log.log(`Starting http server on port ${port} - listening on ${host}`); // https://stackoverflow.com/a/62289870 @@ -125,13 +131,10 @@ function enable() { resolve(); } }); - server.once('error', (err) => { + server.once("error", (err) => { if (!startFinished) { startFinished = true; - console.log( - 'There was an error starting the server in the error listener:', - err - ); + console.log("There was an error starting the server in the error listener:", err); reject(err); } }); @@ -140,11 +143,11 @@ function enable() { function disable() { if (!isListening()) { - log.warn('API server not listening'); + log.warn("API server not listening"); return Promise.resolve(); } - log.log('Stopping http server'); + log.log("Stopping http server"); return server.close(); } @@ -162,31 +165,35 @@ function isListening() { function toggleAutostart() { const newValue = !isAutostart(); - config.set('autostart', newValue); + config.set("autostart", newValue); log.log(`New autostart value is '${newValue}'`); } function isAutostart() { - return config.get('autostart'); + return config.get("autostart"); } function getAuthenticationToken() { - const token = config.get('token'); + const token = config.get("token"); if (token) return token; const newToken = generateToken(); - config.set('token', newToken); + config.set("token", newToken); return newToken; } function generateToken() { const buffer = crypto.randomBytes(48); - return buffer.toString('base64') + return buffer.toString("base64"); } module.exports = { initialize, - enable, disable, toggleServer, - toggleAutostart, isAutostart, - getAuthenticationToken, isListening, -} + enable, + disable, + toggleServer, + toggleAutostart, + isAutostart, + getAuthenticationToken, + isListening, +}; diff --git a/electron/exit.html b/electron/exit.html index 6df21a307..0b484fbfd 100644 --- a/electron/exit.html +++ b/electron/exit.html @@ -1,7 +1,7 @@ - + Bitburner