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

develop #1125

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

develop #1125

wants to merge 4 commits into from

Conversation

nineuito
Copy link

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

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

Good job 👍
Add a favicon on the page
image

Comment on lines 51 to 74
const prevState = structuredClone(this.state);

for (let i = 0; i < 4; i++) {
const row = this.state[i].filter((cell) => cell !== 0);

for (let j = row.length - 1; j > 0; j--) {
if (row[j] === row[j - 1]) {
row[j] *= 2;
this.score += row[j];
row.splice(j - 1, 1);
j--;
}
}

while (row.length < 4) {
row.unshift(0);
}
this.state[i] = row;
}

if (prevState !== structuredClone(this.state)) {
this.addRandomTile();
this.updateGameStatus();
}

Choose a reason for hiding this comment

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

This logic is similar in every method, try to put it in a helper function and use it everywhere

Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

good job, but don't add a new cell if the board didn't change

Screen.Recording.2025-01-15.at.12.03.48.mov

@nineuito nineuito requested a review from etojeDenys January 16, 2025 18:46
Copy link

@maxim2310 maxim2310 left a comment

Choose a reason for hiding this comment

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

Well done!!!

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.

4 participants