bitburner-src/src/DevMenu/ui/Gang.tsx

68 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-09-14 02:37:35 +02:00
import React from "react";
2021-10-01 02:06:40 +02:00
import Typography from "@mui/material/Typography";
2021-09-17 01:23:03 +02:00
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";
2021-09-14 02:37:35 +02:00
import { Adjuster } from "./Adjuster";
import { IPlayer } from "../../PersonObjects/IPlayer";
const bigNumber = 1e27;
interface IProps {
player: IPlayer;
}
export function Gang(props: IProps): React.ReactElement {
function addTonsGangCycles(): void {
if (props.player.gang) {
props.player.gang.storedCycles = bigNumber;
}
}
function modifyGangCycles(modify: number): (x: number) => void {
return function (cycles: number): void {
if (props.player.gang) {
props.player.gang.storedCycles += cycles * modify;
}
};
}
function resetGangCycles(): void {
if (props.player.gang) {
props.player.gang.storedCycles = 0;
}
}
return (
2021-09-18 03:30:02 +02:00
<Accordion TransitionProps={{ unmountOnExit: true }}>
2021-09-14 02:37:35 +02:00
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
2021-10-01 22:22:33 +02:00
<Typography>Gang</Typography>
2021-09-14 02:37:35 +02:00
</AccordionSummary>
<AccordionDetails>
<table>
<tbody>
<tr>
<td>
2021-10-01 02:06:40 +02:00
<Typography>Cycles:</Typography>
2021-09-14 02:37:35 +02:00
</td>
<td>
<Adjuster
label="cycles"
placeholder="amt"
tons={addTonsGangCycles}
add={modifyGangCycles(1)}
subtract={modifyGangCycles(-1)}
reset={resetGangCycles}
/>
</td>
</tr>
</tbody>
</table>
</AccordionDetails>
</Accordion>
);
}