jporter-dev / codewords

162 stars 39 forks source link

Lock “reveal” once spymaster is chosen #11

Open natelapp opened 6 years ago

natelapp commented 6 years ago

Once someone has clicked “reveal” as the spymaster, no one else should be able to reveal the map

jporter-dev commented 6 years ago

Thanks for the suggestion! I'll have to think about this one some more. I get the reasoning, but there's also usually two spymasters, so perhaps locking it to two could work? Other edge cases include refreshing the page/exiting and rejoining the game. I currently don't track connected clients, so I think having a mechanism to do that and use that for tracking the current "spymasters" could work.

jporter-dev commented 4 years ago

Revisiting this as it's been requested by other users, plus with the game being played virtually it would make sense to have something for tracking spymasters.

My initial idea: generate client_ids on each connected client prior to joining the room (or on connect, could assign it server-side). Pass client_id with all requests, and add a channel/method for toggling spymaster. Pass a message on the toggle_spymaster channel when entering/leaving the spymaster view. On message, call Game.Info#toggle_spymaster which adds/removes the client_id from a spymasters dict/list. Add spymasters to to_json.

Client-side, I envision a "spymaster count" badge on the spymaster button to show how many active spymasters there are. Also would add an additional layer of "are you sure?" buttons before switching if spymasters.count > 2. Prefer not to fully "lock" the view just in case something errors and we lose track.

Additional possibilities with this method of client_id tracking:

khimaros commented 4 years ago

Another possibility would be similar to http://syeedibnfaiz.com/codenames/

Generate a unique code for the spymaster link and only provide that link to other spymasters. Everyone else gets the non-spymaster link.

The caveat is that the spymaster links are not one-time-use, so you need to at least trust the other spymasters not to give the link to their team mates.

MirSob commented 4 years ago

I've discovered simple solution. After game is regenerate button is clicked set all player into Agent mode and reset global Spymaster counter. Display this counter on bottom row. After any one goes to Spymaster mode increment counter. Every one will know about number of SpyMasters in game.

serknor commented 4 years ago

My suggestions for solving this: 1) Advanced option for setting the max amount of spymasters possible in the game. For example, if I set that option to "2", when that number is reached, nobody can turn itself to spymaster. 1a) If the spymaster disconnects by error, he can re-join, since the spymaster count is at "1". 1b) If the spymaster has to leave the game, he can disconnect, the spymaster count is at "1" and another player of his team can be the spymaster. If the option is turned off, there's no limit to the amount of spymasters. 2) Advanced option "spymasters can't become agents again in the same game". If a user goes into spymaster mode, I don't see any reason for him to go back to agent mode in the same game, since he already knows all the answers. If he went by mistake, they should create a new game anyway.

jporter-dev commented 4 years ago

@serknor - I think this is a viable strategy. When new games are created, the spymasters are reset to agents so new games should work fine in that sense. I can implement this soon, I just wanted to ensure that the spymaster toggling was working well before locking user out of it just in case.

Thoughts on using the # of teams as the spymaster count? There should only be one spymaster per team so it seems fine to me.

serknor commented 4 years ago

Regarding the last sentence. Since I noticed you where taking a cautious approach to modifications, I thought that an option to set the limit manually would be less strict than having the site define it. For example, if someone is learning how to play, you will have: 1 spymaster for team red, 1 spymaster for team blue and 1 person that is just watching how to play as a spymaster (without actually playing). BUT the cases where this will happen are really exceptional AND they can also be solved by just having the toggle say: "Limit 1 spymaster per team: Yes / No". If for any reason they need more than 1 spymaster per team, they can disable that option. Your approach is cleaner and makes the options easier to understand.

jporter-dev commented 4 years ago

That's a fair point - there are so many different situations that arise in this game that I never even think about, such as having a "spectator" watching the spymaster view.

Perhaps a solution that allows the user to input the # of spymasters, but it will default to the # of teams and will be hidden behind the "advanced options" section?

serknor commented 4 years ago

As you prefer. For me, since having more than 1 spymaster per team is an exception to the rule, just having a toggle in the advanced options "Limit 1 spymaster per team: On / Off" is enough, without making it complicated. 99% of the time people will play with this option turned on. If someone wants to have a spectator, or want to play with 2 spymaster per team, etc, they turn that option off.