mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 10:42:51 +02:00
made tech vendors button a tad smarter.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { Location } from "../Location";
|
||||
import { createPurchaseServerPopup,
|
||||
createUpgradeHomeCoresPopup,
|
||||
purchaseTorRouter } from "../LocationsHelpers";
|
||||
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
|
||||
|
||||
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
|
||||
import { StdButton } from "../../ui/React/StdButton";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
}
|
||||
|
||||
export function RamButton(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender(old => !old);
|
||||
}
|
||||
|
||||
const btnStyle = { display: "block" };
|
||||
|
||||
const homeComputer = props.p.getHomeComputer();
|
||||
if(homeComputer.maxRam >= CONSTANTS.HomeComputerMaxRam) {
|
||||
return (<StdButtonPurchased
|
||||
style={btnStyle}
|
||||
text={"Upgrade 'home' RAM - MAX"}
|
||||
/>);
|
||||
}
|
||||
|
||||
const cost = props.p.getUpgradeHomeRamCost();
|
||||
|
||||
function buy(): void {
|
||||
purchaseRamForHomeComputer(props.p);
|
||||
rerender();
|
||||
}
|
||||
|
||||
return (<StdButton
|
||||
disabled={!props.p.canAfford(cost)}
|
||||
onClick={buy}
|
||||
style={btnStyle}
|
||||
text={<>Upgrade 'home' RAM ({homeComputer.maxRam}GB -> {homeComputer.maxRam*2}GB) - {Money(cost)}</>}
|
||||
/>);
|
||||
}
|
||||
Reference in New Issue
Block a user