-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add task solution #1171
base: master
Are you sure you want to change the base?
add task solution #1171
Conversation
JosielLinhar
commented
Feb 4, 2025
- DEMO LINK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the 2048 game! 🎉 Your code meets the task requirements and effectively handles the game logic and user interactions. While there are a few minor improvements suggested, such as ensuring win/lose messages are hidden on restart and returning the updated state in some methods for consistency, these do not impact the core functionality. Keep up the good work and consider these enhancements for an even smoother user experience! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
moveRight() { | ||
if (this.getStatus() === 'playing') { | ||
this.reverseState(); | ||
this.moveLeft(); | ||
this.reverseState(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The moveRight
method does not return the updated state after performing the move. Consider returning this.state
at the end of the method to maintain consistency with moveLeft
.
moveUp() { | ||
if (this.getStatus() === 'playing') { | ||
this.flipState(); | ||
this.moveLeft(); | ||
this.flipState(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The moveUp
method does not return the updated state after performing the move. Consider returning this.state
at the end of the method to maintain consistency with moveLeft
.
moveDown() { | ||
if (this.getStatus() === 'playing') { | ||
this.flipState(); | ||
this.moveRight(); | ||
this.flipState(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The moveDown
method does not return the updated state after performing the move. Consider returning this.state
at the end of the method to maintain consistency with moveLeft
.
game.restart(); | ||
updateTable(game.getState()); | ||
updateScore(game.getScore()); | ||
winOrLose(); | ||
|
||
button.classList.replace('restart', 'start'); | ||
button.innerHTML = 'Start'; | ||
|
||
messageStart.classList.remove('hidden'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When restarting the game, ensure that the win and lose messages are hidden. Currently, only the start message is shown, but if the game was previously won or lost, those messages might still be visible. Consider adding messageWin.classList.add('hidden');
and messageLose.classList.add('hidden');
to ensure they are hidden when the game restarts.