bitburner-src/src/Faction/ui/Info.tsx

114 lines
3.7 KiB
TypeScript
Raw Normal View History

2019-04-14 11:08:10 +02:00
/**
* React component for general information about the faction. This includes the
* factions "motto", reputation, favor, and gameplay instructions
*/
2021-09-22 18:56:55 +02:00
import React, { useState, useEffect } from "react";
2019-04-14 11:08:10 +02:00
import { Faction } from "../../Faction/Faction";
import { FactionInfo } from "../../Faction/FactionInfo";
import { Reputation } from "../../ui/React/Reputation";
import { Favor } from "../../ui/React/Favor";
2021-10-13 08:15:29 +02:00
import { MathJax, MathJaxContext } from "better-react-mathjax";
2019-04-14 11:08:10 +02:00
2021-09-21 02:42:13 +02:00
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
import Typography from "@mui/material/Typography";
import Tooltip from "@mui/material/Tooltip";
import Box from "@mui/material/Box";
2019-04-14 11:08:10 +02:00
type IProps = {
2021-09-05 01:09:30 +02:00
faction: Faction;
factionInfo: FactionInfo;
};
2019-04-14 11:08:10 +02:00
2021-09-25 08:36:49 +02:00
const useStyles = makeStyles(() =>
2021-09-21 02:42:13 +02:00
createStyles({
noformat: {
2021-09-21 23:12:16 +02:00
whiteSpace: "pre-wrap",
2021-09-25 17:23:56 +02:00
lineHeight: "1em",
2021-09-21 02:42:13 +02:00
},
}),
);
2021-09-21 02:42:13 +02:00
export function Info(props: IProps): React.ReactElement {
2021-09-22 18:56:55 +02:00
const setRerender = useState(false)[1];
2021-09-22 18:49:29 +02:00
function rerender(): void {
setRerender((old) => !old);
}
useEffect(() => {
2021-09-25 19:31:42 +02:00
const id = setInterval(rerender, 200);
2021-09-22 18:49:29 +02:00
return () => clearInterval(id);
}, []);
2021-09-21 02:42:13 +02:00
const classes = useStyles();
2021-09-21 02:42:13 +02:00
const favorGain = props.faction.getFavorGain()[0];
return (
<>
<Typography classes={{ root: classes.noformat }}>{props.factionInfo.infoText}</Typography>
<Typography>-------------------------</Typography>
<Box display="flex">
<Tooltip
title={
2021-09-21 19:08:05 +02:00
<>
<Typography>
2021-10-01 19:08:37 +02:00
You will have <Favor favor={props.faction.favor + favorGain} /> faction favor after installing an
Augmentation.
2021-09-21 19:08:05 +02:00
</Typography>
2021-10-13 08:15:29 +02:00
<MathJaxContext>
2021-10-13 08:42:43 +02:00
<MathJax>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJax>
2021-10-13 08:15:29 +02:00
</MathJaxContext>
<MathJaxContext>
2021-10-13 08:42:43 +02:00
<MathJax>
{"\\(\\huge{favor=\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"}
</MathJax>
2021-10-13 08:15:29 +02:00
</MathJaxContext>
2021-09-21 19:08:05 +02:00
</>
2021-09-21 02:42:13 +02:00
}
>
2021-10-01 19:08:37 +02:00
<Typography>
Reputation: <Reputation reputation={props.faction.playerReputation} />
</Typography>
2021-09-21 02:42:13 +02:00
</Tooltip>
</Box>
2019-04-14 11:08:10 +02:00
2021-09-21 02:42:13 +02:00
<Typography>-------------------------</Typography>
2021-09-21 02:42:13 +02:00
<Box display="flex">
<Tooltip
title={
2021-09-21 19:08:05 +02:00
<>
<Typography>
Faction favor increases the rate at which you earn reputation for this faction by 1% per favor. Faction
favor is gained whenever you install an Augmentation. The amount of favor you gain depends on the total
amount of reputation you earned with this faction. Across all resets.
</Typography>
2021-10-13 08:15:29 +02:00
<MathJaxContext>
2021-10-13 08:42:43 +02:00
<MathJax>{"\\(\\huge{r = reputation}\\)"}</MathJax>
2021-10-13 08:15:29 +02:00
</MathJaxContext>
<MathJaxContext>
2021-10-13 08:42:43 +02:00
<MathJax>{"\\(\\huge{\\Delta r = \\Delta r \\times \\frac{100+favor}{100}}\\)"}</MathJax>
2021-10-13 08:15:29 +02:00
</MathJaxContext>
2021-09-21 19:08:05 +02:00
</>
2021-09-21 02:42:13 +02:00
}
>
2021-10-01 19:08:37 +02:00
<Typography>
Faction Favor: <Favor favor={props.faction.favor} />
</Typography>
2021-09-21 02:42:13 +02:00
</Tooltip>
</Box>
2019-04-14 11:08:10 +02:00
2021-09-21 02:42:13 +02:00
<Typography>-------------------------</Typography>
<Typography>
Perform work/carry out assignments for your faction to help further its cause! By doing so you will earn
reputation for your faction. You will also gain reputation passively over time, although at a very slow rate.
Earning reputation will allow you to purchase Augmentations through this faction, which are powerful upgrades
that enhance your abilities.
</Typography>
</>
);
2019-04-14 11:08:10 +02:00
}