bitburner-src/src/Locations/ui/TorButton.tsx
2021-09-30 20:06:40 -04:00

33 lines
784 B
TypeScript

import React from "react";
import Button from "@mui/material/Button";
import { purchaseTorRouter } from "../LocationsHelpers";
import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { Money } from "../../ui/React/Money";
type IProps = {
p: IPlayer;
rerender: () => void;
};
export function TorButton(props: IProps): React.ReactElement {
function buy(): void {
purchaseTorRouter(props.p);
props.rerender();
}
if (props.p.hasTorRouter()) {
return <Button>TOR Router - Purchased</Button>;
}
return (
<Button disabled={!props.p.canAfford(CONSTANTS.TorRouterCost)} onClick={buy}>
Purchase TOR router -&nbsp;
<Money money={CONSTANTS.TorRouterCost} player={props.p} />
</Button>
);
}