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 Bladeburner(props: IProps): React.ReactElement {
|
2021-09-24 00:47:43 +02:00
|
|
|
const bladeburner = props.player.bladeburner;
|
|
|
|
if (bladeburner === null) return <></>;
|
2021-09-14 02:37:35 +02:00
|
|
|
function modifyBladeburnerRank(modify: number): (x: number) => void {
|
|
|
|
return function (rank: number): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
bladeburner.changeRank(props.player, rank * modify);
|
2021-09-14 02:37:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetBladeburnerRank(): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
bladeburner.rank = 0;
|
|
|
|
bladeburner.maxRank = 0;
|
2021-09-14 02:37:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function addTonsBladeburnerRank(): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
|
|
|
|
bladeburner.changeRank(props.player, bigNumber);
|
2021-09-14 02:37:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function modifyBladeburnerCycles(modify: number): (x: number) => void {
|
|
|
|
return function (cycles: number): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
bladeburner.storedCycles += cycles * modify;
|
2021-09-14 02:37:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetBladeburnerCycles(): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
bladeburner.storedCycles = 0;
|
2021-09-14 02:37:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function addTonsBladeburnerCycles(): void {
|
2021-09-24 00:47:43 +02:00
|
|
|
if (!bladeburner) return;
|
|
|
|
bladeburner.storedCycles += bigNumber;
|
2021-09-14 02:37:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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>Bladeburner</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</AccordionSummary>
|
|
|
|
<AccordionDetails>
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-10-01 02:06:40 +02:00
|
|
|
<Typography>Rank:</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Adjuster
|
|
|
|
label="rank"
|
|
|
|
placeholder="amt"
|
|
|
|
tons={addTonsBladeburnerRank}
|
|
|
|
add={modifyBladeburnerRank(1)}
|
|
|
|
subtract={modifyBladeburnerRank(-1)}
|
|
|
|
reset={resetBladeburnerRank}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<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={addTonsBladeburnerCycles}
|
|
|
|
add={modifyBladeburnerCycles(1)}
|
|
|
|
subtract={modifyBladeburnerCycles(-1)}
|
|
|
|
reset={resetBladeburnerCycles}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</AccordionDetails>
|
|
|
|
</Accordion>
|
|
|
|
);
|
|
|
|
}
|