mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
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
This commit is contained in:
parent
35d590b25d
commit
37f41c89bc
@ -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;
|
||||
}
|
||||
|
||||
function addTonsBladeburnerRank(): void {
|
||||
if (!bladeburner) return;
|
||||
|
||||
bladeburner.changeRank(Player, bigNumber);
|
||||
}
|
||||
|
||||
function modifyBladeburnerCycles(modify: number): (x: number) => void {
|
||||
return function (cycles: number): void {
|
||||
if (!bladeburner) return;
|
||||
bladeburner.storedCycles += cycles * modify;
|
||||
};
|
||||
}
|
||||
const addTonsBladeburnerRank = () => bladeburner.changeRank(Player, bigNumber);
|
||||
|
||||
function resetBladeburnerCycles(): void {
|
||||
if (!bladeburner) return;
|
||||
bladeburner.storedCycles = 0;
|
||||
}
|
||||
// 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);
|
||||
|
||||
function addTonsBladeburnerCycles(): void {
|
||||
if (!bladeburner) return;
|
||||
bladeburner.storedCycles += bigNumber;
|
||||
}
|
||||
// Cycles functions
|
||||
const modifyBladeburnerCycles = (modify: number) => (cycles: number) => (bladeburner.storedCycles += cycles * modify);
|
||||
const resetBladeburnerCycles = () => (bladeburner.storedCycles = 0);
|
||||
const addTonsBladeburnerCycles = () => (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 (
|
||||
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
||||
@ -73,6 +71,21 @@ export function Bladeburner(): React.ReactElement {
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Typography>SP:</Typography>
|
||||
</td>
|
||||
<td>
|
||||
<Adjuster
|
||||
label="skill points"
|
||||
placeholder="amt"
|
||||
tons={addTonsBladeburnerSP}
|
||||
add={modifyBladeburnerSP(1)}
|
||||
subtract={modifyBladeburnerSP(-1)}
|
||||
reset={resetBladeburnerSP}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Typography>Cycles: </Typography>
|
||||
@ -88,9 +101,25 @@ export function Bladeburner(): React.ReactElement {
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Typography title="This is for ALL cities">Chaos:</Typography>
|
||||
</td>
|
||||
<td>
|
||||
<Adjuster
|
||||
label="chaos in all cities"
|
||||
placeholder="amt"
|
||||
tons={addTonsAllChaos}
|
||||
add={addAllChaos(1)}
|
||||
subtract={addAllChaos(-1)}
|
||||
reset={wipeAllChaos}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</AccordionDetails>
|
||||
<Button onClick={wipeActiveCityChaos}>Clear Active City's Chaos</Button>
|
||||
</Accordion>
|
||||
);
|
||||
}
|
||||
|
@ -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<string>): 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<string>) => 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 {
|
||||
<Typography>General</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
<Button
|
||||
onClick={setMoney(0)}
|
||||
title="This sets your money to $0, this means the money you had will just vanish without being accounted for where it went and may offset some metrics."
|
||||
>
|
||||
<pre>
|
||||
= <Money money={0} />
|
||||
</pre>
|
||||
</Button>
|
||||
<Button onClick={addMoney(1e6)}>
|
||||
<pre>
|
||||
+ <Money money={1e6} />
|
||||
@ -105,10 +120,24 @@ export function General(): React.ReactElement {
|
||||
</Button>
|
||||
<Button onClick={upgradeRam}>+ RAM</Button>
|
||||
<br />
|
||||
<Typography>Add Custom Money</Typography>
|
||||
<TextField onChange={(x) => setDevMoney(parseFloat(x.target.value))} />
|
||||
<Button onClick={addCustomMoney}>Give Money</Button>
|
||||
<br />
|
||||
{Player.corporation ? (
|
||||
<Button onClick={destroyCorporation}>Destroy Corporation</Button>
|
||||
) : (
|
||||
<>
|
||||
<Typography>Corporation Name:</Typography>
|
||||
<TextField value={corporationName} onChange={(x) => setCorporationName(x.target.value)} />
|
||||
<Button onClick={createCorporation}>Create Corporation</Button>
|
||||
</>
|
||||
)}
|
||||
<br />
|
||||
{Player.gang ? (
|
||||
<Button onClick={stopGang}>Stop Gang</Button>
|
||||
) : (
|
||||
<>
|
||||
<Typography>Gang Faction:</Typography>
|
||||
<Select value={gangFaction} onChange={setGangFactionDropdown}>
|
||||
{GangConstants.Names.map((factionName) => (
|
||||
@ -118,10 +147,15 @@ export function General(): React.ReactElement {
|
||||
))}
|
||||
</Select>
|
||||
<Button onClick={startGang}>Start Gang</Button>
|
||||
</>
|
||||
)}
|
||||
<br />
|
||||
{Player.bladeburner ? (
|
||||
<Button onClick={leaveBladeburner}>Leave BladeBurner</Button>
|
||||
) : (
|
||||
<Button onClick={joinBladeburner}>Join BladeBurner</Button>
|
||||
)}
|
||||
<br />
|
||||
|
||||
<Button onClick={quickB1tFlum3}>Quick b1t_flum3.exe</Button>
|
||||
<Button onClick={b1tflum3}>Run b1t_flum3.exe</Button>
|
||||
<Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button>
|
||||
|
Loading…
Reference in New Issue
Block a user