bitburner-src/src/Locations/ui/TorButton.tsx

33 lines
784 B
TypeScript
Raw Normal View History

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";
2021-09-06 21:06:08 +02:00
import { purchaseTorRouter } from "../LocationsHelpers";
2021-09-05 01:09:30 +02:00
import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer";
2021-09-05 01:09:30 +02:00
import { Money } from "../../ui/React/Money";
type IProps = {
2021-09-05 01:09:30 +02:00
p: IPlayer;
2021-09-07 23:26:49 +02:00
rerender: () => void;
2021-09-05 01:09:30 +02:00
};
export function TorButton(props: IProps): React.ReactElement {
2021-09-05 01:09:30 +02:00
function buy(): void {
purchaseTorRouter(props.p);
2021-09-07 23:26:49 +02:00
props.rerender();
2021-09-05 01:09:30 +02:00
}
if (props.p.hasTorRouter()) {
2021-09-25 21:34:12 +02:00
return <Button>TOR Router - Purchased</Button>;
2021-09-05 01:09:30 +02:00
}
return (
2021-09-25 21:34:12 +02:00
<Button disabled={!props.p.canAfford(CONSTANTS.TorRouterCost)} onClick={buy}>
2021-10-01 02:06:40 +02:00
Purchase TOR router -&nbsp;
<Money money={CONSTANTS.TorRouterCost} player={props.p} />
2021-09-25 21:34:12 +02:00
</Button>
2021-09-05 01:09:30 +02:00
);
}