-
Notifications
You must be signed in to change notification settings - Fork 7
A Player can lose #37
Copy link
Copy link
Open
Description
User Story
As a user
When I receive a shot
And that shot is a hit
And that hit strikes my last un-hit point
Then the game is over for that player
Implementation Plan
Step 1: Check if a hit is the "last hit"
- When a user receives a shot over PubSub
- And we check if that shot is a hit or a miss
- And it we find that it is a hit
- Then we should check to see if the user has any un-hit points left - hint: where in socket.assigns are we storing the knowledge of which hits we've received?
Step 2: Game Over
- If that hit is the "last hit" and the user has no more points that are open, then the game should be over for that player
What does it mean for the game to be over? Keep in mind that more than two players can play the game. So, if one player lost that doesn't necessary mean the other player one. A player looses when they have no more points to get hit and a player wins when they are the last player standing. So, if there are only two players, and one loses, then the other did win. But if there are more than two players, then one loses and the others are still in the game.
Here are some ideas we might build:
- When a player looses, broadcast a "player lost" message with the player ID.
- When the live view receives that message, check to see if the player ID from the message is the same as the player ID of the current live view. If it is the same, display a game over message to the player that lost and remove the opponent game board from the view so that they can't fire any more shots.
- If it is not the same, determine if there are more than two players. If there are more than two players, display a "player #{id} lost" message but let the remaining players keep playing. If there are only two players, display a "You won!" message and end the game by removing the opponent board from the current player's view.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels