// Root React Component for the Corporation UI
import React, { useState, useEffect } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { numeralWrapper } from "../../ui/numeralFormat";
import { Reputation } from "./Reputation";
import Table from "@material-ui/core/Table";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableContainer from "@material-ui/core/TableContainer";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
import Paper from "@material-ui/core/Paper";
import Box from "@material-ui/core/Box";
import Typography from "@material-ui/core/Typography";
import Divider from "@material-ui/core/Divider";
import Button from "@material-ui/core/Button";
import Collapse from "@material-ui/core/Collapse";
import { colors } from "./Theme";
interface IProps {
player: IPlayer;
save: () => void;
}
function Intelligence({ player }: { player: IPlayer }): React.ReactElement {
if (player.intelligence === 0) return <>>;
const classes = useStyles();
return (
Int
{numeralWrapper.formatSkill(player.intelligence)}
);
}
function Work({ player }: { player: IPlayer }): React.ReactElement {
if (!player.isWorking || player.focus) return <>>;
const classes = useStyles();
return (
<>
Work in progress:
+{Reputation(player.workRepGained)} rep
>
);
}
const useStyles = makeStyles({
cellNone: {
borderBottom: "none",
padding: 0,
margin: 0,
},
cell: {
padding: 0,
margin: 0,
},
hp: {
color: colors.hp,
},
money: {
color: colors.money,
},
hack: {
color: colors.hack,
},
combat: {
color: colors.combat,
},
cha: {
color: colors.cha,
},
int: {
color: colors.int,
},
});
export function CharacterOverview({ player, save }: IProps): React.ReactElement {
const setRerender = useState(false)[1];
useEffect(() => {
const id = setInterval(() => setRerender((old) => !old), 600);
return () => clearInterval(id);
}, []);
const classes = useStyles();
return (
HP
{numeralWrapper.formatHp(player.hp)} / {numeralWrapper.formatHp(player.max_hp)}
Money
{numeralWrapper.formatMoney(player.money.toNumber())}
Hack
{numeralWrapper.formatSkill(player.hacking_skill)}
Str
{numeralWrapper.formatSkill(player.strength)}
Def
{numeralWrapper.formatSkill(player.defense)}
Dex
{numeralWrapper.formatSkill(player.dexterity)}
Agi
{numeralWrapper.formatSkill(player.agility)}
Cha
{numeralWrapper.formatSkill(player.charisma)}
);
}