mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +02:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import React from "react";
|
|
import Button from "@mui/material/Button";
|
|
import Tooltip from "@mui/material/Tooltip";
|
|
import Typography from "@mui/material/Typography";
|
|
|
|
import { Player } from "@player";
|
|
|
|
import { Money } from "../../ui/React/Money";
|
|
import { MathJax } from "better-react-mathjax";
|
|
|
|
interface IProps {
|
|
rerender: () => void;
|
|
}
|
|
|
|
export function CoresButton(props: IProps): React.ReactElement {
|
|
const homeComputer = Player.getHomeComputer();
|
|
const maxCores = homeComputer.cpuCores >= 8;
|
|
if (maxCores) {
|
|
return <Button>Upgrade 'home' cores - MAX</Button>;
|
|
}
|
|
|
|
const cost = Player.getUpgradeHomeCoresCost();
|
|
|
|
function buy(): void {
|
|
if (maxCores) return;
|
|
if (!Player.canAfford(cost)) return;
|
|
Player.loseMoney(cost, "servers");
|
|
homeComputer.cpuCores++;
|
|
props.rerender();
|
|
}
|
|
|
|
return (
|
|
<Tooltip title={<MathJax>{`\\(\\large{cost = 10^9 \\cdot 7.5 ^{\\text{cores}}}\\)`}</MathJax>}>
|
|
<span>
|
|
<br />
|
|
<Typography>
|
|
<i>"Cores increase the effectiveness of grow() and weaken() on 'home'"</i>
|
|
</Typography>
|
|
<br />
|
|
<Button disabled={!Player.canAfford(cost)} onClick={buy}>
|
|
Upgrade 'home' cores ({homeComputer.cpuCores} -> {homeComputer.cpuCores + 1}) -
|
|
<Money money={cost} forPurchase={true} />
|
|
</Button>
|
|
</span>
|
|
</Tooltip>
|
|
);
|
|
}
|