Compare commits

..

2 Commits

Author SHA1 Message Date
b6b1358131 GameBoard: ignore obvuisly bad moves 2023-11-27 15:03:57 +01:00
0e6e896851 small code explainer 2023-11-24 13:10:39 +01:00
2 changed files with 8 additions and 2 deletions

View File

@ -85,7 +85,10 @@ export function Board({ board, flip, prevMove, currMove, onStoneClick, onStoneMo
const isInteractive = (board && (typeof onStoneClick === 'function' || typeof onStoneMove === 'function')) ? ' interactive' : ''; const isInteractive = (board && (typeof onStoneClick === 'function' || typeof onStoneMove === 'function')) ? ' interactive' : '';
const WhiteTile = ({ id }) => { const WhiteTile = ({ id }) => {
const stone = (id === currMove[1]) ? board[currMove[0]] : board[id]; id = (id !== currMove[1]) ? id :
currMove[0]; // the stone from currMove sarting position
const stone = board[id];
return ( return (
<div className={'Tile white' <div className={'Tile white'

View File

@ -14,7 +14,10 @@ export default function GameBoard({ username, getGame, onStoneClick, onStoneMove
(cellId) => onStoneClick(game.uuid, cellId); (cellId) => onStoneClick(game.uuid, cellId);
const optionalOnStoneMove = (typeof onStoneMove !== 'function' || isPushing) ? null : const optionalOnStoneMove = (typeof onStoneMove !== 'function' || isPushing) ? null :
(move) => onStoneMove(game.uuid, move); (move) => {
if (move[0] !== move[1] && game.board[move[1]] === undefined)
onStoneMove(game.uuid, move)
};
return ( return (
<div className='GameBoard'> <div className='GameBoard'>