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

Failure state #16

Open
3 tasks
jugglinmike opened this issue Sep 25, 2014 · 0 comments
Open
3 tasks

Failure state #16

jugglinmike opened this issue Sep 25, 2014 · 0 comments
Milestone

Comments

@jugglinmike
Copy link
Collaborator

Sometimes people will perform so poorly that we just need to stop them. We
don't want players to embarrass themselves, after all. It's about dignity.

There are two different ways a player's score can go down: when the player
clicks and misses, and when a mole escapes. Both events may trigger a "game
over".

Unfortunately, at the moment, the Director cannot respond to changes to the
miss count or the escape count. We could look through the code for every
place we increment those counters, but (1) we might miss one, and (2) we might
forget to add this new "game over" check if we add more code in the future.

Let's create a centralized function that "knows" about all the changes to those
counter variables. Then, we'll update all the places we increment the instance
variables to instead call the function.

At this point, the game will work exactly the same as it did before. But we
can add our new "game over" check to that new function.

  • director.js
    • Define an increment method. This should take a single argument: the
      name of the instance variable to increment. When you call
      director.increment('miss');, for example, the miss count should increase
      by 1.
    • Replace any line of code that increments a counter variable with a call
      to the new increment method.
    • Update the increment method to check if the player has lost. If they
      have lost, call the endGame method.

We haven't decided how badly the player has to perform before losing. It's not
in the spec, so it could be anything. Maybe they lose after missing 5 times. Or
when 8 moles escape. Or both. It's up to you!

@jugglinmike jugglinmike modified the milestone: Game state 1 Sep 25, 2014
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