2021-09-09 09:17:01 +02:00
|
|
|
import React from "react";
|
2021-09-25 21:34:12 +02:00
|
|
|
import Button from "@mui/material/Button";
|
|
|
|
import Tooltip from "@mui/material/Tooltip";
|
2021-12-20 20:03:25 +01:00
|
|
|
import Typography from "@mui/material/Typography";
|
2021-09-04 08:21:31 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { CONSTANTS } from "../../Constants";
|
2022-09-06 15:07:12 +02:00
|
|
|
import { Player } from "../../Player";
|
2021-09-05 01:09:30 +02:00
|
|
|
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
|
|
|
|
|
|
|
|
import { Money } from "../../ui/React/Money";
|
2021-10-12 00:14:10 +02:00
|
|
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
2022-01-08 13:48:10 +01:00
|
|
|
|
|
|
|
import { MathJaxWrapper } from "../../MathJaxWrapper";
|
2022-04-08 07:02:36 +02:00
|
|
|
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
2021-09-04 08:21:31 +02:00
|
|
|
|
|
|
|
type IProps = {
|
2021-09-07 23:26:49 +02:00
|
|
|
rerender: () => void;
|
2021-09-05 01:09:30 +02:00
|
|
|
};
|
2021-09-04 08:21:31 +02:00
|
|
|
|
|
|
|
export function RamButton(props: IProps): React.ReactElement {
|
2022-09-06 15:07:12 +02:00
|
|
|
const homeComputer = Player.getHomeComputer();
|
2021-09-05 01:09:30 +02:00
|
|
|
if (homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) {
|
2021-09-25 21:34:12 +02:00
|
|
|
return <Button>Upgrade 'home' RAM - MAX</Button>;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 15:07:12 +02:00
|
|
|
const cost = Player.getUpgradeHomeRamCost();
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
function buy(): void {
|
2022-09-06 15:07:12 +02:00
|
|
|
purchaseRamForHomeComputer();
|
2021-09-07 23:26:49 +02:00
|
|
|
props.rerender();
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
|
2022-04-08 07:02:36 +02:00
|
|
|
const bnMult = BitNodeMultipliers.HomeComputerRamCost === 1 ? "" : `\\cdot ${BitNodeMultipliers.HomeComputerRamCost}`;
|
2022-05-19 08:09:00 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return (
|
2021-10-13 08:15:29 +02:00
|
|
|
<Tooltip
|
2022-04-08 07:02:36 +02:00
|
|
|
title={
|
|
|
|
<MathJaxWrapper>{`\\(\\large{cost = ram \\cdot 3.2 \\cdot 10^4 \\cdot 1.58^{log_2{(ram)}}} ${bnMult}\\)`}</MathJaxWrapper>
|
|
|
|
}
|
2021-10-13 08:15:29 +02:00
|
|
|
>
|
2021-10-01 02:06:40 +02:00
|
|
|
<span>
|
2021-12-20 20:03:25 +01:00
|
|
|
<br />
|
|
|
|
<Typography>
|
|
|
|
<i>"More RAM means more scripts on 'home'"</i>
|
|
|
|
</Typography>
|
|
|
|
<br />
|
2022-09-06 15:07:12 +02:00
|
|
|
<Button disabled={!Player.canAfford(cost)} onClick={buy}>
|
2021-10-12 00:14:10 +02:00
|
|
|
Upgrade 'home' RAM ({numeralWrapper.formatRAM(homeComputer.maxRam)} ->
|
|
|
|
{numeralWrapper.formatRAM(homeComputer.maxRam * 2)}) -
|
2022-09-06 15:07:12 +02:00
|
|
|
<Money money={cost} forPurchase={true} />
|
2021-10-01 02:06:40 +02:00
|
|
|
</Button>
|
|
|
|
</span>
|
2021-09-25 21:34:12 +02:00
|
|
|
</Tooltip>
|
2021-09-05 01:09:30 +02:00
|
|
|
);
|
2021-09-04 08:21:31 +02:00
|
|
|
}
|