bitburner-src/src/PersonObjects/Sleeve/ui/StatsElement.tsx

175 lines
8.0 KiB
TypeScript
Raw Normal View History

2021-09-27 02:55:38 +02:00
import React from "react";
2022-03-11 06:02:32 +01:00
2022-04-07 01:30:08 +02:00
import { Typography, Table, TableBody, TableCell, TableRow } from "@mui/material";
2021-09-27 02:55:38 +02:00
2022-03-11 06:02:32 +01:00
import { numeralWrapper } from "../../../ui/numeralFormat";
import { Settings } from "../../../Settings/Settings";
2022-03-12 22:49:07 +01:00
import { StatsRow } from "../../../ui/React/StatsRow";
import { characterOverviewStyles as useStyles } from "../../../ui/React/CharacterOverview";
import { Money } from "../../../ui/React/Money";
import { MoneyRate } from "../../../ui/React/MoneyRate";
import { ReputationRate } from "../../../ui/React/ReputationRate";
import { use } from "../../../ui/Context";
2022-03-11 06:02:32 +01:00
import { Sleeve } from "../Sleeve";
2022-07-28 02:37:32 +02:00
import { isSleeveClassWork } from "../Work/SleeveClassWork";
import { isSleeveFactionWork } from "../Work/SleeveFactionWork";
import { isSleeveCompanyWork } from "../Work/SleeveCompanyWork";
2022-07-28 08:46:34 +02:00
import { isSleeveCrimeWork } from "../Work/SleeveCrimeWork";
2022-08-25 17:18:01 +02:00
import { BitNodeMultipliers } from "../../../BitNode/BitNodeMultipliers";
2022-03-11 06:02:32 +01:00
interface IProps {
sleeve: Sleeve;
}
export function StatsElement(props: IProps): React.ReactElement {
const classes = useStyles();
return (
2022-04-07 01:30:08 +02:00
<Table sx={{ display: "table", mb: 1, width: "100%" }}>
<TableBody>
2022-03-12 22:49:07 +01:00
<StatsRow name="City" color={Settings.theme.primary} data={{ content: props.sleeve.city }} />
2022-04-07 01:30:08 +02:00
<StatsRow
name="HP"
color={Settings.theme.hp}
data={{
content: `${numeralWrapper.formatHp(props.sleeve.hp.current)} / ${numeralWrapper.formatHp(
props.sleeve.hp.max,
)}`,
2022-04-07 01:30:08 +02:00
}}
/>
<StatsRow
name="Hacking"
color={Settings.theme.hack}
data={{ level: props.sleeve.skills.hacking, exp: props.sleeve.exp.hacking }}
2022-04-07 01:30:08 +02:00
/>
<StatsRow
name="Strength"
color={Settings.theme.combat}
data={{ level: props.sleeve.skills.strength, exp: props.sleeve.exp.strength }}
2022-04-07 01:30:08 +02:00
/>
<StatsRow
name="Defense"
color={Settings.theme.combat}
data={{ level: props.sleeve.skills.defense, exp: props.sleeve.exp.defense }}
2022-04-07 01:30:08 +02:00
/>
<StatsRow
name="Dexterity"
color={Settings.theme.combat}
data={{ level: props.sleeve.skills.dexterity, exp: props.sleeve.exp.dexterity }}
2022-04-07 01:30:08 +02:00
/>
<StatsRow
name="Agility"
color={Settings.theme.combat}
data={{ level: props.sleeve.skills.agility, exp: props.sleeve.exp.agility }}
2022-04-07 01:30:08 +02:00
/>
<StatsRow
name="Charisma"
color={Settings.theme.cha}
data={{ level: props.sleeve.skills.charisma, exp: props.sleeve.exp.charisma }}
/>
<TableRow>
<TableCell classes={{ root: classes.cellNone }}>
<br />
</TableCell>
</TableRow>
2022-04-07 01:30:08 +02:00
<StatsRow
name="Shock"
color={Settings.theme.primary}
data={{ content: numeralWrapper.formatSleeveShock(100 - props.sleeve.shock) }}
/>
<StatsRow
name="Sync"
color={Settings.theme.primary}
data={{ content: numeralWrapper.formatSleeveSynchro(props.sleeve.sync) }}
/>
<StatsRow
name="Memory"
color={Settings.theme.primary}
data={{ content: numeralWrapper.formatSleeveMemory(props.sleeve.memory) }}
/>
</TableBody>
</Table>
2022-04-07 01:30:08 +02:00
);
}
export function EarningsElement(props: IProps): React.ReactElement {
const classes = useStyles();
const player = use.Player();
2022-07-18 09:11:49 +02:00
let data: (string | JSX.Element)[][] = [];
2022-07-28 08:46:34 +02:00
if (isSleeveCrimeWork(props.sleeve.currentWork)) {
const gains = props.sleeve.currentWork.getExp();
data = [
2022-08-25 17:18:01 +02:00
[`Money:`, <Money money={5 * gains.money * BitNodeMultipliers.CrimeMoney} />],
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * gains.hackExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * gains.strExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * gains.defExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * gains.dexExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * gains.agiExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * gains.chaExp * BitNodeMultipliers.CrimeExpGain)}`],
];
}
2022-07-28 02:37:32 +02:00
if (isSleeveClassWork(props.sleeve.currentWork)) {
const rates = props.sleeve.currentWork.calculateRates(player, props.sleeve);
data = [
[`Money:`, <MoneyRate money={5 * rates.money} />],
2022-08-25 17:18:01 +02:00
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.ClassGymExpGain)} / sec`],
2022-07-28 02:37:32 +02:00
];
}
if (isSleeveFactionWork(props.sleeve.currentWork)) {
const rates = props.sleeve.currentWork.getExpRates(props.sleeve);
const repGain = props.sleeve.currentWork.getReputationRate(props.sleeve);
data = [
2022-08-25 17:18:01 +02:00
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`],
[`Reputation:`, <ReputationRate reputation={5 * repGain * BitNodeMultipliers.FactionWorkRepGain} />],
2022-07-28 02:37:32 +02:00
];
}
if (isSleeveCompanyWork(props.sleeve.currentWork)) {
const rates = props.sleeve.currentWork.getGainRates(player, props.sleeve);
data = [
2022-08-25 17:18:01 +02:00
[`Money:`, <MoneyRate money={5 * rates.money * BitNodeMultipliers.CompanyWorkMoney} />],
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`],
2022-07-28 02:37:32 +02:00
[`Reputation:`, <ReputationRate reputation={5 * rates.reputation} />],
];
}
return (
2022-04-07 01:30:08 +02:00
<Table sx={{ display: "table", mb: 1, width: "100%", lineHeight: 0 }}>
<TableBody>
<TableRow>
<TableCell classes={{ root: classes.cellNone }}>
2022-07-28 02:37:32 +02:00
<Typography variant="h6">Earnings {props.sleeve.storedCycles > 50 ? "(overclock)" : ""}</Typography>
</TableCell>
</TableRow>
{data.map(([a, b]) => (
<TableRow key={a.toString() + b.toString()}>
<TableCell classes={{ root: classes.cellNone }}>
<Typography>{a}</Typography>
</TableCell>
<TableCell align="right" classes={{ root: classes.cellNone }}>
<Typography>{b}</Typography>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
2022-04-07 01:30:08 +02:00
);
2022-03-11 05:21:02 +01:00
}