IvarK / AntimatterDimensionsSourceCode

MIT License
160 stars 136 forks source link

Particular secret achievement impossible due to tab-switching hotkeys #3074

Closed dan-simon closed 2 years ago

dan-simon commented 2 years ago

Describe the bug 30 Lives, which is "Input the konami code.", is impossible due to arrow hotkeys being interpreted as tab switching

To Reproduce Steps to reproduce the behavior:

  1. Type the Konami code
  2. See issue (no secret achievement)

Expected behavior 30 Lives being given

Additional context I thought this issue existed already, but I couldn't find it. I'm pretty sure this has been discussed, though.

Hirame1 commented 2 years ago

Did you push Enter key at the last? I could get it :blobthink:

earthernsence commented 2 years ago

Did you push Enter key at the last? I could get it :blobthink:

No, I did not do this in testing. But it only works if you have hotkeys disabled, which I don't think is ideal.

Hirame1 commented 2 years ago

I tried again, it worked on both hotkeys enabled and disabled.

earthernsence commented 2 years ago

chrome_tWIlYDQRGZ Interesting.

dan-simon commented 2 years ago

This could be that after you press the Konami code, I think due to how the code is written your next keystroke doesn't count towards the Konami code, because of

  if (konamiCode[konamiStep] === character) konamiStep++;
  else konamiStep = 0;

(lines 461 and 462 of hotkeys.js). konamiStep isn't reset to 0 when you finish the Konami code, so konamiCode[konamiStep] will always be false for the next character after the Konami code.

I think this type of issue can partially be fixed by adding an else if (konamiCode[0] === character) konamiStep = 1;, but only partially; ["up", "up", "up", "down", "down", "left", "right", "left", "right", "b", "a", "enter"] would still not be counted as the Konami code. Possibly

  if (konamiCode[konamiStep] === character) konamiStep++;
  else if (konamiStep === 2 && konamiCode[1] === character) konamiStep = 2;
  else if (konamiCode[0] === character) konamiStep = 1;
  else konamiStep = 0;

would work (probably it should also have a comment explaining)

dan-simon commented 2 years ago

To be clear, the Konami code seems to mostly be working for me but to be failing intermittently, and I think the above thing with "due to how the code is written your next keystroke doesn't count towards the Konami code" is why but I'm not sure.