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

shift plus moving moves character as far as it can #1071

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

Conversation

k2xl
Copy link
Collaborator

@k2xl k2xl commented Jan 21, 2024

No description provided.

@k2xl k2xl requested a review from sspenst January 21, 2024 02:22
Copy link

codecov bot commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f3349e0) 83.46% compared to head (c38aabc) 83.46%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1071   +/-   ##
=======================================
  Coverage   83.46%   83.46%           
=======================================
  Files         222      222           
  Lines        6386     6386           
  Branches     1360     1360           
=======================================
  Hits         5330     5330           
  Misses       1015     1015           
  Partials       41       41           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

let timesToMove = 1;

// if code starts with arrow
if (shiftKeyDown.current && code.startsWith('Arrow')) {
Copy link
Owner

Choose a reason for hiding this comment

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

This logic should be moved to within the setGameState of handleKeyDown

Need a condition around this section of code:

      if (!makeMove(newGameState, direction, !disableAutoUndo)) {
        return prevGameState;
      }

to check if the shift key is pressed, and if so call makeMove in a loop until it fails

Would need to double check that the makeMove function doesn't mess up the gameState object when the function returns false (since it updates in-place)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I was doing this first but then realized that undo may not work as expected. I can try it and see but I think that we wouldn't be storing the intermediate state

Copy link
Owner

Choose a reason for hiding this comment

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

Interesting... I wonder what would be best there. Maybe it's nice if a single undo removes all the moves at once? Since the shift + move is kind of like one "move"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think it is less confusing if you can undo one at a time and not be in a batch...

@@ -335,28 +335,28 @@ export default function Game({
onNext();
}

return;
return false;
Copy link
Owner

Choose a reason for hiding this comment

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

don't need to return a boolean here, or if we do it should be more clear what the boolean means

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

Successfully merging this pull request may close these issues.

2 participants