Character percentages are aligned, server and hacknet limit are displayed, if the player has SF5 the reduces stats are shown.

This commit is contained in:
Olivier Gagnon 2021-03-07 15:58:52 -05:00
parent 31e8ca8c8d
commit 58e38faad6
5 changed files with 242 additions and 159 deletions

0
doc/Stats Normal file

@ -254,5 +254,7 @@ export let CONSTANTS: IMap<any> = {
* minor formatting under Hacking>Active Scripts * minor formatting under Hacking>Active Scripts
* typo in BN12 description * typo in BN12 description
* BN12 now reduces contract money * BN12 now reduces contract money
* Character>Stats percentages are aligned, server and hacknet limit are
displayed, if the player has SF5 the reduces stats are shown.
` `
} }

@ -86,7 +86,7 @@ import {
} from "./PersonObjects/Resleeving/ResleevingUI"; } from "./PersonObjects/Resleeving/ResleevingUI";
import { createStatusText } from "./ui/createStatusText"; import { createStatusText } from "./ui/createStatusText";
import { displayCharacterInfo } from "./ui/displayCharacterInfo"; import { CharacterInfo } from "./ui/CharacterInfo";
import { Page, routing } from "./ui/navigationTracking"; import { Page, routing } from "./ui/navigationTracking";
import { numeralWrapper } from "./ui/numeralFormat"; import { numeralWrapper } from "./ui/numeralFormat";
import { setSettingsLabels } from "./ui/setSettingsLabels"; import { setSettingsLabels } from "./ui/setSettingsLabels";
@ -567,7 +567,7 @@ const Engine = {
/// Display character info /// Display character info
updateCharacterInfo: function() { updateCharacterInfo: function() {
displayCharacterInfo(Engine.Display.characterInfo, Player); ReactDOM.render(CharacterInfo(Player), Engine.Display.characterInfo)
}, },
// TODO Refactor this into Faction implementation // TODO Refactor this into Faction implementation

238
src/ui/CharacterInfo.tsx Normal file

@ -0,0 +1,238 @@
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 { MaxNumberHacknetServers } from "../Hacknet/HacknetServer";
export function CharacterInfo(p: IPlayer): React.ReactElement {
function LastEmployer(): React.ReactElement {
if (p.companyName) {
return <><span>Employer at which you last worked: {p.companyName}</span><br /></>;
}
return <></>;
}
function LastJob(): React.ReactElement {
if (p.companyName !== "") {
return <><span>Job you last worked: {p.jobs[p.companyName]}</span><br /></>;
}
return <></>;
}
function Employers(): React.ReactElement {
if (p.jobs && Object.keys(p.jobs).length !== 0)
return <>
<span>All Employers:</span><br />
<ul>
{Object.keys(p.jobs).map(j => <li key='j'> * {j}</li>)}
</ul><br /><br />
</>
return <></>;
}
function convertMoneySourceTrackerToString(src: MoneySourceTracker): string {
let parts: string[] = [`Total: ${numeralWrapper.formatMoney(src.total)}`];
if (src.bladeburner) { parts.push(`Bladeburner: ${numeralWrapper.formatMoney(src.bladeburner)}`) };
if (src.codingcontract) { parts.push(`Coding Contracts: ${numeralWrapper.formatMoney(src.codingcontract)}`) };
if (src.work) { parts.push(`Company Work: ${numeralWrapper.formatMoney(src.work)}`) };
if (src.corporation) { parts.push(`Corporation: ${numeralWrapper.formatMoney(src.corporation)}`) };
if (src.crime) { parts.push(`Crimes: ${numeralWrapper.formatMoney(src.crime)}`) };
if (src.gang) { parts.push(`Gang: ${numeralWrapper.formatMoney(src.gang)}`) };
if (src.hacking) { parts.push(`Hacking: ${numeralWrapper.formatMoney(src.hacking)}`) };
if (src.hacknetnode) { parts.push(`Hacknet Nodes: ${numeralWrapper.formatMoney(src.hacknetnode)}`) };
if (src.hospitalization) { parts.push(`Hospitalization: ${numeralWrapper.formatMoney(src.hospitalization)}`) };
if (src.infiltration) { parts.push(`Infiltration: ${numeralWrapper.formatMoney(src.infiltration)}`) };
if (src.stock) { parts.push(`Stock Market: ${numeralWrapper.formatMoney(src.stock)}`) };
return parts.join("<br>");
}
function openMoneyModal() {
let txt: string = "<u>Money earned since you last installed Augmentations:</u><br>" +
convertMoneySourceTrackerToString(p.moneySourceA);
if (p.sourceFiles.length !== 0) {
txt += "<br><br><u>Money earned in this BitNode:</u><br>" +
convertMoneySourceTrackerToString(p.moneySourceB);
}
dialogBoxCreate(txt, false);
}
function Intelligence(): React.ReactElement {
if (p.intelligence > 0) {
return <tr key='5'>
<td>Intelligence:</td>
<td style={{textAlign: 'right'}}>{(p.intelligence).toLocaleString()}</td>
</tr>;
}
return <></>;
}
function MultiplierTable(props: any): React.ReactElement {
function bn5Stat(r: any) {
if(SourceFileFlags[5] > 0 && r.length > 2 && r[1] != r[2]) {
return <td key='2' style={{textAlign: 'right'}}> ({numeralWrapper.formatPercentage(r[2])})</td>
}
return undefined;
}
return <>
<table>
<tbody>
{props.rows.map((r: any) => <tr key={r[0]}>
<td key='0'>{r[0]} multiplier: </td>
<td key='1' style={{textAlign: 'right'}}>{numeralWrapper.formatPercentage(r[1])}</td>
{bn5Stat(r)}
</tr>)}
</tbody>
</table>
</>
}
function BitNodeTimeText(): React.ReactElement {
if(p.sourceFiles.length > 0) {
return <>
<span>Time played since last Bitnode destroyed: {convertTimeMsToTimeElapsedString(p.playtimeSinceLastBitnode)}</span>
<br />
</>
}
return <></>
}
function CurrentBitNode(): React.ReactElement {
if(p.sourceFiles.length > 0) {
const index = "BitNode" + p.bitNodeN;
return <>
<span>Current BitNode: {p.bitNodeN} ({BitNodes[index].name})</span><br /><br />
<div style={{width:"60%", fontSize: "13px", marginLeft:"4%"}}>
{BitNodes[index].info.split("<br>").map((t, i) => <div key={i}>
<span style={{whiteSpace: 'pre-wrap', overflowWrap: 'break-word'}}>{t}</span><br />
</div>)}
</div>
</>
}
return <></>
}
return (
<pre>
<b>General</b>
<br /><br />
<span>Current City: {p.city}</span><br />
<LastEmployer />
<LastJob />
<Employers />
<span>Money: {numeralWrapper.formatMoney(p.money.toNumber())}</span>
<button className="popup-box-button" style={{display: 'inline-block', float: 'none'}} onClick={openMoneyModal}>Money Statistics & Breakdown</button><br /><br />
<b>Stats</b>
<table>
<tbody>
<tr key='0'>
<td key='0'>Hacking:</td>
<td key='1' style={{textAlign: 'right'}}>{p.hacking_skill.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.hacking_exp, '0.000a')} exp)</td>
</tr>
<tr key='1'>
<td key='0'>Strength:</td>
<td key='1' style={{textAlign: 'right'}}>{p.strength.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.strength_exp, '0.000a')} exp)</td>
</tr>
<tr key='2'>
<td key='0'>Defense:</td>
<td key='1' style={{textAlign: 'right'}}>{p.defense.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.defense_exp, '0.000a')} exp)</td>
</tr>
<tr key='3'>
<td key='0'>Dexterity:</td>
<td key='1' style={{textAlign: 'right'}}>{p.dexterity.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.dexterity_exp, '0.000a')} exp)</td>
</tr>
<tr key='4'>
<td key='0'>Agility:</td>
<td key='1' style={{textAlign: 'right'}}>{p.agility.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.agility_exp, '0.000a')} exp)</td>
</tr>
<tr key='5'>
<td key='0'>Charisma:</td>
<td key='1' style={{textAlign: 'right'}}>{p.charisma.toLocaleString()}</td>
<td key='2' style={{textAlign: 'right'}}>({numeralWrapper.format(p.charisma_exp, '0.000a')} exp)</td>
</tr>
<Intelligence />
</tbody>
</table>
<br />
<MultiplierTable rows={[
['Hacking Chance', p.hacking_chance_mult],
['Hacking Speed', p.hacking_speed_mult],
['Hacking Money', p.hacking_money_mult, p.hacking_speed_mult*BitNodeMultipliers.ScriptHackMoney],
['Hacking Growth', p.hacking_grow_mult, p.hacking_money_mult*BitNodeMultipliers.ServerGrowthRate]
]} /><br />
<MultiplierTable rows={[
['Hacking Level', p.hacking_mult, p.hacking_mult*BitNodeMultipliers.HackingLevelMultiplier],
['Hacking Experience', p.hacking_exp_mult, p.hacking_exp_mult*BitNodeMultipliers.HackExpGain],
]} /><br />
<MultiplierTable rows={[
['Strength Level', p.strength_mult, p.strength_mult*BitNodeMultipliers.StrengthLevelMultiplier],
['Strength Experience', p.strength_exp_mult]
]} /><br />
<MultiplierTable rows={[
['Defense Level', p.defense_mult, p.defense_mult*BitNodeMultipliers.DefenseLevelMultiplier],
['Defense Experience', p.defense_exp_mult]
]} /><br />
<MultiplierTable rows={[
['Dexterity Level', p.dexterity_mult, p.dexterity_mult*BitNodeMultipliers.DexterityLevelMultiplier],
['Dexterity Experience', p.dexterity_exp_mult]
]} /><br />
<MultiplierTable rows={[
['Agility Level', p.agility_mult, p.agility_mult*BitNodeMultipliers.AgilityLevelMultiplier],
['Agility Experience', p.agility_exp_mult]
]} /><br />
<MultiplierTable rows={[
['Charisma Level', p.charisma_mult, p.charisma_mult*BitNodeMultipliers.CharismaLevelMultiplier],
['Charisma Experience', p.charisma_exp_mult]
]} /><br />
<MultiplierTable rows={[
['Hacknet Node production', p.hacknet_node_money_mult, p.hacknet_node_money_mult*BitNodeMultipliers.HacknetNodeMoney],
['Hacknet Node purchase cost', p.hacknet_node_purchase_cost_mult],
['Hacknet Node RAM upgrade cost', p.hacknet_node_ram_cost_mult],
['Hacknet Node Core purchase cost', p.hacknet_node_core_cost_mult],
['Hacknet Node level upgrade cost', p.hacknet_node_level_cost_mult]
]} /><br />
<MultiplierTable rows={[
['Company reputation gain', p.company_rep_mult],
['Faction reputation gain', p.faction_rep_mult, p.faction_rep_mult*BitNodeMultipliers.FactionWorkRepGain],
['Salary', p.work_money_mult, p.work_money_mult*BitNodeMultipliers.CompanyWorkMoney]
]} /><br />
<MultiplierTable rows={[
['Crime success', p.crime_success_mult],
['Crime money', p.crime_money_mult, p.crime_money_mult*BitNodeMultipliers.CrimeMoney]
]} /><br /><br />
<b>Misc.</b><br /><br />
<span>Servers owned: {p.purchasedServers.length} / {getPurchaseServerLimit()}</span><br />
<span>Hacknet Nodes owned: {p.hacknetNodes.length} / {MaxNumberHacknetServers}</span><br />
<span>Augmentations installed: {p.augmentations.length}</span><br />
<span>Time played since last Augmentation: {convertTimeMsToTimeElapsedString(p.playtimeSinceLastAug)}</span><br />
<BitNodeTimeText />
<span>Time played: {convertTimeMsToTimeElapsedString(p.totalPlaytime)}</span><br />
<br />
<CurrentBitNode />
</pre>
)
}

@ -1,157 +0,0 @@
// Displays character info on a given element. This is used to create & update
// the 'Stats' page from the main menu
import { BitNodes } from "../BitNode/BitNode";
import { IPlayer } from "../PersonObjects/IPlayer";
import { numeralWrapper } from "../ui/numeralFormat";
import { MoneySourceTracker } from "../utils/MoneySourceTracker";
import { dialogBoxCreate } from "../../utils/DialogBox";
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
import { createElement } from "../../utils/uiHelpers/createElement";
import { removeChildrenFromElement } from "../../utils/uiHelpers/removeChildrenFromElement";
export function displayCharacterInfo(elem: HTMLElement, p: IPlayer) {
removeChildrenFromElement(elem);
let companyPosition = "";
if (p.companyName !== "") {
companyPosition = p.jobs[p.companyName];
}
var intText = "";
if (p.intelligence > 0) {
intText = 'Intelligence: ' + (p.intelligence).toLocaleString() + '<br>';
}
let bitNodeTimeText = "";
if(p.sourceFiles.length > 0) {
bitNodeTimeText = 'Time played since last Bitnode destroyed: ' + convertTimeMsToTimeElapsedString(p.playtimeSinceLastBitnode) + '<br>';
}
const unlockedBitnodes: boolean = p.sourceFiles.length !== 0;
// General info
elem.appendChild(createElement("pre", {
display: "block",
innerHTML:
'<b>General</b><br><br>' +
'Current City: ' + p.city + '<br><br>' +
`Employer at which you last worked: ${p.companyName}<br>` +
`Job you last worked: ${companyPosition}<br>` +
`All Employers: ${Object.keys(p.jobs).join(", ")}<br><br>`
}));
// Money, and a button to show money breakdown
elem.appendChild(createElement("pre", {
display: "inline-block",
innerHTML: 'Money: ' + numeralWrapper.formatMoney(p.money.toNumber()) + '<br><br><br>',
margin: "6px",
}));
function convertMoneySourceTrackerToString(src: MoneySourceTracker): string {
let parts: string[] = [`Total: ${numeralWrapper.formatMoney(src.total)}`];
if (src.bladeburner) { parts.push(`Bladeburner: ${numeralWrapper.formatMoney(src.bladeburner)}`) };
if (src.codingcontract) { parts.push(`Coding Contracts: ${numeralWrapper.formatMoney(src.codingcontract)}`) };
if (src.work) { parts.push(`Company Work: ${numeralWrapper.formatMoney(src.work)}`) };
if (src.corporation) { parts.push(`Corporation: ${numeralWrapper.formatMoney(src.corporation)}`) };
if (src.crime) { parts.push(`Crimes: ${numeralWrapper.formatMoney(src.crime)}`) };
if (src.gang) { parts.push(`Gang: ${numeralWrapper.formatMoney(src.gang)}`) };
if (src.hacking) { parts.push(`Hacking: ${numeralWrapper.formatMoney(src.hacking)}`) };
if (src.hacknetnode) { parts.push(`Hacknet Nodes: ${numeralWrapper.formatMoney(src.hacknetnode)}`) };
if (src.hospitalization) { parts.push(`Hospitalization: ${numeralWrapper.formatMoney(src.hospitalization)}`) };
if (src.infiltration) { parts.push(`Infiltration: ${numeralWrapper.formatMoney(src.infiltration)}`) };
if (src.stock) { parts.push(`Stock Market: ${numeralWrapper.formatMoney(src.stock)}`) };
return parts.join("<br>");
}
elem.appendChild(createElement("button", {
class: "popup-box-button",
display: "inline-block",
float: "none",
innerText: "Money Statistics & Breakdown",
clickListener: () => {
let txt: string = "<u>Money earned since you last installed Augmentations:</u><br>" +
convertMoneySourceTrackerToString(p.moneySourceA);
if (unlockedBitnodes) {
txt += "<br><br><u>Money earned in this BitNode:</u><br>" +
convertMoneySourceTrackerToString(p.moneySourceB);
}
dialogBoxCreate(txt, false);
}
}));
// Stats and multiplier
elem.appendChild(createElement("pre", {
display: "block",
innerHTML:
'<b>Stats</b><br><br>' +
'Hacking Level: ' + (p.hacking_skill).toLocaleString() +
' (' + numeralWrapper.format(p.hacking_exp, '(0.000a)') + ' experience)<br>' +
'Strength: ' + (p.strength).toLocaleString() +
' (' + numeralWrapper.format(p.strength_exp, '(0.000a)') + ' experience)<br>' +
'Defense: ' + (p.defense).toLocaleString() +
' (' + numeralWrapper.format(p.defense_exp, '(0.000a)') + ' experience)<br>' +
'Dexterity: ' + (p.dexterity).toLocaleString() +
' (' + numeralWrapper.format(p.dexterity_exp, '(0.000a)') + ' experience)<br>' +
'Agility: ' + (p.agility).toLocaleString() +
' (' + numeralWrapper.format(p.agility_exp, '(0.000a)') + ' experience)<br>' +
'Charisma: ' + (p.charisma).toLocaleString() +
' (' + numeralWrapper.format(p.charisma_exp, '(0.000a)') + ' experience)<br>' +
intText + '<br><br>' +
'<b>Multipliers</b><br><br>' +
'Hacking Chance multiplier: ' + numeralWrapper.formatPercentage(p.hacking_chance_mult) + '<br>' +
'Hacking Speed multiplier: ' + numeralWrapper.formatPercentage(p.hacking_speed_mult) + '<br>' +
'Hacking Money multiplier: ' + numeralWrapper.formatPercentage(p.hacking_money_mult) + '<br>' +
'Hacking Growth multiplier: ' + numeralWrapper.formatPercentage(p.hacking_grow_mult) + '<br><br>' +
'Hacking Level multiplier: ' + numeralWrapper.formatPercentage(p.hacking_mult) + '<br>' +
'Hacking Experience multiplier: ' + numeralWrapper.formatPercentage(p.hacking_exp_mult) + '<br><br>' +
'Strength Level multiplier: ' + numeralWrapper.formatPercentage(p.strength_mult) + '<br>' +
'Strength Experience multiplier: ' + numeralWrapper.formatPercentage(p.strength_exp_mult) + '<br><br>' +
'Defense Level multiplier: ' + numeralWrapper.formatPercentage(p.defense_mult) + '<br>' +
'Defense Experience multiplier: ' + numeralWrapper.formatPercentage(p.defense_exp_mult) + '<br><br>' +
'Dexterity Level multiplier: ' + numeralWrapper.formatPercentage(p.dexterity_mult) + '<br>' +
'Dexterity Experience multiplier: ' + numeralWrapper.formatPercentage(p.dexterity_exp_mult) + '<br><br>' +
'Agility Level multiplier: ' + numeralWrapper.formatPercentage(p.agility_mult) + '<br>' +
'Agility Experience multiplier: ' + numeralWrapper.formatPercentage(p.agility_exp_mult) + '<br><br>' +
'Charisma Level multiplier: ' + numeralWrapper.formatPercentage(p.charisma_mult) + '<br>' +
'Charisma Experience multiplier: ' + numeralWrapper.formatPercentage(p.charisma_exp_mult) + '<br><br>' +
'Hacknet Node production multiplier: ' + numeralWrapper.formatPercentage(p.hacknet_node_money_mult) + '<br>' +
'Hacknet Node purchase cost multiplier: ' + numeralWrapper.formatPercentage(p.hacknet_node_purchase_cost_mult) + '<br>' +
'Hacknet Node RAM upgrade cost multiplier: ' + numeralWrapper.formatPercentage(p.hacknet_node_ram_cost_mult) + '<br>' +
'Hacknet Node Core purchase cost multiplier: ' + numeralWrapper.formatPercentage(p.hacknet_node_core_cost_mult) + '<br>' +
'Hacknet Node level upgrade cost multiplier: ' + numeralWrapper.formatPercentage(p.hacknet_node_level_cost_mult) + '<br><br>' +
'Company reputation gain multiplier: ' + numeralWrapper.formatPercentage(p.company_rep_mult) + '<br>' +
'Faction reputation gain multiplier: ' + numeralWrapper.formatPercentage(p.faction_rep_mult) + '<br>' +
'Salary multiplier: ' + numeralWrapper.formatPercentage(p.work_money_mult) + '<br>' +
'Crime success multiplier: ' + numeralWrapper.formatPercentage(p.crime_success_mult) + '<br>' +
'Crime money multiplier: ' + numeralWrapper.formatPercentage(p.crime_money_mult) + '<br><br><br>' +
'<b>Misc</b><br><br>' +
'Servers owned: ' + p.purchasedServers.length + '<br>' +
'Hacknet Nodes owned: ' + p.hacknetNodes.length + '<br>' +
'Augmentations installed: ' + p.augmentations.length + '<br>' +
'Time played since last Augmentation: ' + convertTimeMsToTimeElapsedString(p.playtimeSinceLastAug) + '<br>' +
bitNodeTimeText +
'Time played: ' + convertTimeMsToTimeElapsedString(p.totalPlaytime),
}));
// BitNode information, if player has gotten that far
if (unlockedBitnodes) {
var index = "BitNode" + p.bitNodeN;
elem.appendChild(createElement("p", {
width:"60%",
innerHTML:
"<br>Current BitNode: " + p.bitNodeN + " (" + BitNodes[index].name + ")<br><br>",
}));
elem.appendChild(createElement("p", {
width:"60%", fontSize: "13px", marginLeft:"4%",
innerHTML:BitNodes[index].info,
}))
}
}