2019-05-17 08:44:59 +02:00
|
|
|
/**
|
|
|
|
* React Component for displaying the total production and production rate
|
|
|
|
* of scripts on the 'Active Scripts' UI page
|
|
|
|
*/
|
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
2021-03-31 06:45:21 +02:00
|
|
|
import { Money } from "../React/Money";
|
2019-05-17 08:44:59 +02:00
|
|
|
|
|
|
|
type IProps = {
|
2021-09-05 01:09:30 +02:00
|
|
|
p: IPlayer;
|
|
|
|
workerScripts: Map<number, WorkerScript>;
|
|
|
|
};
|
2019-05-17 08:44:59 +02:00
|
|
|
|
|
|
|
export function ScriptProduction(props: IProps): React.ReactElement {
|
2021-09-09 05:47:34 +02:00
|
|
|
const prodRateSinceLastAug = props.p.scriptProdSinceLastAug / (props.p.playtimeSinceLastAug / 1000);
|
2019-05-17 08:44:59 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
let onlineProduction = 0;
|
|
|
|
for (const ws of props.workerScripts.values()) {
|
2021-09-09 05:47:34 +02:00
|
|
|
onlineProduction += ws.scriptRef.onlineMoneyMade / ws.scriptRef.onlineRunningTime;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-06-19 10:51:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
|
|
|
<p id="active-scripts-total-prod">
|
|
|
|
Total online production of Active scripts:
|
|
|
|
<span className="money-gold">
|
|
|
|
<span id="active-scripts-total-production-active">
|
|
|
|
<Money money={onlineProduction} />
|
|
|
|
</span>{" "}
|
|
|
|
/ sec
|
|
|
|
</span>
|
|
|
|
<br />
|
|
|
|
Total online production since last Aug installation:
|
|
|
|
<span id="active-scripts-total-prod-aug-total" className="money-gold">
|
|
|
|
<Money money={props.p.scriptProdSinceLastAug} />
|
|
|
|
</span>
|
|
|
|
(
|
|
|
|
<span className="money-gold">
|
|
|
|
<span id="active-scripts-total-prod-aug-avg" className="money-gold">
|
|
|
|
<Money money={prodRateSinceLastAug} />
|
|
|
|
</span>{" "}
|
|
|
|
/ sec
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
</p>
|
|
|
|
);
|
2019-05-17 08:44:59 +02:00
|
|
|
}
|