diff --git a/client/src/Board.css b/client/src/Board.css index 39dc7c6..c325d97 100644 --- a/client/src/Board.css +++ b/client/src/Board.css @@ -89,15 +89,19 @@ background-color: rgba(0, 0, 0, 0.5); box-shadow: 5px 5px 5px black; } -.Selected[data-color='R'] { + +[data-color='R'] { background-color: rgba(255, 0, 0, 0.5); } -.Selected[data-color='O'] { + +[data-color='O'] { background-color: rgba(255, 196, 0, 0.5); } -.Selected[data-color='W'] { + +[data-color='W'] { background-color: rgba(255, 255, 255, 0.5); } -.Selected[data-color='B'] { + +[data-color='B'] { background-color: rgba(0, 0, 255, 0.5); } \ No newline at end of file diff --git a/client/src/Board.js b/client/src/Board.js index 341c856..4d0baa7 100644 --- a/client/src/Board.js +++ b/client/src/Board.js @@ -4,7 +4,7 @@ import "./Board.css"; const base = process.env.PUBLIC_URL; const assetsPath = `${base}/assets`; -const Board = ({ game }) => { +const Board = ({ table, game }) => { const rows = [3, 4, 5, 4, 3, 2]; /* The final row of 2 is to place roads and corners */ const [signature, setSignature] = useState(""); const [pips, setPips] = useState(<>>); @@ -35,46 +35,6 @@ const Board = ({ game }) => { const Tile = ({tile}) => { const onClick = (event) => { console.log(`Tile clicked: ${tile.index}`); - let nodes = document.querySelectorAll('.Tile.Selected'); - for (let i = 0; i < nodes.length; i++) { - const el = nodes[i]; - if (el !== event.target) { - el.classList.remove('Selected'); - } - } - nodes = document.querySelectorAll('.Corner.Selected'); - for (let i = 0; i < nodes.length; i++) { - const el = nodes[i]; - if (el !== event.target) { - el.classList.remove('Selected'); - } - } - nodes = document.querySelectorAll('.Road.Selected'); - for (let i = 0; i < nodes.length; i++) { - const el = nodes[i]; - if (el !== event.target) { - el.classList.remove('Selected'); - } - } - game.layout.tiles[tile.index].corners.forEach(index => { - const el = document.querySelector(`.Corner[data-index="${index}"]`); - if (!el) { - console.log(`Unable to find corner[${index}]`); - } else { - el.classList.add('Selected'); - } - }); - game.layout.tiles[tile.index].roads.forEach(index => { - const el = document.querySelector(`.Road[data-index="${index}"]`); - if (!el) { - console.log(`Unable to find corner[${index}]`); - } else { - el.classList.add('Selected'); - } - }); - - event.target.setAttribute("data-color", game.color); - event.target.classList.toggle('Selected'); }; return