mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 23:38:35 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
@@ -19,59 +19,96 @@ import { arrayToString } from "../../../utils/helpers/arrayToString";
|
||||
import { Money } from "../React/Money";
|
||||
|
||||
type IProps = {
|
||||
workerScript: WorkerScript;
|
||||
}
|
||||
workerScript: WorkerScript;
|
||||
};
|
||||
|
||||
export function WorkerScriptAccordion(props: IProps): React.ReactElement {
|
||||
const workerScript = props.workerScript;
|
||||
const scriptRef = workerScript.scriptRef;
|
||||
const workerScript = props.workerScript;
|
||||
const scriptRef = workerScript.scriptRef;
|
||||
|
||||
const logClickHandler = logBoxCreate.bind(null, scriptRef);
|
||||
const killScript = killWorkerScript.bind(null, scriptRef as any, scriptRef.server);
|
||||
const logClickHandler = logBoxCreate.bind(null, scriptRef);
|
||||
const killScript = killWorkerScript.bind(
|
||||
null,
|
||||
scriptRef as any,
|
||||
scriptRef.server,
|
||||
);
|
||||
|
||||
function killScriptClickHandler(): void {
|
||||
killScript();
|
||||
dialogBoxCreate("Killing script");
|
||||
}
|
||||
function killScriptClickHandler(): void {
|
||||
killScript();
|
||||
dialogBoxCreate("Killing script");
|
||||
}
|
||||
|
||||
// Calculations for script stats
|
||||
const onlineMps = scriptRef.onlineMoneyMade / scriptRef.onlineRunningTime;
|
||||
const onlineEps = scriptRef.onlineExpGained / scriptRef.onlineRunningTime;
|
||||
const offlineMps = scriptRef.offlineMoneyMade / scriptRef.offlineRunningTime;
|
||||
const offlineEps = scriptRef.offlineExpGained / scriptRef.offlineRunningTime;
|
||||
// Calculations for script stats
|
||||
const onlineMps = scriptRef.onlineMoneyMade / scriptRef.onlineRunningTime;
|
||||
const onlineEps = scriptRef.onlineExpGained / scriptRef.onlineRunningTime;
|
||||
const offlineMps = scriptRef.offlineMoneyMade / scriptRef.offlineRunningTime;
|
||||
const offlineEps = scriptRef.offlineExpGained / scriptRef.offlineRunningTime;
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
headerClass="active-scripts-script-header"
|
||||
headerContent={
|
||||
<>{props.workerScript.name}</>
|
||||
}
|
||||
panelClass="active-scripts-script-panel"
|
||||
panelContent={
|
||||
<>
|
||||
<pre>Threads: {numeralWrapper.formatThreads(props.workerScript.scriptRef.threads)}</pre>
|
||||
<pre>Args: {arrayToString(props.workerScript.args)}</pre>
|
||||
<pre>Online Time: {convertTimeMsToTimeElapsedString(scriptRef.onlineRunningTime * 1e3)}</pre>
|
||||
<pre>Offline Time: {convertTimeMsToTimeElapsedString(scriptRef.offlineRunningTime * 1e3)}</pre>
|
||||
<pre>Total online production: <Money money={scriptRef.onlineMoneyMade} /></pre>
|
||||
<pre>{(Array(26).join(" ") + numeralWrapper.formatExp(scriptRef.onlineExpGained) + " hacking exp")}</pre>
|
||||
<pre>Online production rate: <Money money={onlineMps} /> / second</pre>
|
||||
<pre>{(Array(25).join(" ") + numeralWrapper.formatExp(onlineEps) + " hacking exp / second")}</pre>
|
||||
<pre>Total offline production: <Money money={scriptRef.offlineMoneyMade} /></pre>
|
||||
<pre>{(Array(27).join(" ") + numeralWrapper.formatExp(scriptRef.offlineExpGained) + " hacking exp")}</pre>
|
||||
<pre>Offline production rate: <Money money={offlineMps} /> / second</pre>
|
||||
<pre>{(Array(26).join(" ") + numeralWrapper.formatExp(offlineEps) + " hacking exp / second")}</pre>
|
||||
return (
|
||||
<Accordion
|
||||
headerClass="active-scripts-script-header"
|
||||
headerContent={<>{props.workerScript.name}</>}
|
||||
panelClass="active-scripts-script-panel"
|
||||
panelContent={
|
||||
<>
|
||||
<pre>
|
||||
Threads:{" "}
|
||||
{numeralWrapper.formatThreads(props.workerScript.scriptRef.threads)}
|
||||
</pre>
|
||||
<pre>Args: {arrayToString(props.workerScript.args)}</pre>
|
||||
<pre>
|
||||
Online Time:{" "}
|
||||
{convertTimeMsToTimeElapsedString(
|
||||
scriptRef.onlineRunningTime * 1e3,
|
||||
)}
|
||||
</pre>
|
||||
<pre>
|
||||
Offline Time:{" "}
|
||||
{convertTimeMsToTimeElapsedString(
|
||||
scriptRef.offlineRunningTime * 1e3,
|
||||
)}
|
||||
</pre>
|
||||
<pre>
|
||||
Total online production: <Money money={scriptRef.onlineMoneyMade} />
|
||||
</pre>
|
||||
<pre>
|
||||
{Array(26).join(" ") +
|
||||
numeralWrapper.formatExp(scriptRef.onlineExpGained) +
|
||||
" hacking exp"}
|
||||
</pre>
|
||||
<pre>
|
||||
Online production rate: <Money money={onlineMps} /> / second
|
||||
</pre>
|
||||
<pre>
|
||||
{Array(25).join(" ") +
|
||||
numeralWrapper.formatExp(onlineEps) +
|
||||
" hacking exp / second"}
|
||||
</pre>
|
||||
<pre>
|
||||
Total offline production:{" "}
|
||||
<Money money={scriptRef.offlineMoneyMade} />
|
||||
</pre>
|
||||
<pre>
|
||||
{Array(27).join(" ") +
|
||||
numeralWrapper.formatExp(scriptRef.offlineExpGained) +
|
||||
" hacking exp"}
|
||||
</pre>
|
||||
<pre>
|
||||
Offline production rate: <Money money={offlineMps} /> / second
|
||||
</pre>
|
||||
<pre>
|
||||
{Array(26).join(" ") +
|
||||
numeralWrapper.formatExp(offlineEps) +
|
||||
" hacking exp / second"}
|
||||
</pre>
|
||||
|
||||
<AccordionButton
|
||||
onClick={logClickHandler}
|
||||
text="Log"
|
||||
/>
|
||||
<AccordionButton
|
||||
onClick={killScriptClickHandler}
|
||||
text="Kill Script"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
<AccordionButton onClick={logClickHandler} text="Log" />
|
||||
<AccordionButton
|
||||
onClick={killScriptClickHandler}
|
||||
text="Kill Script"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user