From 37f41c89bcabbefd241a46de314be3b3042041e5 Mon Sep 17 00:00:00 2001 From: Zelow79 <32428876+Zelow79@users.noreply.github.com> Date: Thu, 2 Feb 2023 10:09:38 -0500 Subject: [PATCH] MISC: Added features to DevMenu (#353) * More blade devmenu functions * Custom money field, set money to 0 option * Options for removing blade/gang/corp * Better dev menu responsiveness (dev menu rerenders after adding or removing blade/gang/corp) * Some general code style changes --- src/DevMenu/ui/Bladeburner.tsx | 95 ++++++++++++++-------- src/DevMenu/ui/General.tsx | 142 ++++++++++++++++++++------------- 2 files changed, 150 insertions(+), 87 deletions(-) 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 ? ( + + ) : ( + + )}
-