Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hidden layer tile selection bug #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ingoschlegelmilch
Copy link
Collaborator

Issue should be fixed without affecting any special tiles.

Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eureka ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 2:19pm

@ingoschlegelmilch ingoschlegelmilch linked an issue Nov 13, 2024 that may be closed by this pull request
const { gameBoard: board } = get();
const { row, layer } = board[index];
const currentTile = board[index];
const { row, layer, column } = currentTile;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructure directly

board[j].layer === layer + 1 &&
board[j].column === column;
})
.map((j: string) => j);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant statement.

})
.map((j: string) => j);
};

Copy link
Owner

@riethmayer riethmayer Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isCoveringItem = (row: number, layer: number, column: number) => {
const coveringItems = Object.keys(board);
.filter((j) => {
return board[j].row === row - 1 &&
board[j].layer === layer + 1 &&
board[j].column === column;
})
return !!coveringItems && coveringItems[0]
};

@@ -159,6 +171,11 @@ export const useGameStore = create<GameState>()(
.map((i: string) => i);
};

// Check if covering tile exists
if (coveringItem(row, layer, column).length !== 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (coveringItem(row, layer, column).length !== 0) {
if (isCoveringItem(row, layer, column)) {

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe so schlecht, nee geht nicht, dass man direkt ne andere Implementation suggested.
Wahrscheinlich auch um das discouragen.

@@ -159,6 +171,11 @@ export const useGameStore = create<GameState>()(
.map((i: string) => i);
};

// Check if covering tile exists
if (coveringItem(row, layer, column).length !== 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe so schlecht, nee geht nicht, dass man direkt ne andere Implementation suggested.
Wahrscheinlich auch um das discouragen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

covered tiles are clickable tiles
2 participants