def route(game_id, data, userid, username): command = None params = [] if data: command = COMMAND_MAPPINGS.get(data[0].lower()) if len(data) > 1: params = data[1:] if command: game_state = GameState() game_state.load(game_id) try: return command(commands.Game(game_state), params, userid, username).to_json() finally: game_state.save(game_id) return { "text": u"""Usage: /slack command, where commands are: reset [confirm]: reset the game if "confirm" is passed as the parameter setup [add|remove]: display the current setup. If add is the parameter, add rest of text as setup text. If remove, remove the nth item. pool [reroll|setup]: show the current dice pool. if setup passed as a parameter, setup the initial pool. if reroll passed in, reroll all dice in the pool. register [name]: register your player name with the game unregister [name]: unregister yourself or the specified user status: output current status to channel take [color number]: take a die from the pool give [color number] [user]: give a die to another player. use "pool" as player name to return to the pool. roll: roll all your dice and give the aggregate score spend: spend one your dice (so you no longer have it)""" }
def route(game_id,data,userid,username): command = None params = [] if data: command = COMMAND_MAPPINGS.get(data[0].lower()) if len(data) > 1: params = data[1:] if command: game_state = GameState() game_state.load(game_id) try: return command(commands.Game(game_state), params,userid,username).to_json() finally: game_state.save(game_id) return {'text': u"""Usage: /slack command, where commands are: reset [confirm]: reset the game if "confirm" is passed as the parameter setup [add|remove]: display the current setup. If add is the parameter, add rest of text as setup text. If remove, remove the nth item. pool [reroll|setup]: show the current dice pool. if setup passed as a parameter, setup the initial pool. if reroll passed in, reroll all dice in the pool. register [name]: register your player name with the game unregister [name]: unregister yourself or the specified user status: output current status to channel take [color number]: take a die from the pool give [color number] [user]: give a die to another player. use "pool" as player name to return to the pool. roll: roll all your dice and give the aggregate score spend: spend one your dice (so you no longer have it)"""}