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

Optimize konami code so that it actually will check if order is correct before final validation #5

Open
augbog opened this issue Jan 13, 2017 · 0 comments

Comments

@augbog
Copy link
Owner

augbog commented Jan 13, 2017

Taking a look at the code

    // if first button isn't up, return
    if (keypresses.length == 0 && key != 38) {
      return;
    // if valid konami code character and keypresses available
    } else if (keypresses.length < 10 && /37|38|39|40|65|66/.test(key)) {

Ideally rather than validating a correct konami code character, it should verify if the order of the codes is entered correctly. The way it is now, if the user hits up and then hits any key that is a valid konami character i.e. up 10 times, it will still go through and try to validate. We can optimize it by simply going through a stack of the valid keypresses and fail the whole thing if its wrong.

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

No branches or pull requests

1 participant