octachrome / treason

A clone of the card game Coup written in Node.js
Other
139 stars 79 forks source link

Unique playerId per player #43

Closed JackieNiebling closed 4 years ago

JackieNiebling commented 4 years ago

The playerId needs to be generated for the player by the server, if the player isn't providing one themselves already. Using the classic anti pattern of 'navigation by exception', I had originally attempted a couch key lookup directly of the provided playerId and if that failed, assigned them a fresh one in the catch block.

To fix this, the dummy data-access now also generates an Id if one isn't provided already.

JackieNiebling commented 4 years ago

No, new players can join, they just assume each other's identity in chat I think, because it uses the player index in the game.

Good point about the promise, nobody likes mixed responses. Fixed now.