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

Game 2048 #1093

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

Game 2048 #1093

wants to merge 3 commits into from

Conversation

pdabizha
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!
To improve:

  1. Add favicon on the page
image

});

if (hasWinningCell) {
return 'win'; // Игрок выиграл

Choose a reason for hiding this comment

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

Remove comments

Suggested change
return 'win'; // Игрок выиграл
return 'win';

if (arr[i] === arr[i + 1]) {
const mergedValue = arr[i] * 2;

result.push(mergedValue); // Удваиваем значение

Choose a reason for hiding this comment

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

Remove comments everywhere

Suggested change
result.push(mergedValue); // Удваиваем значение
result.push(mergedValue);

Comment on lines 74 to 91
const previousBoard = this.getState();

const transposedBoard = this.transpose(this.board);

transposedBoard.forEach((row, index) => {
const nonZeroElements = row.filter((value) => value !== 0);
const combinedRow = this.joinValues(nonZeroElements, row.length);

transposedBoard[index] = combinedRow;
});

this.board = this.transpose(transposedBoard);

if (this.isBoardChanged(previousBoard, this.board)) {
const randomCell = this.getRandomCell(1);

this.addNewCell(randomCell);
}

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, so it would be better to move it to 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.

amazing

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.

3 participants