mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
Update HospitalLocation.tsx
This commit is contained in:
parent
6c84d64e67
commit
1b61ec0e12
@ -12,29 +12,18 @@ import { getHospitalizationCost } from "../../Hospital/Hospital";
|
|||||||
import { Money } from "../../ui/React/Money";
|
import { Money } from "../../ui/React/Money";
|
||||||
|
|
||||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
type IState = {
|
export function HospitalLocation(): React.ReactElement {
|
||||||
currHp: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
//Todo: Make this a functional component
|
|
||||||
export class HospitalLocation extends React.Component<Record<string, never>, IState> {
|
|
||||||
/** Stores button styling that sets them all to block display */
|
/** Stores button styling that sets them all to block display */
|
||||||
btnStyle = { display: "block" };
|
const btnStyle = { display: "block" };
|
||||||
|
|
||||||
constructor() {
|
const setRerender = useState(false)[1];
|
||||||
super({});
|
function rerender(): void {
|
||||||
|
setRerender((old) => !old);
|
||||||
this.state = {
|
|
||||||
currHp: Player.hp.current,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCost(): number {
|
function getHealed(e: React.MouseEvent<HTMLElement>): void {
|
||||||
return getHospitalizationCost();
|
|
||||||
}
|
|
||||||
|
|
||||||
getHealed(e: React.MouseEvent<HTMLElement>): void {
|
|
||||||
if (!e.isTrusted) {
|
if (!e.isTrusted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -46,14 +35,12 @@ export class HospitalLocation extends React.Component<Record<string, never>, ISt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cost = this.getCost();
|
const cost = getHospitalizationCost();
|
||||||
Player.loseMoney(cost, "hospitalization");
|
Player.loseMoney(cost, "hospitalization");
|
||||||
Player.hp.current = Player.hp.max;
|
Player.hp.current = Player.hp.max;
|
||||||
|
|
||||||
// This just forces a re-render to update the cost
|
// This just forces a re-render to update the cost
|
||||||
this.setState({
|
rerender();
|
||||||
currHp: Player.hp.current,
|
|
||||||
});
|
|
||||||
|
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
<>
|
<>
|
||||||
@ -62,13 +49,9 @@ export class HospitalLocation extends React.Component<Record<string, never>, ISt
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): React.ReactNode {
|
return (
|
||||||
const cost = this.getCost();
|
<Button onClick={getHealed} style={btnStyle}>
|
||||||
|
Get treatment for wounds - <Money money={getHospitalizationCost()} forPurchase={true} />
|
||||||
return (
|
</Button>
|
||||||
<Button onClick={this.getHealed} style={this.btnStyle}>
|
);
|
||||||
Get treatment for wounds - <Money money={cost} forPurchase={true} />
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user