2023-10-03 06:36:51 +02:00
|
|
|
import React, { useState } from "react";
|
2021-09-14 02:37:35 +02:00
|
|
|
|
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
|
|
|
|
2021-10-01 02:06:40 +02:00
|
|
|
import Typography from "@mui/material/Typography";
|
2021-09-17 01:23:03 +02:00
|
|
|
import Button from "@mui/material/Button";
|
2022-10-10 00:42:14 +02:00
|
|
|
import { Player } from "@player";
|
2021-09-17 01:23:03 +02:00
|
|
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
2021-09-14 02:37:35 +02:00
|
|
|
|
|
|
|
// Update as additional BitNodes get implemented
|
2022-01-09 21:22:23 +01:00
|
|
|
const validSFN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
|
2023-10-03 06:36:51 +02:00
|
|
|
const initialState = validSFN.reduce((obj, sfN) => ({ ...obj, [sfN]: "" }), { "": "" });
|
2021-09-14 02:37:35 +02:00
|
|
|
|
2023-06-27 04:29:44 +02:00
|
|
|
export function SourceFilesDev(): React.ReactElement {
|
2023-10-03 06:36:51 +02:00
|
|
|
const [sfData, setSfData] = useState(initialState);
|
|
|
|
|
2021-09-14 02:37:35 +02:00
|
|
|
function setSF(sfN: number, sfLvl: number) {
|
|
|
|
return function () {
|
2022-01-16 00:13:35 +01:00
|
|
|
if (sfN === 9) {
|
2022-09-06 15:07:12 +02:00
|
|
|
Player.hacknetNodes = [];
|
2022-01-16 00:13:35 +01:00
|
|
|
}
|
2021-09-14 02:37:35 +02:00
|
|
|
if (sfLvl === 0) {
|
2023-04-18 09:19:45 +02:00
|
|
|
Player.sourceFiles.delete(sfN);
|
2023-10-03 06:36:51 +02:00
|
|
|
setSfData({ ...sfData, [sfN]: sfLvl });
|
2021-09-14 02:37:35 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-04-18 09:19:45 +02:00
|
|
|
Player.sourceFiles.set(sfN, sfLvl);
|
2023-10-03 06:36:51 +02:00
|
|
|
setSfData({ ...sfData, [sfN]: sfLvl });
|
2021-09-14 02:37:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function setAllSF(sfLvl: number) {
|
|
|
|
return () => {
|
|
|
|
for (let i = 0; i < validSFN.length; i++) {
|
|
|
|
setSF(validSFN[i], sfLvl)();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearExploits(): void {
|
2022-09-06 15:07:12 +02:00
|
|
|
Player.exploits = [];
|
2021-09-14 02:37:35 +02:00
|
|
|
}
|
|
|
|
|
2023-10-03 06:36:51 +02:00
|
|
|
const setallButtonStyle = { borderColor: "", background: "black" };
|
|
|
|
const ownedStyle = { borderColor: "green", background: "" };
|
|
|
|
const notOwnedStyle = { borderColor: "", background: "black" };
|
|
|
|
|
|
|
|
const devLvls = [0, 1, 2, 3];
|
|
|
|
|
|
|
|
const buttonGroup = (sfN?: number) =>
|
|
|
|
devLvls.map((lvl) => {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
key={lvl}
|
|
|
|
onClick={sfN === undefined ? setAllSF(lvl) : setSF(sfN, lvl)}
|
|
|
|
style={sfN === undefined ? setallButtonStyle : Player.sourceFileLvl(sfN) >= lvl ? ownedStyle : notOwnedStyle}
|
|
|
|
>
|
|
|
|
{lvl}
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
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>Source-Files</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</AccordionSummary>
|
|
|
|
<AccordionDetails>
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-10-01 02:06:40 +02:00
|
|
|
<Typography>Exploits:</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={clearExploits}>Clear</Button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr key={"sf-all"}>
|
|
|
|
<td>
|
2023-10-03 06:36:51 +02:00
|
|
|
<Typography>Set All:</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2023-10-03 06:36:51 +02:00
|
|
|
<ButtonGroup>{buttonGroup()}</ButtonGroup>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
2023-10-03 06:36:51 +02:00
|
|
|
{validSFN.map((sfN) => (
|
|
|
|
<tr key={"sf-" + sfN}>
|
2021-09-14 02:37:35 +02:00
|
|
|
<td>
|
2023-10-03 06:36:51 +02:00
|
|
|
<Typography>SF-{sfN}:</Typography>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2023-10-03 06:36:51 +02:00
|
|
|
<ButtonGroup>{buttonGroup(sfN)}</ButtonGroup>
|
2021-09-14 02:37:35 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</AccordionDetails>
|
|
|
|
</Accordion>
|
|
|
|
);
|
|
|
|
}
|