Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 committed Aug 19, 2024
1 parent 2438470 commit eb5ca02
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export default function App() {

const [customState, dispatchCustomState] = React.useReducer(
customReducer,
{
},
{},
customInit,
);

Expand Down Expand Up @@ -208,7 +207,7 @@ export default function App() {
setDisplay={setDisplay}
></CustomCreation>
</div>
)
);

default:
return (
Expand Down
5 changes: 1 addition & 4 deletions src/components/CustomPool.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from "react";
import Piece from "./Piece";

export default function CustomPool({
pieces,
dispatchGameState,
}) {
export default function CustomPool({pieces, dispatchGameState}) {
const poolPieces = pieces.filter((piece) => piece.poolIndex >= 0);
poolPieces.sort((a, b) => a.poolIndex - b.poolIndex);

Expand Down
1 change: 0 additions & 1 deletion src/logic/convertGridToRepresentativeString.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function convertGridToRepresentativeString(grid) {
// todo center the grid
// todo validate that the puzzle consists of known words vert and horiz


let stringifiedGrid = "";
let spaceCount = 0;

Expand Down
40 changes: 22 additions & 18 deletions src/logic/customReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,31 @@ function updateStateForDragStart({
placeholderPoolPieces = piecesBeingDragged.map((piece) =>
updatePieceDatum(piece, {
letters: [[""]],
id: (piece.id + 1) * (-1)
id: (piece.id + 1) * -1,
}),
)
);
}

currentGameState = {
...currentGameState,
pieces: piecesNotBeingDragged.concat(
piecesBeingDragged.map((piece) =>
updatePieceDatum(piece, {
//todo add an empty letter here if dragging from pool?
boardTop: undefined,
boardLeft: undefined,
poolIndex: undefined,
dragGroupTop:
groupBoardTop === undefined ? 0 : piece.boardTop - groupBoardTop,
dragGroupLeft:
groupBoardLeft === undefined ? 0 : piece.boardLeft - groupBoardLeft,
}),
),
).concat(placeholderPoolPieces),
pieces: piecesNotBeingDragged
.concat(
piecesBeingDragged.map((piece) =>
updatePieceDatum(piece, {
//todo add an empty letter here if dragging from pool?
boardTop: undefined,
boardLeft: undefined,
poolIndex: undefined,
dragGroupTop:
groupBoardTop === undefined ? 0 : piece.boardTop - groupBoardTop,
dragGroupLeft:
groupBoardLeft === undefined
? 0
: piece.boardLeft - groupBoardLeft,
}),
),
)
.concat(placeholderPoolPieces),
dragCount: currentGameState.dragCount + 1,
dragState: updateDragState({
pieceIDs: piecesBeingDragged.map((piece) => piece.id),
Expand Down Expand Up @@ -217,7 +221,7 @@ function updateStateForDragEnd(currentGameState) {
for (const piece of currentGameState.pieces) {
if (draggedPieceIDs.includes(piece.id)) {
continue;
} else if (piece.letters[0][0] !== ""){
} else if (piece.letters[0][0] !== "") {
newPieces.push(piece);
}
}
Expand All @@ -233,7 +237,7 @@ function updateStateForDragEnd(currentGameState) {
dragGroupLeft: undefined,
}),
);
} else if (piece.letters[0][0] !== ""){
} else if (piece.letters[0][0] !== "") {
newPieces.push(piece);
}
}
Expand Down

0 comments on commit eb5ca02

Please sign in to comment.