1
0

Impelemented missing House Rules

This commit is contained in:
James Ketr 2025-09-25 12:13:00 -07:00
parent 25bb7d05a5
commit 279fc68718

View File

@ -15,12 +15,16 @@ import Dialog from "@mui/material/Dialog";
import DialogTitle from "@mui/material/DialogTitle";
import DialogContent from "@mui/material/DialogContent";
import DialogActions from "@mui/material/DialogActions";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableRow from "@mui/material/TableRow";
// import "./HouseRules.css";
import { GlobalContext } from "./GlobalContext";
import { Placard } from "./Placard";
import { Box } from "@mui/material";
/* eslint-disable @typescript-eslint/no-explicit-any */
@ -404,39 +408,50 @@ const HouseRules: React.FC<HouseRulesProps> = ({ houseRulesActive }) => {
<DialogTitle>House Rules</DialogTitle>
<DialogContent>
<Box sx={{ display: "flex", flexDirection: "column" }}>
{ruleList.map((item) => {
const defaultChecked = item.defaultChecked;
if (!(item.key in rules)) {
rules[item.key] = {
enabled: defaultChecked,
};
}
const checked = rules[item.key].enabled;
if (checked !== state[item.key]) {
setState({ ...state, [item.key]: checked });
}
<TableContainer>
<Table>
<TableBody>
{ruleList.map((item) => {
const defaultChecked = item.defaultChecked;
if (!(item.key in rules)) {
rules[item.key] = {
enabled: defaultChecked,
};
}
const checked = rules[item.key].enabled;
if (checked !== state[item.key]) {
setState({ ...state, [item.key]: checked });
}
return (
<div key={item.key} className="HouseSelector">
<div>
<b>{item.label}</b>: {item.description}
</div>
<div>
<Switch
size={"small"}
className="RuleSwitch"
checked={checked}
id={item.key}
onChange={(e) => setRule(e, item.key)}
disabled={gameState !== "lobby" || !name}
/>
</div>
{checked && item.element}
</div>
);
})}
</Box>
return (
<React.Fragment key={item.key}>
<TableRow>
<TableCell>
<b>{item.label}</b>
</TableCell>
<TableCell>{item.description}</TableCell>
<TableCell>
<Switch
size={"small"}
className="RuleSwitch"
checked={checked}
id={item.key}
onChange={(e) => setRule(e, item.key)}
disabled={gameState !== "lobby" || !name}
/>
</TableCell>
</TableRow>
{checked && (
<TableRow>
<TableCell colSpan={3}>{item.element}</TableCell>
</TableRow>
)}
</React.Fragment>
);
})}
</TableBody>
</Table>
</TableContainer>
</DialogContent>
<DialogActions>
<Button onClick={dismissClicked}>Close</Button>