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

57 lines
1.7 KiB
TypeScript
Raw Normal View History

/**
* React Subcomponent for displaying a location's UI, when that location is a gym
*
* This subcomponent renders all of the buttons for training at the gym
*/
import * as React from "react";
2021-09-25 21:34:12 +02:00
import Button from "@mui/material/Button";
2021-09-05 01:09:30 +02:00
import { Location } from "../Location";
2021-09-05 01:09:30 +02:00
import { IPlayer } from "../../PersonObjects/IPlayer";
2021-09-05 01:09:30 +02:00
import { Money } from "../../ui/React/Money";
2021-09-20 07:45:32 +02:00
import { IRouter } from "../../ui/Router";
import { Box } from "@mui/material";
import { ClassWork, ClassType, Classes } from "../../Work/ClassWork";
import { calculateCost } from "../../Work/formulas/Class";
type IProps = {
2021-09-05 01:09:30 +02:00
loc: Location;
p: IPlayer;
2021-09-20 07:45:32 +02:00
router: IRouter;
2021-09-05 01:09:30 +02:00
};
2021-09-25 21:34:12 +02:00
export function GymLocation(props: IProps): React.ReactElement {
function train(stat: ClassType): void {
props.p.startNEWWork(
new ClassWork({
classType: stat,
location: props.loc.name,
singularity: false,
}),
);
2022-01-18 15:49:06 +01:00
props.p.startFocusing();
props.router.toWork();
2021-09-05 01:09:30 +02:00
}
const cost = calculateCost(Classes[ClassType.GymStrength], props.loc);
2021-09-25 21:34:12 +02:00
return (
2022-04-07 01:30:08 +02:00
<Box sx={{ display: "grid", width: "fit-content" }}>
<Button onClick={() => train(ClassType.GymStrength)}>
2021-09-25 21:34:12 +02:00
Train Strength (<Money money={cost} player={props.p} /> / sec)
</Button>
<Button onClick={() => train(ClassType.GymDefense)}>
2021-09-25 21:34:12 +02:00
Train Defense (<Money money={cost} player={props.p} /> / sec)
</Button>
<Button onClick={() => train(ClassType.GymDexterity)}>
2021-09-25 21:34:12 +02:00
Train Dexterity (<Money money={cost} player={props.p} /> / sec)
</Button>
<Button onClick={() => train(ClassType.GymAgility)}>
2021-09-25 21:34:12 +02:00
Train Agility (<Money money={cost} player={props.p} /> / sec)
</Button>
</Box>
2021-09-25 21:34:12 +02:00
);
}