diff --git a/.eslintignore b/.eslintignore index 9f6599e8c..50b2e676b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,26 +1,16 @@ node_modules/ -.dist -.tmp .package .build -.cypress/ +.app -dist/ -input/ -assets/ -doc/ -markdown/ +dist +input +assets +doc +markdown +electron +tools +src/ThirdParty - -test/netscript/ - -electron/lib -electron/greenworks.js -src/ThirdParty/* -src/JSInterpreter.js -tools/engines-check/ - -editor.main.js -main.bundle.js webpack.config.js diff --git a/.github/workflows/check-for-generated-files.yml b/.github/workflows/check-for-generated-files.yml index eaac3904b..6d29c3ea8 100644 --- a/.github/workflows/check-for-generated-files.yml +++ b/.github/workflows/check-for-generated-files.yml @@ -35,51 +35,30 @@ jobs: - name: Warn when bundle files were changed id: warn-bundles-changed - if: steps.changed-bundle-files.outputs.any_changed == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - echo "One or more files in the bundle files were changed." >> warnings.txt + echo "Creating label (if it does not exist)" + LABEL="validation: bundle files modified" + gh --repo "${{ github.repository }}" \ + label create "$LABEL" --description "Modifications to this pull request are suggested" --color D93F0B || true - - name: Warn when documentation markdown files were changed - id: warn-markdown-changed - if: steps.changed-markdown-doc-files.outputs.any_changed == 'true' - run: | - echo "One or more files in the markdown documentation were changed." >> warnings.txt - - - name: Print Warnings - id: get-warnings - run: | - if [ -f warnings.txt ] - then - echo "::set-output name=has_warnings::true" + if [ "${{ steps.changed-bundle-files.outputs.any_changed }}" == "false" ]; then + echo "No forbidden files included, removing warning" + gh --repo "${{ github.repository }}" \ + pr edit "${{ github.event.number }}" --remove-label "$LABEL" || true else - echo "::set-output name=has_warnings::false" - touch warnings.txt + echo "Forbidden files included, generating warning" + + touch comment.txt + echo "## Generated build or documentation files were included. PRs should not normally contain any generated files." >> comment.txt + echo "" >> comment.txt + echo "Review the changes and ensure that including built files was necessary." >> comment.txt + + echo "Add pr label" + gh --repo "${{ github.repository }}" \ + pr edit "${{ github.event.number }}" --add-label "$LABEL" + echo "And comment on the pr" + gh --repo "${{ github.repository }}" \ + pr comment "${{ github.event.number }}" --body-file comment.txt fi - - - name: Get Comment Body - id: get-comment-body - if: steps.get-warnings.outputs.has_warnings == 'true' - run: | - cat warnings.txt > comment.txt - echo "" >> comment.txt - echo "Please do not commit files generated by webpack or generated markdown" >> comment.txt - echo "" >> comment.txt - echo "See [CONTRIBUTING.md](https://github.com/bitburner-official/bitburner-src/blob/dev/doc/CONTRIBUTING.md) for details." >> comment.txt - - body=$(cat comment.txt) - body="${body//'%'/'%25'}" - body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" - - echo ::set-output name=body::$body - - name: Add github comment on problem - 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' - run: | - COMMIT_WARNINGS=$(cat warnings.txt) - echo "::warning:: $COMMIT_WARNINGS" - exit 1 diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index e9a2c3b24..d109f0b0c 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -1,7 +1,7 @@ name: CI Pull Request on: - # Triggers the workflow on pull request events but only for the dev branch, checking only diffs + # Triggers the workflow on pull request events but only for the dev branch pull_request: branches: [dev] @@ -38,7 +38,7 @@ jobs: - name: Install npm dependencies run: npm ci - name: Run linter - run: npm run lint:report-diff + run: npm run lint:report prettier: name: Prettier runs-on: ubuntu-latest @@ -54,7 +54,7 @@ jobs: - name: Install npm dependencies run: npm ci - name: Run prettier check - run: npm run format:report-diff + run: npm run format:report test: name: Test runs-on: ubuntu-latest diff --git a/.prettierignore b/.prettierignore index 10997bab0..517c68449 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,10 +1,11 @@ node_modules package.json dist -doc/build/ +doc/build doc/source .build .package +.app editor.main.js main.bundle.js diff --git a/package.json b/package.json index a4b1eb0d6..cc17903d1 100644 --- a/package.json +++ b/package.json @@ -102,14 +102,12 @@ "doc": "npx api-extractor run && npx api-documenter markdown && rm input/bitburner.api.json && rm -r input", "format": "prettier --write .", "format:report": "prettier -c .", - "format:report-diff": "bash -c 'if [[ $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | wc -c) -ne 0 ]]; then prettier -c $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs); fi'", "start": "http-server -p 8000", "start:dev": "webpack serve --progress --env devServer --mode development", - "build": "bash ./tools/build.sh", - "build:dev": "webpack --mode development", + "build": "bash ./tools/build.sh production", + "build:dev": "bash ./tools/build.sh development", "lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src", "lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src", - "lint:report-diff": "eslint --max-warnings 0 $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs)", "preinstall": "node ./tools/engines-check/engines-check.js", "postinstall": "cd electron && npm install", "test": "jest", @@ -117,11 +115,6 @@ "watch": "webpack --watch --mode production", "watch:dev": "webpack --watch --mode development", "electron": "bash ./tools/package-electron.sh", - "electron:packager": "electron-packager .package bitburner --platform all --arch x64,armv7l,arm64,mips64el --out .build --overwrite --icon .package/icon.png --no-prune", - "electron:packager-all": "electron-packager .package bitburner --platform all --arch x64,armv7l,arm64,mips64el --out .build --overwrite --icon .package/icon.png", - "electron:packager-win": "electron-packager .package bitburner --platform win32 --arch x64 --out .build --overwrite --icon .package/icon.png", - "electron:packager-mac": "electron-packager .package bitburner --platform darwin --arch x64 --out .build --overwrite --icon .package/icon.png", - "electron:packager-linux": "electron-packager .package bitburner --platform linux --arch x64 --out .build --overwrite --icon .package/icon.png", "allbuild": "npm run build && npm run electron && git add --all && git commit -m \"allbuild commit $(git rev-parse --short HEAD)\" && git push -u origin dev", "preversion": "npm install && npm run test", "version": "sh ./tools/build-release.sh && git add --all", diff --git a/src/Corporation/data/Constants.ts b/src/Corporation/data/Constants.ts index ba7d1ecf9..edacf2405 100644 --- a/src/Corporation/data/Constants.ts +++ b/src/Corporation/data/Constants.ts @@ -15,7 +15,7 @@ import { IndustryType, EmployeePositions } from "./Enums"; // This structure + import * as corpConstants allows easier type definitions for individual properties. /** Names of all corporation game states */ -export const stateNames: CorpStateName[] = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"], +export const stateNames: CorpStateName[] = ["START", "PURCHASE", "PRODUCTION", "EXPORT", "SALE"], // TODO: remove IndustryType and EmployeePositions enums and just use the typed strings. /** Names of all corporation employee positions */ employeePositions: CorpEmployeePosition[] = Object.values(EmployeePositions), diff --git a/src/DevMenu/ui/Bladeburner.tsx b/src/DevMenu/ui/Bladeburner.tsx index 95e446158..670db10aa 100644 --- a/src/DevMenu/ui/Bladeburner.tsx +++ b/src/DevMenu/ui/Bladeburner.tsx @@ -1,54 +1,52 @@ import React from "react"; - import Typography from "@mui/material/Typography"; import Accordion from "@mui/material/Accordion"; import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionDetails from "@mui/material/AccordionDetails"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; - +import Button from "@mui/material/Button"; import { Adjuster } from "./Adjuster"; import { Player } from "@player"; +import { CityName } from "../../Enums"; const bigNumber = 1e27; export function Bladeburner(): React.ReactElement { + if (!Player.bladeburner) return <>; const bladeburner = Player.bladeburner; - if (bladeburner === null) return <>; - function modifyBladeburnerRank(modify: number): (x: number) => void { - return function (rank: number): void { - if (!bladeburner) return; - bladeburner.changeRank(Player, rank * modify); - }; - } - function resetBladeburnerRank(): void { - if (!bladeburner) return; + // Rank functions + const modifyBladeburnerRank = (modify: number) => (rank: number) => bladeburner.changeRank(Player, rank * modify); + const resetBladeburnerRank = () => { bladeburner.rank = 0; bladeburner.maxRank = 0; - } + }; + const addTonsBladeburnerRank = () => bladeburner.changeRank(Player, bigNumber); - function addTonsBladeburnerRank(): void { - if (!bladeburner) return; + // Skill point functions + const modifyBladeburnerSP = (modify: number) => (skillPoints: number) => { + bladeburner.skillPoints += skillPoints * modify; + }; + const resetBladeburnerSP = () => { + bladeburner.skillPoints = 0; + bladeburner.totalSkillPoints = 0; + }; + const addTonsBladeburnerSP = () => (bladeburner.skillPoints = bigNumber); - bladeburner.changeRank(Player, bigNumber); - } + // Cycles functions + const modifyBladeburnerCycles = (modify: number) => (cycles: number) => (bladeburner.storedCycles += cycles * modify); + const resetBladeburnerCycles = () => (bladeburner.storedCycles = 0); + const addTonsBladeburnerCycles = () => (bladeburner.storedCycles += bigNumber); - function modifyBladeburnerCycles(modify: number): (x: number) => void { - return function (cycles: number): void { - if (!bladeburner) return; - bladeburner.storedCycles += cycles * modify; - }; - } - - function resetBladeburnerCycles(): void { - if (!bladeburner) return; - bladeburner.storedCycles = 0; - } - - function addTonsBladeburnerCycles(): void { - if (!bladeburner) return; - bladeburner.storedCycles += bigNumber; - } + // Chaos functions + const wipeAllChaos = () => Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos = 0)); + const wipeActiveCityChaos = () => (bladeburner.cities[bladeburner.city].chaos = 0); + const addAllChaos = (modify: number) => (chaos: number) => { + Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += chaos * modify)); + }; + const addTonsAllChaos = () => { + Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += bigNumber)); + }; return ( @@ -75,7 +73,22 @@ export function Bladeburner(): React.ReactElement { - Cycles: + SP: + + + + + + + + Cycles: + + + Chaos: + + + + + + ); } diff --git a/src/DevMenu/ui/General.tsx b/src/DevMenu/ui/General.tsx index 8394287bd..79f29448b 100644 --- a/src/DevMenu/ui/General.tsx +++ b/src/DevMenu/ui/General.tsx @@ -1,10 +1,8 @@ import React, { useEffect, useState } from "react"; - import Accordion from "@mui/material/Accordion"; import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionDetails from "@mui/material/AccordionDetails"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; - import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; import { Money } from "../../ui/React/Money"; @@ -15,59 +13,68 @@ import { Bladeburner } from "../../Bladeburner/Bladeburner"; import { GangConstants } from "../../Gang/data/Constants"; import { FactionNames } from "../../Faction/data/FactionNames"; import { checkForMessagesToSend } from "../../Message/MessageHelpers"; +import { ThemeEvents } from "../../Themes/ui/Theme"; export function General(): React.ReactElement { const [error, setError] = useState(false); const [corporationName, setCorporationName] = useState(""); - const [gangFaction, setGangFaction] = useState(""); + const [gangFaction, setGangFaction] = useState("Slum Snakes"); + const [devMoney, setDevMoney] = useState(0); - function addMoney(n: number) { - return function () { - Player.gainMoney(n, "other"); - }; - } + // Money functions + const addCustomMoney = () => !Number.isNaN(devMoney) && Player.gainMoney(devMoney, "other"); + const addMoney = (n: number) => () => Player.gainMoney(n, "other"); + const setMoney = (n: number) => () => (Player.money = Number(n)); - function upgradeRam(): void { - Player.getHomeComputer().maxRam *= 2; - } + // Ram functions + const upgradeRam = () => (Player.getHomeComputer().maxRam *= 2); - function quickB1tFlum3(): void { - Router.toBitVerse(true, true); - } + // Node-clearing functions + const quickB1tFlum3 = () => Router.toBitVerse(true, true); + const b1tflum3 = () => Router.toBitVerse(true, false); + const quickHackW0r1dD43m0n = () => Router.toBitVerse(false, true); + const hackW0r1dD43m0n = () => Router.toBitVerse(false, false); - function b1tflum3(): void { - Router.toBitVerse(true, false); - } - - function quickHackW0r1dD43m0n(): void { - Router.toBitVerse(false, true); - } - - function hackW0r1dD43m0n(): void { - Router.toBitVerse(false, false); - } - - function createCorporation(): void { + // Corp functions + const createCorporation = () => { Player.startCorporation(corporationName); - } + // Rerender so the corp menu option will show up immediately on the devmenu page selection + ThemeEvents.emit(); + }; + const destroyCorporation = () => { + Player.corporation = null; + // Rerender so the corp menu option will be removed immediately on the devmenu page selection + ThemeEvents.emit(); + }; - function joinBladeburner(): void { + // Blade functions + const joinBladeburner = () => { Player.bladeburner = new Bladeburner(); - } + // Rerender so the blade menu option will show up immediately on the devmenu page selection + ThemeEvents.emit(); + }; + const leaveBladeburner = () => { + Player.bladeburner = null; + // Rerender so the blade menu option will be removed immediately on the devmenu page selection + ThemeEvents.emit(); + }; - function startGang(): void { + // Gang functions + const startGang = () => { const isHacking = gangFaction === FactionNames.NiteSec || gangFaction === FactionNames.TheBlackHand; Player.startGang(gangFaction, isHacking); - } - - function setGangFactionDropdown(event: SelectChangeEvent): void { - setGangFaction(event.target.value); - } - - function checkMessages(): void { - checkForMessagesToSend(); - } + // Rerender so the gang menu option will show up immediately on the devmenu page selection + ThemeEvents.emit(); + }; + const stopGang = () => { + Player.gang = null; + // Rerender so the gang menu option will be removed immediately on the devmenu page selection + ThemeEvents.emit(); + }; + const setGangFactionDropdown = (event: SelectChangeEvent) => setGangFaction(event.target.value); + // Misc functions + const checkMessages = () => checkForMessagesToSend(); useEffect(() => { if (error) throw new ReferenceError("Manually thrown error"); }, [error]); @@ -78,6 +85,14 @@ export function General(): React.ReactElement { General +
- Corporation Name: - setCorporationName(x.target.value)} /> - + Add Custom Money + setDevMoney(parseFloat(x.target.value))} /> +
- Gang Faction: - - + {Player.corporation ? ( + + ) : ( + <> + Corporation Name: + setCorporationName(x.target.value)} /> + + + )}
- + {Player.gang ? ( + + ) : ( + <> + Gang Faction: + + + + )} +
+ {Player.bladeburner ? ( + + ) : ( + + )}
- diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 844776af8..04e6e9252 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -7604,7 +7604,7 @@ interface CorporationInfo { dividendTax: number; /** Your earnings as a shareholder per second this cycle */ dividendEarnings: number; - /** State of the corporation. Possible states are START, PURCHASE, PRODUCTION, SALE, EXPORT. */ + /** State of the corporation. Possible states are START, PURCHASE, PRODUCTION, EXPORT, SALE. */ state: string; /** Array of all division names */ divisions: string[]; @@ -7662,7 +7662,7 @@ interface CorpConstants { minEmployeeDecay: number; } /** @public */ -type CorpStateName = "START" | "PURCHASE" | "PRODUCTION" | "SALE" | "EXPORT"; +type CorpStateName = "START" | "PURCHASE" | "PRODUCTION" | "EXPORT" | "SALE"; /** @public */ type CorpMaterialName = diff --git a/src/Themes/data/index.ts b/src/Themes/data/index.ts index cef542782..ce97a891f 100644 --- a/src/Themes/data/index.ts +++ b/src/Themes/data/index.ts @@ -12,3 +12,4 @@ export { Theme as DiscordLike } from "./discord-like"; export { Theme as OneDark } from "./one-dark"; export { Theme as MutedGoldBlue } from "./muted-gold-blue"; export { Theme as Light } from "./light"; +export { Theme as IronMan } from "./iron-man"; diff --git a/src/Themes/data/iron-man/index.ts b/src/Themes/data/iron-man/index.ts new file mode 100644 index 000000000..0c6224941 --- /dev/null +++ b/src/Themes/data/iron-man/index.ts @@ -0,0 +1,45 @@ +import { IPredefinedTheme } from "../../Themes"; +import img1 from "./screenshot.png"; + +export const Theme: IPredefinedTheme = { + name: "Iron Man", + credit: "Matti#2942", + description: "Mark 42. Threw a little hot rod red in there.", + reference: "https://discord.com/channels/415207508303544321/921991895230611466/1069233364927787089", + screenshot: img1, + colors: { + primarylight: "#FFFEFC", + primary: "#FFA95E", + primarydark: "#E8BC71", + successlight: "#00FF00", + success: "#0c0", + successdark: "#090", + errorlight: "#FF0B0B", + error: "#FF0000", + errordark: "#770000", + secondarylight: "#FFC596", + secondary: "#DA3F3F", + secondarydark: "#6E1D1D", + warninglight: "#ff0", + warning: "#cc0", + warningdark: "#990", + infolight: "#FFFFFF", + info: "#B6E9FF", + infodark: "#5596CF", + welllight: "#8A2121", + well: "#350000", + white: "#fff", + black: "#000", + hp: "#FF4E4E", + money: "#C2F26F", + hack: "#D5FFB2", + combat: "#E39C5A", + cha: "#CA4444", + int: "#6495ed", + rep: "#E39C5A", + disabled: "#3C0C0C", + backgroundprimary: "#2C0707", + backgroundsecondary: "#551212", + button: "#8A2121", + }, +}; diff --git a/src/Themes/data/iron-man/screenshot.png b/src/Themes/data/iron-man/screenshot.png new file mode 100644 index 000000000..6be8482a5 Binary files /dev/null and b/src/Themes/data/iron-man/screenshot.png differ diff --git a/tools/build.sh b/tools/build.sh index e26c98f09..16104923f 100644 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # builds the game in the root folder -webpack --mode production +webpack --mode $1 # Clear out any files remaining from old builds and recreate folder rm -rf .app