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

42 lines
1007 B
TypeScript
Raw Normal View History

2021-09-09 09:17:01 +02:00
import React from "react";
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 { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
import { StdButton } from "../../ui/React/StdButton";
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
const btnStyle = { display: "block" };
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-09 05:47:34 +02:00
return <StdButtonPurchased style={btnStyle} text={"TOR Router - Purchased"} />;
2021-09-05 01:09:30 +02:00
}
return (
<StdButton
disabled={!props.p.canAfford(CONSTANTS.TorRouterCost)}
onClick={buy}
style={btnStyle}
text={
<>
2021-09-09 05:47:34 +02:00
Purchase TOR router - <Money money={CONSTANTS.TorRouterCost} player={props.p} />
2021-09-05 01:09:30 +02:00
</>
}
/>
);
}