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

Memory Pair Game #344

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

zhenyakornilov
Copy link
Contributor

@zhenyakornilov zhenyakornilov commented Aug 29, 2022

Memory Pair Game

Demo | Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@zhenyakornilov
Copy link
Contributor Author

Added some changes with fixes and improvements

@zhenyakornilov
Copy link
Contributor Author

zhenyakornilov commented Sep 11, 2022

Feedback collected, issues fixed accordingly to remarks by other students.

@stale
Copy link

stale bot commented Sep 25, 2022

This issue has been automatically marked as stale because there were no activity during last 14 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

А. Чому так?
Найбільш розповсюджена причина: Студент не реагує на коментарі змінами коду і не задає запитань через брак часу або зміну життєвих пріоритетів. Покинуті піари відволікають менторів. Коли у студента з'явиться час, він/вона зможе перевідкрити той самий піар і продовжити роботу.

Б. Що робити, якщо в піарі нема оновлень, оскільки не зрозуміло, що треба зробити?
Варіант 1. Задати питання в самому PR.
Варіант 2. Задати питання в студентському чаті.

В. А якщо я все зробив(ла) і це ментор не рев'юває мої зміни?

  1. Переконайся, що ти відреагував(ла) на всі коментарі або кодом, або запитаннями, або відповідями. Напиши в PR і в чаті, що чесно вважаєш, що все зроблено і попроси повторне рев'ю. Якщо щось не зрозуміло, задай запитання.
  2. Реагуй на коментарі як менторів, так і інших учасників, включаючи ботів.
  3. Не ігноруй прохання типу * "Let's do some self-checks ..." * "Go through the checklist below..." * "mark fulfilled requirements..." * "if you would silently ignore this recommendation, a mentor may think that you are still working on fixes"
    навіть якщо вони написані ботом. Боти помічники і ментори покладаються на те, що прохання і пропозиції бота дотримуються.
    Не лінись піти по лінках в коментарях, погуглити термінологію та скористатись Google Translate.
  4. Можливо, у менторів склалися інші пріоритети через роботу, сімейні обставини і т.п. В такому разі, якщо ти зробив(ла) рекомендоване вище, то волай в чаті, що PR позначений stale, наче, все зроблено, а ментори чомусь не реагують - рятуйте!

Г. Хіба недостатньо того, що я додав(ла) коміт із змінами?
Часто буває так, що бачиш новий коміт, ідеш перевіряти, змін багато, доводиться перечитувати весь код. А потім з'ясовується, що одна невеличка зміна "відкладена на потім" чи з'являється ще один коміт і знов треба перечитувати все. Любіть нас, спілкуйтеся з нами - і ми відповімо повною взаємністю.

Традиційна пропозиція: задай питання по вищенаписаному в студентському чаті.

@stale stale bot added the 💤 Stale label Sep 25, 2022
@zhenyakornilov
Copy link
Contributor Author

Self checks done, please, remove stale label.

@stale stale bot removed the 💤 Stale label Sep 25, 2022
@OleksiyRudenko OleksiyRudenko added UAT-done Student confirmed User Acceptance Tests are done and collected feedback is processed self-check-done Student confirmed that self-checks against requirements/common-mistakes are done Stage0.1 labels Oct 1, 2022
@kasionio kasionio self-assigned this Oct 2, 2022
@kasionio kasionio self-requested a review October 2, 2022 16:05
Copy link
Contributor

@kasionio kasionio 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! Please take a look at the comments.
Small tip - if we want to compare two elements we can simply use
function isElementsMatched (first, second) { return first.name === second.name }

currentCardPair: [],
totalTries: 0,
};
const allGameCards = shuffleCards([...cards, ...cards]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems allCards or shuffledCards will be enough here, to make it consistent with shuffleCards

renderCards(allGameCards, cardsMenu);

function shuffleCards(cardsArr) {
for (let i = cardsArr.length - 1; i > 0; i--) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks sort array method is the best choice here

Copy link
Contributor Author

@zhenyakornilov zhenyakornilov Oct 2, 2022

Choose a reason for hiding this comment

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

Did You mean that Fisher–Yates shuffle is overkill to shuffle game cards? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a built-in sort method in JS for this purpose, no need to reinvent the wheel, also it is much better for code readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

But you can leave it, I changed my mind :))

}

function sleep(milliseconds) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need async operation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to create some kind of custom delay function instead of repeating setTimeout all the time. This is solution I came up with and thats why I use async - await later. I haven't figured out how to do that in another way yet (except using setTimeout in every place where I currently used my sleep() function.

cardsList.innerHTML = cardsHTML;
}

function sleep(milliseconds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess cards won't sleep, please try rename a function :)

}

function checkCardsMatch() {
return states.firstFlippedCard.isEqualNode(states.secondFlippedCard);
Copy link
Contributor

Choose a reason for hiding this comment

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

why so a complicated approach? I guess better compare name of the cards, even for performance reasons

}

function restartGame() {
location.reload();
Copy link
Contributor

Choose a reason for hiding this comment

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

clumsy method :))


let cardsBlocked = false;

cardsMenu.addEventListener("click", async function flipCards({ target }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please explain why do you need async here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I unterstood remark properly. Without async-await it all breaks and does not work as expected.

@zhenyakornilov
Copy link
Contributor Author

zhenyakornilov commented Oct 2, 2022

I tried to account all the recommendations and remarks, but some questions still left (answered in comments above).

@stale
Copy link

stale bot commented Apr 14, 2023

This issue has been automatically marked as stale because there were no activity during last 14 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

А. Чому так?
Найбільш розповсюджена причина: Студент не реагує на коментарі змінами коду і не задає запитань через брак часу або зміну життєвих пріоритетів. Покинуті піари відволікають менторів. Коли у студента з'явиться час, він/вона зможе перевідкрити той самий піар і продовжити роботу.

Б. Що робити, якщо в піарі нема оновлень, оскільки не зрозуміло, що треба зробити?
Варіант 1. Задати питання в самому PR.
Варіант 2. Задати питання в студентському чаті.

В. А якщо я все зробив(ла) і це ментор не рев'юває мої зміни?

  1. Переконайся, що ти відреагував(ла) на всі коментарі або кодом, або запитаннями, або відповідями. Напиши в PR і в чаті, що чесно вважаєш, що все зроблено і попроси повторне рев'ю. Якщо щось не зрозуміло, задай запитання.
  2. Реагуй на коментарі як менторів, так і інших учасників, включаючи ботів.
  3. Не ігноруй прохання типу * "Let's do some self-checks ..." * "Go through the checklist below..." * "mark fulfilled requirements..." * "if you would silently ignore this recommendation, a mentor may think that you are still working on fixes"
    навіть якщо вони написані ботом. Боти помічники і ментори покладаються на те, що прохання і пропозиції бота дотримуються.
    Не лінись піти по лінках в коментарях, погуглити термінологію та скористатись Google Translate.
  4. Можливо, у менторів склалися інші пріоритети через роботу, сімейні обставини і т.п. В такому разі, якщо ти зробив(ла) рекомендоване вище, то волай в чаті, що PR позначений stale, наче, все зроблено, а ментори чомусь не реагують - рятуйте!

Г. Хіба недостатньо того, що я додав(ла) коміт із змінами?
Часто буває так, що бачиш новий коміт, ідеш перевіряти, змін багато, доводиться перечитувати весь код. А потім з'ясовується, що одна невеличка зміна "відкладена на потім" чи з'являється ще один коміт і знов треба перечитувати все. Любіть нас, спілкуйтеся з нами - і ми відповімо повною взаємністю.

Традиційна пропозиція: задай питання по вищенаписаному в студентському чаті.

@stale stale bot added the 💤 Stale label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-check-done Student confirmed that self-checks against requirements/common-mistakes are done Stage0.1 💤 Stale task-MPG UAT-done Student confirmed User Acceptance Tests are done and collected feedback is processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants