2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* 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";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { Location } from "../Location";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
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";
|
2022-01-15 06:12:16 +01:00
|
|
|
import { Box } from "@mui/material";
|
2022-07-07 23:28:23 +02:00
|
|
|
import { ClassWork, ClassType, Classes } from "../../Work/ClassWork";
|
|
|
|
import { calculateCost } from "../../Work/formulas/Class";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
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
|
|
|
};
|
2019-04-01 11:23:25 +02:00
|
|
|
|
2021-09-25 21:34:12 +02:00
|
|
|
export function GymLocation(props: IProps): React.ReactElement {
|
2022-05-04 21:18:12 +02:00
|
|
|
function train(stat: ClassType): void {
|
2022-07-14 23:43:08 +02:00
|
|
|
props.p.startWork(
|
2022-07-07 23:28:23 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-07-07 23:28:23 +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" }}>
|
2022-07-07 23:28:23 +02:00
|
|
|
<Button onClick={() => train(ClassType.GymStrength)}>
|
2021-09-25 21:34:12 +02:00
|
|
|
Train Strength (<Money money={cost} player={props.p} /> / sec)
|
|
|
|
</Button>
|
2022-07-07 23:28:23 +02:00
|
|
|
<Button onClick={() => train(ClassType.GymDefense)}>
|
2021-09-25 21:34:12 +02:00
|
|
|
Train Defense (<Money money={cost} player={props.p} /> / sec)
|
|
|
|
</Button>
|
2022-07-07 23:28:23 +02:00
|
|
|
<Button onClick={() => train(ClassType.GymDexterity)}>
|
2021-09-25 21:34:12 +02:00
|
|
|
Train Dexterity (<Money money={cost} player={props.p} /> / sec)
|
|
|
|
</Button>
|
2022-07-07 23:28:23 +02:00
|
|
|
<Button onClick={() => train(ClassType.GymAgility)}>
|
2021-09-25 21:34:12 +02:00
|
|
|
Train Agility (<Money money={cost} player={props.p} /> / sec)
|
|
|
|
</Button>
|
2022-01-15 06:12:16 +01:00
|
|
|
</Box>
|
2021-09-25 21:34:12 +02:00
|
|
|
);
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|