def _register_player(self, player): """ Register a new player to the server (internal function). """ # generate a (public) ID and (private) access token player.id = short_uuid() player.akey = short_uuid() self.players.append(player) return player.rpc_encode(private=True)
def game_create(self): """ Create a new game and enter it. Return the game id. """ player = self.authenticated_player game = GameController() # TODO: slight chance of race self.games.append(game) game.id = short_uuid() try: self.game_enter(self.authenticated_player.akey, game.id) except GameError: self.games.remove(game) raise return game.id