import * as React 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";
export function CharacterInfo(p: IPlayer): React.ReactElement {
function LastEmployer(): React.ReactElement {
if (p.companyName) {
return <>Employer at which you last worked: {p.companyName} >;
}
return <>>;
}
function LastJob(): React.ReactElement {
if (p.companyName !== "") {
return <>Job you last worked: {p.jobs[p.companyName]} >;
}
return <>>;
}
function Employers(): React.ReactElement {
if (p.jobs && Object.keys(p.jobs).length !== 0)
return <>
All Employers:
{Object.keys(p.jobs).map(j =>
* {j}
)}
>
return <>>;
}
function Hacknet(): React.ReactElement {
// Can't import HacknetHelpers for some reason.
if(!(p.bitNodeN === 9 || SourceFileFlags[9] > 0)) {
return <>Hacknet Nodes owned: {p.hacknetNodes.length} >
} else {
return <>Hacknet Servers owned: {p.hacknetNodes.length} / {HacknetServerConstants.MaxServers} >
}
}
function convertMoneySourceTrackerToString(src: MoneySourceTracker): React.ReactElement {
let parts: any[][] = [[`Total:`, Money(src.total)]];
if (src.bladeburner) { parts.push([`Bladeburner:`, Money(src.bladeburner)]) };
if (src.codingcontract) { parts.push([`Coding Contracts:`, Money(src.codingcontract)]) };
if (src.work) { parts.push([`Company Work:`, Money(src.work)]) };
if (src.corporation) { parts.push([`Corporation:`, Money(src.corporation)]) };
if (src.crime) { parts.push([`Crimes:`, Money(src.crime)]) };
if (src.gang) { parts.push([`Gang:`, Money(src.gang)]) };
if (src.hacking) { parts.push([`Hacking:`, Money(src.hacking)]) };
if (src.hacknetnode) { parts.push([`Hacknet Nodes:`, Money(src.hacknetnode)]) };
if (src.hospitalization) { parts.push([`Hospitalization:`, Money(src.hospitalization)]) };
if (src.infiltration) { parts.push([`Infiltration:`, Money(src.infiltration)]) };
if (src.stock) { parts.push([`Stock Market:`, Money(src.stock)]) };
return StatsTable(parts, "");
}
function openMoneyModal() {
let content = (<>
Money earned since you last installed Augmentations:
{convertMoneySourceTrackerToString(p.moneySourceA)}
>);
if (p.sourceFiles.length !== 0) {
content = (<>{content}
Money earned in this BitNode:
{convertMoneySourceTrackerToString(p.moneySourceB)}>);
}
dialogBoxCreate(content, false);
}
function Intelligence(): React.ReactElement {
if (p.intelligence > 0) {
return
>
}
function CurrentBitNode(): React.ReactElement {
if(p.sourceFiles.length > 0) {
const index = "BitNode" + p.bitNodeN;
return <>
Current BitNode: {p.bitNodeN} ({BitNodes[index].name})
{BitNodes[index].info.split(" ").map((t, i) =>
{t}
)}
>
}
return <>>
}
const timeRows = [
['Time played since last Augmentation:', convertTimeMsToTimeElapsedString(p.playtimeSinceLastAug)],
]
if(p.sourceFiles.length > 0) {
timeRows.push(['Time played since last Bitnode destroyed:', convertTimeMsToTimeElapsedString(p.playtimeSinceLastBitnode)]);
}
timeRows.push(['Total Time played:', convertTimeMsToTimeElapsedString(p.totalPlaytime)])
return (
General
Current City: {p.city} Money: {Money(p.money.toNumber())}