import React, { useState, useEffect } from "react"; import { numeralWrapper } from "../ui/numeralFormat"; import { BitNodes } from "../BitNode/BitNode"; import { IPlayer } from "../PersonObjects/IPlayer"; import { MoneySourceTracker } from "../utils/MoneySourceTracker"; import { dialogBoxCreate } from "../../utils/DialogBox"; import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { SourceFileFlags } from "../SourceFile/SourceFileFlags"; import { getPurchaseServerLimit } from "../Server/ServerPurchases"; import { HacknetServerConstants } from "../Hacknet/data/Constants"; import { StatsTable } from "./React/StatsTable"; import { Money } from "./React/Money"; import { use } from "./Context"; import Typography from "@mui/material/Typography"; function LastEmployer(): React.ReactElement { const player = use.Player(); if (player.companyName) { return ( <> Employer at which you last worked: {player.companyName}
); } return <>; } function LastJob(): React.ReactElement { const player = use.Player(); if (player.companyName !== "") { return ( <> Job you last worked: {player.jobs[player.companyName]}
); } return <>; } function Employers(): React.ReactElement { const player = use.Player(); if (player.jobs && Object.keys(player.jobs).length !== 0) return ( <> All Employers:


); return <>; } function Hacknet(): React.ReactElement { const player = use.Player(); // Can't import HacknetHelpers for some reason. if (!(player.bitNodeN === 9 || SourceFileFlags[9] > 0)) { return ( <> {`Hacknet Nodes owned: ${player.hacknetNodes.length}`}
); } else { return ( <> {`Hacknet Servers owned: ${player.hacknetNodes.length} / ${HacknetServerConstants.MaxServers}`}
); } } function Intelligence(): React.ReactElement { const player = use.Player(); if (player.intelligence > 0 && (player.bitNodeN === 5 || SourceFileFlags[5] > 0)) { return ( Intelligence: {numeralWrapper.formatSkill(player.intelligence)} ); } return <>; } function MultiplierTable(props: any): React.ReactElement { function bn5Stat(r: any): JSX.Element { if (SourceFileFlags[5] > 0 && r.length > 2 && r[1] != r[2]) { return ( {" "} ({numeralWrapper.formatPercentage(r[2])}) ); } return <>; } return ( <> {props.rows.map((r: any) => ( {bn5Stat(r)} ))}
{`${r[0]} multiplier:`} {numeralWrapper.formatPercentage(r[1])}
); } function BladeburnerMults(): React.ReactElement { const player = use.Player(); if (!player.canAccessBladeburner()) return <>; return ( <>
); } function CurrentBitNode(): React.ReactElement { const player = use.Player(); if (player.sourceFiles.length > 0) { const index = "BitNode" + player.bitNodeN; return ( <> Current BitNode: {player.bitNodeN} ({BitNodes[index].name})

{BitNodes[index].info}
); } return <>; } export function CharacterStats(): React.ReactElement { const player = use.Player(); const setRerender = useState(false)[1]; function rerender(): void { setRerender((old) => !old); } useEffect(() => { const id = setInterval(rerender, 20); return () => clearInterval(id); }, []); function convertMoneySourceTrackerToString(src: MoneySourceTracker): React.ReactElement { const parts: any[][] = [[`Total:`, ]]; if (src.bladeburner) { parts.push([`Bladeburner:`, ]); } if (src.codingcontract) { parts.push([`Coding Contracts:`, ]); } if (src.work) { parts.push([`Company Work:`, ]); } if (src.class) { parts.push([`Class:`, ]); } if (src.corporation) { parts.push([`Corporation:`, ]); } if (src.crime) { parts.push([`Crimes:`, ]); } if (src.gang) { parts.push([`Gang:`, ]); } if (src.hacking) { parts.push([`Hacking:`, ]); } if (src.hacknetnode) { parts.push([`Hacknet Nodes:`, ]); } if (src.hospitalization) { parts.push([`Hospitalization:`, ]); } if (src.infiltration) { parts.push([`Infiltration:`, ]); } if (src.stock) { parts.push([`Stock Market:`, ]); } if (src.casino) { parts.push([`Casino:`, ]); } if (src.sleeves) { parts.push([`Sleeves:`, ]); } return StatsTable(parts); } function openMoneyModal(): void { let content = ( <> Money earned since you last installed Augmentations:
{convertMoneySourceTrackerToString(player.moneySourceA)} ); if (player.sourceFiles.length !== 0) { content = ( <> {content}

Money earned in this BitNode:
{convertMoneySourceTrackerToString(player.moneySourceB)} ); } dialogBoxCreate(content, false); } const timeRows = [ ["Time played since last Augmentation:", convertTimeMsToTimeElapsedString(player.playtimeSinceLastAug)], ]; if (player.sourceFiles.length > 0) { timeRows.push([ "Time played since last Bitnode destroyed:", convertTimeMsToTimeElapsedString(player.playtimeSinceLastBitnode), ]); } timeRows.push(["Total Time played:", convertTimeMsToTimeElapsedString(player.totalPlaytime)]); return ( <>
        General
        

Current City: {player.city}
Money:

Stats
Hacking: {numeralWrapper.formatSkill(player.hacking_skill)} ({numeralWrapper.formatExp(player.hacking_exp)} exp)
Strength: {numeralWrapper.formatSkill(player.strength)} ({numeralWrapper.formatExp(player.strength_exp)} exp)
Defense: {numeralWrapper.formatSkill(player.defense)} ({numeralWrapper.formatExp(player.defense_exp)} exp)
Dexterity: {numeralWrapper.formatSkill(player.dexterity)} ({numeralWrapper.formatExp(player.dexterity_exp)} exp)
Agility: {numeralWrapper.formatSkill(player.agility)} ({numeralWrapper.formatExp(player.agility_exp)} exp)
Charisma: {numeralWrapper.formatSkill(player.charisma)} ({numeralWrapper.formatExp(player.charisma_exp)} exp)












Misc.

{`Servers owned: ${player.purchasedServers.length} / ${getPurchaseServerLimit()}`}
{`Augmentations installed: ${player.augmentations.length}`}

{StatsTable(timeRows)}
); }