This commit is contained in:
Martin Berg Alstad 2023-05-22 22:13:21 +02:00
parent a16de14d54
commit 485014d28d
2 changed files with 3 additions and 3 deletions

View File

@ -42,7 +42,7 @@ const Board: Component<BoardProps> = (
const [tileSize, setTileSize] = useState(2);
const [selectedCharacter, setSelectedCharacter] = useState<Character>();
// TODO show the paths to the positions when hovering over a possible position (type Path = CharacterPosition[])
const [possiblePositions, setPossiblePositions] = useState<Position[]>([]);
const [possiblePositions, setPossiblePositions] = useState<Position[]>([]); // TODO reset when other client moves a character
function handleSelectCharacter(character: Character): void {
setSelectedCharacter(character);
@ -178,5 +178,5 @@ const CharacterComponent: Component<CharacterComponentProps> = (
}) => (
<div className={`rounded-full w-4/5 h-4/5 cursor-pointer hover:border border-black ${className}`}
style={{backgroundColor: `${character.color}`}}
onClick={onClick ? () => onClick(character) : undefined}/>
onClick={() => onClick?.(character)}/>
);

View File

@ -16,7 +16,7 @@ function findPossibleRecursive(board: number[][], currentPos: Position, steps: n
possibleList: Position[], visitedTiles: Position[]): Position | null {
if (isOutsideBoard(currentPos, board.length)) {
addTeleportationTiles(board, currentPos, steps, possibleList, visitedTiles);
} else if (visitedTiles.find(tile => tile.x === currentPos.x && tile.y === currentPos.y)) {
} else if (visitedTiles.find(tile => tile.x === currentPos.x && tile.y === currentPos.y)) { // TODO might be true when teleporting, when it shouldn't (1,5) and 6 steps
return null;
} else if (isWall(board, currentPos)) {
return null;