mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-24 02:03:01 +02:00
convert all hacknet to ts
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* React Component for the button that is used to purchase new Hacknet Nodes
|
||||
*/
|
||||
import React from "react";
|
||||
|
||||
import { hasHacknetServers, hasMaxNumberHacknetServers } from "../HacknetHelpers";
|
||||
import { Player } from "../../Player";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
|
||||
interface IProps {
|
||||
multiplier: number | string;
|
||||
onClick: () => void;
|
||||
cost: number;
|
||||
}
|
||||
|
||||
export function PurchaseButton(props: IProps): React.ReactElement {
|
||||
const cost = props.cost;
|
||||
let className = Player.canAfford(cost) ? "std-button" : "std-button-disabled";
|
||||
let text;
|
||||
let style = {};
|
||||
if (hasHacknetServers(Player)) {
|
||||
if (hasMaxNumberHacknetServers(Player)) {
|
||||
className = "std-button-disabled";
|
||||
text = <>Hacknet Server limit reached</>;
|
||||
style = { color: "red" };
|
||||
} else {
|
||||
text = (
|
||||
<>
|
||||
Purchase Hacknet Server - <Money money={cost} player={Player} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
text = (
|
||||
<>
|
||||
Purchase Hacknet Node - <Money money={cost} player={Player} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<button className={className} onClick={props.onClick} style={style}>
|
||||
{text}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user