-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
2048 #1053
base: master
Are you sure you want to change the base?
2048 #1053
Conversation
Dushkaaa-BabyBoss
commented
Nov 28, 2024
•
edited
Loading
edited
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.
Try to fix tests
this.status = 'idle'; // Початковий статус гри | ||
} | ||
|
||
moveLeft() { |
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.
src/modules/Game.class.js
Outdated
this.board[i] = newRow; | ||
} | ||
|
||
this.addRandomTile(); |
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.
|
||
/** | ||
* Resets the game. | ||
*/ | ||
restart() {} | ||
restart() { |
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.
after clicking restart, the button text is "Start", but new tiles appeared and I can play
src/modules/Game.class.js
Outdated
} | ||
|
||
moveLeft() { | ||
this.checkLose(); |
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.
it should be done in after move - same as checkWin (no need to do it in each "move" method)
.reverse() | ||
.filter((value) => value !== 0); | ||
|
||
for (let j = 0; j < newRow.length - 1; j++) { |
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.
code in this method is almost the same, but you do reverse before and after manipulations. Try to add reusable code to a separate function and reuse it instead of duplication
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.
src/modules/Game.class.js
Outdated
@@ -23,22 +23,201 @@ class Game { | |||
constructor(initialState) { | |||
// eslint-disable-next-line no-console | |||
console.log(initialState); | |||
|
|||
// Ініціалізуємо гральну дошку |
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.
Remove all comments
// Ініціалізуємо гральну дошку |
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.
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.
LGTM, great job!