mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +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 React from "react";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Accordion from "@mui/material/Accordion";
|
import Accordion from "@mui/material/Accordion";
|
||||||
import AccordionSummary from "@mui/material/AccordionSummary";
|
import AccordionSummary from "@mui/material/AccordionSummary";
|
||||||
import AccordionDetails from "@mui/material/AccordionDetails";
|
import AccordionDetails from "@mui/material/AccordionDetails";
|
||||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
import { Adjuster } from "./Adjuster";
|
import { Adjuster } from "./Adjuster";
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
|
import { CityName } from "../../Enums";
|
||||||
|
|
||||||
const bigNumber = 1e27;
|
const bigNumber = 1e27;
|
||||||
|
|
||||||
export function Bladeburner(): React.ReactElement {
|
export function Bladeburner(): React.ReactElement {
|
||||||
|
if (!Player.bladeburner) return <></>;
|
||||||
const bladeburner = Player.bladeburner;
|
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 {
|
// Rank functions
|
||||||
if (!bladeburner) return;
|
const modifyBladeburnerRank = (modify: number) => (rank: number) => bladeburner.changeRank(Player, rank * modify);
|
||||||
|
const resetBladeburnerRank = () => {
|
||||||
bladeburner.rank = 0;
|
bladeburner.rank = 0;
|
||||||
bladeburner.maxRank = 0;
|
bladeburner.maxRank = 0;
|
||||||
}
|
};
|
||||||
|
const addTonsBladeburnerRank = () => bladeburner.changeRank(Player, bigNumber);
|
||||||
|
|
||||||
function addTonsBladeburnerRank(): void {
|
// Skill point functions
|
||||||
if (!bladeburner) return;
|
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 {
|
// Chaos functions
|
||||||
return function (cycles: number): void {
|
const wipeAllChaos = () => Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos = 0));
|
||||||
if (!bladeburner) return;
|
const wipeActiveCityChaos = () => (bladeburner.cities[bladeburner.city].chaos = 0);
|
||||||
bladeburner.storedCycles += cycles * modify;
|
const addAllChaos = (modify: number) => (chaos: number) => {
|
||||||
};
|
Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += chaos * modify));
|
||||||
}
|
};
|
||||||
|
const addTonsAllChaos = () => {
|
||||||
function resetBladeburnerCycles(): void {
|
Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += bigNumber));
|
||||||
if (!bladeburner) return;
|
};
|
||||||
bladeburner.storedCycles = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTonsBladeburnerCycles(): void {
|
|
||||||
if (!bladeburner) return;
|
|
||||||
bladeburner.storedCycles += bigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
||||||
@ -75,7 +73,22 @@ export function Bladeburner(): React.ReactElement {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Typography>Cycles:</Typography>
|
<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>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Adjuster
|
<Adjuster
|
||||||
@ -88,9 +101,25 @@ export function Bladeburner(): React.ReactElement {
|
|||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
|
<Button onClick={wipeActiveCityChaos}>Clear Active City's Chaos</Button>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import Accordion from "@mui/material/Accordion";
|
import Accordion from "@mui/material/Accordion";
|
||||||
import AccordionSummary from "@mui/material/AccordionSummary";
|
import AccordionSummary from "@mui/material/AccordionSummary";
|
||||||
import AccordionDetails from "@mui/material/AccordionDetails";
|
import AccordionDetails from "@mui/material/AccordionDetails";
|
||||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||||
|
|
||||||
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 { Money } from "../../ui/React/Money";
|
import { Money } from "../../ui/React/Money";
|
||||||
@ -15,59 +13,68 @@ import { Bladeburner } from "../../Bladeburner/Bladeburner";
|
|||||||
import { GangConstants } from "../../Gang/data/Constants";
|
import { GangConstants } from "../../Gang/data/Constants";
|
||||||
import { FactionNames } from "../../Faction/data/FactionNames";
|
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||||
import { checkForMessagesToSend } from "../../Message/MessageHelpers";
|
import { checkForMessagesToSend } from "../../Message/MessageHelpers";
|
||||||
|
import { ThemeEvents } from "../../Themes/ui/Theme";
|
||||||
|
|
||||||
export function General(): React.ReactElement {
|
export function General(): React.ReactElement {
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [corporationName, setCorporationName] = useState("");
|
const [corporationName, setCorporationName] = useState("");
|
||||||
const [gangFaction, setGangFaction] = useState("");
|
const [gangFaction, setGangFaction] = useState("Slum Snakes");
|
||||||
|
const [devMoney, setDevMoney] = useState(0);
|
||||||
|
|
||||||
function addMoney(n: number) {
|
// Money functions
|
||||||
return function () {
|
const addCustomMoney = () => !Number.isNaN(devMoney) && Player.gainMoney(devMoney, "other");
|
||||||
Player.gainMoney(n, "other");
|
const addMoney = (n: number) => () => Player.gainMoney(n, "other");
|
||||||
};
|
const setMoney = (n: number) => () => (Player.money = Number(n));
|
||||||
}
|
|
||||||
|
|
||||||
function upgradeRam(): void {
|
// Ram functions
|
||||||
Player.getHomeComputer().maxRam *= 2;
|
const upgradeRam = () => (Player.getHomeComputer().maxRam *= 2);
|
||||||
}
|
|
||||||
|
|
||||||
function quickB1tFlum3(): void {
|
// Node-clearing functions
|
||||||
Router.toBitVerse(true, true);
|
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 {
|
// Corp functions
|
||||||
Router.toBitVerse(true, false);
|
const createCorporation = () => {
|
||||||
}
|
|
||||||
|
|
||||||
function quickHackW0r1dD43m0n(): void {
|
|
||||||
Router.toBitVerse(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function hackW0r1dD43m0n(): void {
|
|
||||||
Router.toBitVerse(false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createCorporation(): void {
|
|
||||||
Player.startCorporation(corporationName);
|
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();
|
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;
|
const isHacking = gangFaction === FactionNames.NiteSec || gangFaction === FactionNames.TheBlackHand;
|
||||||
Player.startGang(gangFaction, isHacking);
|
Player.startGang(gangFaction, isHacking);
|
||||||
}
|
// Rerender so the gang menu option will show up immediately on the devmenu page selection
|
||||||
|
ThemeEvents.emit();
|
||||||
function setGangFactionDropdown(event: SelectChangeEvent<string>): void {
|
};
|
||||||
setGangFaction(event.target.value);
|
const stopGang = () => {
|
||||||
}
|
Player.gang = null;
|
||||||
|
// Rerender so the gang menu option will be removed immediately on the devmenu page selection
|
||||||
function checkMessages(): void {
|
ThemeEvents.emit();
|
||||||
checkForMessagesToSend();
|
};
|
||||||
}
|
const setGangFactionDropdown = (event: SelectChangeEvent<string>) => setGangFaction(event.target.value);
|
||||||
|
|
||||||
|
// Misc functions
|
||||||
|
const checkMessages = () => checkForMessagesToSend();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) throw new ReferenceError("Manually thrown error");
|
if (error) throw new ReferenceError("Manually thrown error");
|
||||||
}, [error]);
|
}, [error]);
|
||||||
@ -78,6 +85,14 @@ export function General(): React.ReactElement {
|
|||||||
<Typography>General</Typography>
|
<Typography>General</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails>
|
<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)}>
|
<Button onClick={addMoney(1e6)}>
|
||||||
<pre>
|
<pre>
|
||||||
+ <Money money={1e6} />
|
+ <Money money={1e6} />
|
||||||
@ -105,23 +120,42 @@ export function General(): React.ReactElement {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button onClick={upgradeRam}>+ RAM</Button>
|
<Button onClick={upgradeRam}>+ RAM</Button>
|
||||||
<br />
|
<br />
|
||||||
<Typography>Corporation Name:</Typography>
|
<Typography>Add Custom Money</Typography>
|
||||||
<TextField value={corporationName} onChange={(x) => setCorporationName(x.target.value)} />
|
<TextField onChange={(x) => setDevMoney(parseFloat(x.target.value))} />
|
||||||
<Button onClick={createCorporation}>Create Corporation</Button>
|
<Button onClick={addCustomMoney}>Give Money</Button>
|
||||||
<br />
|
<br />
|
||||||
<Typography>Gang Faction:</Typography>
|
{Player.corporation ? (
|
||||||
<Select value={gangFaction} onChange={setGangFactionDropdown}>
|
<Button onClick={destroyCorporation}>Destroy Corporation</Button>
|
||||||
{GangConstants.Names.map((factionName) => (
|
) : (
|
||||||
<MenuItem key={factionName} value={factionName}>
|
<>
|
||||||
{factionName}
|
<Typography>Corporation Name:</Typography>
|
||||||
</MenuItem>
|
<TextField value={corporationName} onChange={(x) => setCorporationName(x.target.value)} />
|
||||||
))}
|
<Button onClick={createCorporation}>Create Corporation</Button>
|
||||||
</Select>
|
</>
|
||||||
<Button onClick={startGang}>Start Gang</Button>
|
)}
|
||||||
<br />
|
<br />
|
||||||
<Button onClick={joinBladeburner}>Join BladeBurner</Button>
|
{Player.gang ? (
|
||||||
|
<Button onClick={stopGang}>Stop Gang</Button>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Typography>Gang Faction:</Typography>
|
||||||
|
<Select value={gangFaction} onChange={setGangFactionDropdown}>
|
||||||
|
{GangConstants.Names.map((factionName) => (
|
||||||
|
<MenuItem key={factionName} value={factionName}>
|
||||||
|
{factionName}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
<Button onClick={startGang}>Start Gang</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<br />
|
||||||
|
{Player.bladeburner ? (
|
||||||
|
<Button onClick={leaveBladeburner}>Leave BladeBurner</Button>
|
||||||
|
) : (
|
||||||
|
<Button onClick={joinBladeburner}>Join BladeBurner</Button>
|
||||||
|
)}
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<Button onClick={quickB1tFlum3}>Quick b1t_flum3.exe</Button>
|
<Button onClick={quickB1tFlum3}>Quick b1t_flum3.exe</Button>
|
||||||
<Button onClick={b1tflum3}>Run b1t_flum3.exe</Button>
|
<Button onClick={b1tflum3}>Run b1t_flum3.exe</Button>
|
||||||
<Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button>
|
<Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user