Fix missing money display

This commit is contained in:
Olivier Gagnon 2021-09-04 14:03:19 -04:00
parent c9efa977fb
commit e1c29f25e2
14 changed files with 43 additions and 51 deletions

File diff suppressed because one or more lines are too long

@ -627,7 +627,7 @@ class DevMenuComponent extends Component {
this.processStocks((stock) => {
stocks.push(<tr key={stock.symbol}>
<td>{stock.symbol}</td>
<td style={{'textAlign':'right'}}>{Money(stock.cap)}</td>
<td style={{'textAlign':'right'}}><Money money={stock.cap} /></td>
</tr>);
});
dialogBoxCreate(<table><tbody><tr><th>Stock</th><th>Price cap</th></tr>
@ -727,11 +727,11 @@ class DevMenuComponent extends Component {
<h2>Generic</h2>
</div>
<div className="row">
<button className="std-button" onClick={this.addMoney(1e6)}>Add $1m</button>
<button className="std-button" onClick={this.addMoney(1e9)}>Add $1b</button>
<button className="std-button" onClick={this.addMoney(1e12)}>Add $1t</button>
<button className="std-button" onClick={this.addMoney(1e15)}>Add $1000t</button>
<button className="std-button" onClick={this.addMoney(Infinity)}>Add $Infinity</button>
<button className="std-button" onClick={this.addMoney(1e6)}>Add <Money money={1e6} /></button>
<button className="std-button" onClick={this.addMoney(1e9)}>Add <Money money={1e9} /></button>
<button className="std-button" onClick={this.addMoney(1e12)}>Add <Money money={1e12} /></button>
<button className="std-button" onClick={this.addMoney(1e15)}>Add <Money money={1000e12} /></button>
<button className="std-button" onClick={this.addMoney(Infinity)}>Add <Money money={Infinity} /></button>
<button className="std-button" onClick={this.upgradeRam}>Upgrade Home Computer's RAM</button>
</div>
<div className="row">

@ -124,7 +124,7 @@ export function purchaseAugmentationBoxCreate(aug, fac) {
<h2>{aug.name}</h2><br />
{content}<br /><br />
<br />Would you like to purchase the {aug.name} Augmentation for&nbsp;
{Money(aug.baseCost * factionInfo.augmentationPriceMult)}?
<Money money={aug.baseCost * factionInfo.augmentationPriceMult} />?
</>);
}

@ -40,7 +40,7 @@ export class HacknetNode extends React.Component {
}
const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, Player.hacknet_node_level_cost_mult);
upgradeLevelContent = <>Upgrade x{multiplier} - {Money(upgradeLevelCost)}</>;
upgradeLevelContent = <>Upgrade x{multiplier} - <Money money={upgradeLevelCost} player={Player} /></>;
if (Player.money.lt(upgradeLevelCost)) {
upgradeLevelClass = "std-button-disabled";
} else {
@ -71,7 +71,7 @@ export class HacknetNode extends React.Component {
}
const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, Player.hacknet_node_ram_cost_mult);
upgradeRamContent = <>Upgrade x{multiplier} - {Money(upgradeRamCost)}</>;
upgradeRamContent = <>Upgrade x{multiplier} - <Money money={upgradeRamCost} player={Player} /></>;
if (Player.money.lt(upgradeRamCost)) {
upgradeRamClass = "std-button-disabled";
} else {
@ -102,7 +102,7 @@ export class HacknetNode extends React.Component {
}
const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, Player.hacknet_node_core_cost_mult);
upgradeCoresContent = <>Upgrade x{multiplier} - {Money(upgradeCoreCost)}</>;
upgradeCoresContent = <>Upgrade x{multiplier} - <Money money={upgradeCoreCost} player={Player} /></>;
if (Player.money.lt(upgradeCoreCost)) {
upgradeCoresClass = "std-button-disabled";
} else {
@ -128,7 +128,7 @@ export class HacknetNode extends React.Component {
<div className={"row"}>
<p>Production:</p>
<span className={"text money-gold"}>
{Money(node.totalMoneyGenerated)} ({MoneyRate(node.moneyGainRatePerSecond)})
<Money money={node.totalMoneyGenerated} player={Player} /> ({MoneyRate(node.moneyGainRatePerSecond)})
</span>
</div>
<div className={"row"}>

@ -44,7 +44,7 @@ export class HacknetServer extends React.Component {
}
const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, Player.hacknet_node_level_cost_mult);
upgradeLevelContent = <>Upgrade x{multiplier} - {Money(upgradeLevelCost)}</>;
upgradeLevelContent = <>Upgrade x{multiplier} - <Money money={upgradeLevelCost} player={Player} /></>;
if (Player.money.lt(upgradeLevelCost)) {
upgradeLevelClass = "std-button-disabled";
} else {
@ -76,7 +76,7 @@ export class HacknetServer extends React.Component {
}
const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, Player.hacknet_node_ram_cost_mult);
upgradeRamContent = <>Upgrade x{multiplier} - {Money(upgradeRamCost)}</>;
upgradeRamContent = <>Upgrade x{multiplier} - <Money money={upgradeRamCost} player={Player} /></>;
if (Player.money.lt(upgradeRamCost)) {
upgradeRamClass = "std-button-disabled";
} else {
@ -108,7 +108,7 @@ export class HacknetServer extends React.Component {
}
const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, Player.hacknet_node_core_cost_mult);
upgradeCoresContent = <>Upgrade x{multiplier} - {Money(upgradeCoreCost)}</>;
upgradeCoresContent = <>Upgrade x{multiplier} - <Money money={upgradeCoreCost} player={Player} /></>;
if (Player.money.lt(upgradeCoreCost)) {
upgradeCoresClass = "std-button-disabled";
} else {
@ -140,7 +140,7 @@ export class HacknetServer extends React.Component {
}
const upgradeCacheCost = node.calculateCacheUpgradeCost(multiplier);
upgradeCacheContent = <>Upgrade x{multiplier} - {Money(upgradeCacheCost)}</>;
upgradeCacheContent = <>Upgrade x{multiplier} - <Money money={upgradeCacheCost} player={Player} /></>;
if (Player.money.lt(upgradeCacheCost)) {
upgradeCacheClass = "std-button-disabled";
} else {

@ -26,7 +26,7 @@ export function PlayerInfo(props) {
return (
<p id={"hacknet-nodes-money"}>
<span>Money: </span>
{Money(Player.money.toNumber())}<br />
<Money money={Player.money.toNumber()} /><br />
{
hasServers && <><span>Hashes: {Hashes(Player.hashManager.hashes)} / {Hashes(Player.hashManager.capacity)}</span><br /></>

@ -23,10 +23,10 @@ export function PurchaseButton(props) {
text = <>Hacknet Server limit reached</>;
style = {color: "red"};
} else {
text = <>Purchase Hacknet Server - {Money(cost)}</>;
text = <>Purchase Hacknet Server - <Money money={cost} player={Player} /></>;
}
} else {
text = <>Purchase Hacknet Node - {Money(cost)}</>;
text = <>Purchase Hacknet Node - <Money money={cost} player={Player} /></>;
}
return (

@ -12,6 +12,7 @@ import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
import { StdButton } from "../../ui/React/StdButton";
import { Money } from "../../ui/React/Money";
import { MathComponent } from 'mathjax-react';
type IProps = {
p: IPlayer;
@ -34,18 +35,7 @@ export function CoresButton(props: IProps): React.ReactElement {
/>);
}
const allCosts = [
0,
10e9,
250e9,
5e12,
100e12,
1e15,
20e15,
200e15,
];
const cost: number = allCosts[homeComputer.cpuCores];
const cost = 1e9*Math.pow(7.5, homeComputer.cpuCores);
function buy(): void {
if(maxCores) return;
@ -54,11 +44,12 @@ export function CoresButton(props: IProps): React.ReactElement {
homeComputer.cpuCores++;
rerender();
}
//tooltip={<MathComponent tex={String.raw`cost = `} />}
return (<StdButton
disabled={!props.p.canAfford(cost)}
onClick={buy}
style={btnStyle}
text={<>Upgrade 'home' cores ({homeComputer.cpuCores} -&gt; {homeComputer.cpuCores+1}) - <Money money={cost} player={props.p} /></>}
/>);
}

@ -38,6 +38,7 @@ export function TechVendorLocation(props: IProps): React.ReactElement {
onClick={() => createPurchaseServerPopup(i, props.p)}
style={btnStyle}
text={<>Purchase {i}GB Server - <Money money={cost} player={props.p} /></>}
disabled={!props.p.canAfford(cost)}
/>,
)
}

@ -47,7 +47,7 @@ export class TravelAgencyLocation extends React.Component<IProps, any> {
<div className="noselect">
<p>
From here, you can travel to any other city! A ticket
costs {Money(CONSTANTS.TravelCost)}.
costs <Money money={CONSTANTS.TravelCost} />.
</p>
<pre> ,_ . ._. _. .</pre>
<pre> , _-\','|~\~ ~/ ;-'_ _-' ,;_;_, ~~-</pre>
@ -98,7 +98,7 @@ export class TravelAgencyLocation extends React.Component<IProps, any> {
<div>
<p>
From here, you can travel to any other city! A ticket
costs {Money(CONSTANTS.TravelCost)}.
costs <Money money={CONSTANTS.TravelCost} />.
</p>
{travelBtns}
</div>

@ -600,7 +600,7 @@ export function work(numCycles) {
You are currently working as a {position} at {this.companyName} (Current Company Reputation: {Reputation(companyRep)})<br /><br />
You have been working for {convertTimeMsToTimeElapsedString(this.timeWorked)}<br /><br />
You have earned: <br /><br />
{Money(this.workMoneyGained)} ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
<Money money={this.workMoneyGained} /> ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
{Reputation(this.workRepGained)} ({ReputationRate(this.workRepGainRate * CYCLES_PER_SEC)}) reputation for this company <br /><br />
{numeralWrapper.formatExp(this.workHackExpGained)} ({`${numeralWrapper.formatExp(this.workHackExpGainRate * CYCLES_PER_SEC)} / sec`}) hacking exp <br /><br />
{numeralWrapper.formatExp(this.workStrExpGained)} ({`${numeralWrapper.formatExp(this.workStrExpGainRate * CYCLES_PER_SEC)} / sec`}) strength exp <br />
@ -626,7 +626,7 @@ export function finishWork(cancelled, sing=false) {
let content = <>
You earned a total of: <br />
{Money(this.workMoneyGained)}<br />
<Money money={this.workMoneyGained} /><br />
{Reputation(this.workRepGained)} reputation for the company <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
@ -728,7 +728,7 @@ export function workPartTime(numCycles) {
You are currently working as a {position} at {this.companyName} (Current Company Reputation: {Reputation(companyRep)})<br /><br />
You have been working for {convertTimeMsToTimeElapsedString(this.timeWorked)}<br /><br />
You have earned: <br /><br />
{Money(this.workMoneyGained)} ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
<Money money={this.workMoneyGained} /> ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
{Reputation(this.workRepGained)} ({Reputation(`${numeralWrapper.formatExp(this.workRepGainRate * CYCLES_PER_SEC)} / sec`)}) reputation for this company <br /><br />
{numeralWrapper.formatExp(this.workHackExpGained)} ({`${numeralWrapper.formatExp(this.workHackExpGainRate * CYCLES_PER_SEC)} / sec`}) hacking exp <br /><br />
{numeralWrapper.formatExp(this.workStrExpGained)} ({`${numeralWrapper.formatExp(this.workStrExpGainRate * CYCLES_PER_SEC)} / sec`}) strength exp <br />
@ -749,7 +749,7 @@ export function finishWorkPartTime(sing=false) {
const content = <>
You worked for {convertTimeMsToTimeElapsedString(this.timeWorked)}<br /><br />
You earned a total of: <br />
{Money(this.workMoneyGained)}<br />
<Money money={this.workMoneyGained} /><br />
{Reputation(this.workRepGained)} reputation for the company <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
@ -913,7 +913,7 @@ export function workForFaction(numCycles) {
(Current Faction Reputation: {Reputation(faction.playerReputation)}). <br />
You have been doing this for {convertTimeMsToTimeElapsedString(this.timeWorked)}<br /><br />
You have earned: <br /><br />
{Money(this.workMoneyGained)} ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
<Money money={this.workMoneyGained} /> ({MoneyRate(this.workMoneyGainRate * CYCLES_PER_SEC)}) <br /><br />
{Reputation(this.workRepGained)} ({ReputationRate(this.workRepGainRate * CYCLES_PER_SEC)}) reputation for this faction <br /><br />
{numeralWrapper.formatExp(this.workHackExpGained)} ({numeralWrapper.formatExp(this.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br /><br />
{numeralWrapper.formatExp(this.workStrExpGained)} ({numeralWrapper.formatExp(this.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br />
@ -936,7 +936,7 @@ export function finishFactionWork(cancelled, sing=false) {
dialogBoxCreate(<>
You worked for your faction {faction.name} for a total of {convertTimeMsToTimeElapsedString(this.timeWorked)} <br /><br />
You earned a total of: <br />
{Money(this.workMoneyGained)}<br />
<Money money={this.workMoneyGained} /><br />
{Reputation(this.workRepGained)} reputation for the faction <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
@ -1316,7 +1316,7 @@ export function takeClass(numCycles) {
ReactDOM.render(<>
You have been {className} for {convertTimeMsToTimeElapsedString(this.timeWorked)}<br /><br />
This has cost you: <br />
{Money(-this.workMoneyGained)} ({MoneyRate(this.workMoneyLossRate * CYCLES_PER_SEC)}) <br /><br />
<Money money={-this.workMoneyGained} /> ({MoneyRate(this.workMoneyLossRate * CYCLES_PER_SEC)}) <br /><br />
You have gained: <br />
{numeralWrapper.formatExp(this.workHackExpGained)} ({numeralWrapper.formatExp(this.workHackExpGainRate * CYCLES_PER_SEC)} / sec) hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} ({numeralWrapper.formatExp(this.workStrExpGainRate * CYCLES_PER_SEC)} / sec) strength exp <br />
@ -1341,7 +1341,7 @@ export function finishClass(sing=false) {
if (!sing) {
dialogBoxCreate(<>
After {this.className} for {convertTimeMsToTimeElapsedString(this.timeWorked)}, <br />
you spent a total of {Money(this.workMoneyGained * -1)}. <br /><br />
you spent a total of <Money money={-this.workMoneyGained} />. <br /><br />
You earned a total of: <br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking exp <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength exp <br />
@ -1475,7 +1475,7 @@ export function finishCrime(cancelled) {
dialogBoxCreate(<>
Crime successful!<br /><br />
You gained:<br />
{Money(this.workMoneyGained)}<br />
<Money money={this.workMoneyGained} /><br />
{numeralWrapper.formatExp(this.workHackExpGained)} hacking experience <br />
{numeralWrapper.formatExp(this.workStrExpGained)} strength experience<br />
{numeralWrapper.formatExp(this.workDefExpGained)} defense experience<br />
@ -1596,7 +1596,7 @@ export function hospitalize() {
dialogBoxCreate(<>
You were in critical condition! You were taken to the hospital where
luckily they were able to save your life. You were charged&nbsp;
{Money(cost)}
<Money money={cost} />
</>);
}

@ -555,7 +555,7 @@ let Terminal = {
server.fortify(CONSTANTS.ServerFortifyAmount);
postElement(<>Hack successful! Gained {Money(moneyGained)} and {numeralWrapper.formatExp(expGainedOnSuccess)} hacking exp</>);
postElement(<>Hack successful! Gained <Money money={moneyGained} /> and {numeralWrapper.formatExp(expGainedOnSuccess)} hacking exp</>);
} else { // Failure
// Player only gains 25% exp for failure? TODO Can change this later to balance
Player.gainHackingExp(expGainedOnFailure)
@ -600,7 +600,7 @@ let Terminal = {
post("Chance to hack: " + (!isHacknet ? numeralWrapper.formatPercentage(hackingChance) : "N/A"));
const hackingTime = calculateHackingTime(currServ, Player)*1000;
post("Time to hack: " + (!isHacknet ? convertTimeMsToTimeElapsedString(hackingTime, true) : "N/A"));
postElement(<>Total money available on server: {!isHacknet ? Money(currServ.moneyAvailable) : "N/A"}</>);
postElement(<>Total money available on server: {!isHacknet ? <Money money={currServ.moneyAvailable} /> : "N/A"}</>);
const numPort = currServ.numOpenPortsRequired;
post("Required number of open ports for NUKE: " + (!isHacknet ? numPort : "N/A"));
post("SSH port: "+ (currServ.sshPortOpen ? "Open" : "Closed"))
@ -2242,7 +2242,7 @@ let Terminal = {
Player.hacking_skill >= 2500;
if(!fulfilled) {
post(`Augmentations: ${Player.augmentations.length} / ${numAugReq}`);
postElement(<>Money: {Money(Player.money.toNumber())} / {Money(1e11)}</>);
postElement(<>Money: <Money money={Player.money.toNumber()} /> / <Money money={1e11} /></>);
post(`Hacking skill: ${Player.hacking_skill} / 2500`);
return;
}

@ -1059,7 +1059,7 @@ const Engine = {
var offlineProductionFromHacknetNodes = processHacknetEarnings(numCyclesOffline);
const hacknetProdInfo = hasHacknetServers() ?
<>{Hashes(offlineProductionFromHacknetNodes)} hashes</>:
Money(offlineProductionFromHacknetNodes);
<Money money={offlineProductionFromHacknetNodes} />;
// Passive faction rep gain offline
processPassiveFactionRepGain(numCyclesOffline);
@ -1113,7 +1113,7 @@ const Engine = {
const timeOfflineString = convertTimeMsToTimeElapsedString(time);
dialogBoxCreate(<>
Offline for {timeOfflineString}. While you were offline, your scripts
generated {Money(offlineHackingIncome)}, your Hacknet Nodes
generated <Money money={offlineHackingIncome} />, your Hacknet Nodes
generated {hacknetProdInfo} and you
gained {Reputation(offlineReputation)} divided amongst your factions.
</>);

@ -154,7 +154,7 @@ export function CharacterInfo(p: IPlayer): React.ReactElement {
<LastEmployer />
<LastJob />
<Employers />
<span>Money: {Money(p.money.toNumber())}</span>
<span>Money: <Money money={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>