diff --git a/src/components/CustomCreation.js b/src/components/CustomCreation.js index d3f660d..765dd03 100644 --- a/src/components/CustomCreation.js +++ b/src/components/CustomCreation.js @@ -30,7 +30,7 @@ function CustomCreation({dispatchCustomState, customState, validityOpacity}) { indicateValidity={validityOpacity > 0} dragPieceIDs={customState.dragState?.pieceIDs} dragDestination={customState.dragState?.destination} - gridSize={12} + gridSize={customState.gridSize} customCreation={true} > 9) { diff --git a/src/logic/convertRepresentativeStringToGrid.js b/src/logic/convertRepresentativeStringToGrid.js index 083da71..d665d2b 100644 --- a/src/logic/convertRepresentativeStringToGrid.js +++ b/src/logic/convertRepresentativeStringToGrid.js @@ -54,6 +54,7 @@ export function convertRepresentativeStringToGrid(string) { // so I don't need to remove whitespace from the edges or center the grid. // (Since this is done when the custom query is generated via the UI.) // By this same logic, I'm not validating that the puzzle consists of known words. + // (Since that is done when a player tries to generate the query string via the UI.) const grid = arrayToGrid(list); return grid; diff --git a/src/logic/gameInit.js b/src/logic/gameInit.js index a3d0531..02b2873 100644 --- a/src/logic/gameInit.js +++ b/src/logic/gameInit.js @@ -54,9 +54,7 @@ export function gameInit({ if ( savedState && savedState.seed && - //todo verify comment clarity - // If daily or custom, use the saved state if the seed matches - // otherwise, we don't care if the seed matches + // Make sure the seed matches (unless this isn't a daily or custom game) ((!isDaily && !isCustom) || savedState.seed == seed) && validateSavedState(savedState) && // Use the saved state if daily even if the game is solved @@ -90,7 +88,9 @@ export function gameInit({ maxShiftDown, } = generatePuzzleFromRepresentativeString({representativeString: seed})); } catch (error) { - console.error(error); + console.error( + `Error generating custom puzzle from seed ${seed}. Will proceed to generate random game instead. Caught error: ${error}`, + ); ({pieces, maxShiftLeft, maxShiftRight, maxShiftUp, maxShiftDown} = generatePuzzle({ diff --git a/src/logic/gameReducer.js b/src/logic/gameReducer.js index 3a74ff5..b699431 100644 --- a/src/logic/gameReducer.js +++ b/src/logic/gameReducer.js @@ -101,7 +101,8 @@ function updateStateForDragStart({ }; } - // (For custom creation only) If dragging from the pool, add a dummy placeholder + // (For custom creation only) + // If dragging from the pool, add a dummy placeholder let placeholderPoolPieces = []; if (isCustomCreation && groupBoardTop === undefined) { placeholderPoolPieces = piecesBeingDragged.map((piece) => @@ -289,8 +290,9 @@ function updateStateForCustomDragEnd(currentGameState) { newPieces.push(piece); } } - } else if (destination.where === "pool" && origin.where === "board") { - // If dragging from board to pool, clear the piece from the board but don't add it to the pool + } + // If dragging from board to pool, clear the piece from the board but don't add it to the pool + else if (destination.where === "pool" && origin.where === "board") { for (const piece of currentGameState.pieces) { if (draggedPieceIDs.includes(piece.id)) { continue; @@ -300,6 +302,7 @@ function updateStateForCustomDragEnd(currentGameState) { } } // If dragging from pool to pool, readd the piece to the pool at its original position + // (and get rid of the empty placeholder piece) else if (destination.where === "pool" && origin.where === "pool") { for (const piece of currentGameState.pieces) { if (draggedPieceIDs.includes(piece.id)) { diff --git a/src/logic/generatePuzzleFromRepresentativeString.js b/src/logic/generatePuzzleFromRepresentativeString.js index 8462abb..a3675b5 100644 --- a/src/logic/generatePuzzleFromRepresentativeString.js +++ b/src/logic/generatePuzzleFromRepresentativeString.js @@ -27,10 +27,10 @@ export function generatePuzzleFromRepresentativeString({representativeString}) { return { pieces: pieceData, - maxShiftLeft: maxShiftLeft, - maxShiftRight: maxShiftRight, - maxShiftUp: maxShiftUp, - maxShiftDown: maxShiftDown, + maxShiftLeft, + maxShiftRight, + maxShiftUp, + maxShiftDown, gridSize, minLetters, };