import { Grid, IconButton, Typography } from "@mui/material"; import CloseIcon from "@mui/icons-material/Close"; import AddIcon from "@mui/icons-material/Add"; import { MuiColorInput } from "mui-color-input"; import { RulesetName, WarGameConfig, getRandomColor, } from "../../../../internal"; import { useState } from "react"; import { useGameSpecificOptions } from "../hooks"; const WarControls = () => { const { config, handleUpdate } = useGameSpecificOptions( RulesetName.WAR ); const [newArmyColor, setNewArmyColor] = useState(getRandomColor()); const { factionColors } = config; return ( <> {factionColors.map((color, i) => { return ( Army {i + 1} { const newFactions = factionColors.filter( (existingColor) => existingColor !== color ); handleUpdate({ factionColors: newFactions }); }} > ); })} setNewArmyColor(newColor)} /> { const newFactions = [...factionColors, newArmyColor]; handleUpdate({ factionColors: newFactions }); setNewArmyColor(getRandomColor()); }} > ); }; export default WarControls;