def get_game_state(userid): player = session.query(Player).filter_by(userid_player=userid).first() if player is None: raise WithingsException(*status.USER_NOT_FOUND) p = g._get_by_userid(userid) return json_response({'status': status.OK, 'body': g.dump_state(p)})
def join_game(userid): player = session.query(Player).filter_by(userid_player=userid).first() if player is None: raise WithingsException(*status.USER_NOT_FOUND) g.add_player(player) return json_response({'status': status.OK, 'body': "Ok!"})
def player_get(userid): player = session.query(Player).filter_by(userid_player=userid).first() if player is None: raise WithingsException(*status.USER_NOT_FOUND) return json_response({ 'status': status.OK, 'body': utils.format_player(player) })
def player_create(userid, info): player = session.query(Player).filter_by(userid_player=userid).first() if player is not None: raise WithingsException(*status.USER_ALREADY_EXISTS) info = json.loads(info) player = Player(userid, info) session.add(player) session.commit() return json_response({ 'status': status.OK, 'body': { "id": player.id_player } })
def propose_mission(userid, members, lady=0): p = check_player(userid) members = json.loads(members) g.propose_mission(p, members, lady) return json_response({'status': status.OK, 'body': "Ok!"})
def abort_game(): global g g = game.Game(session) return json_response({'status': status.OK, 'body': "Ok!"})
def start_game(userid): p = check_player(userid) g.start(p) return json_response({'status': status.OK, 'body': "Ok!"})
def use_lady(userid, target): p = check_player(userid) return json_response({'status': status.OK, 'body': g.use_lady(p, target)})
def kill_merlin(userid, target): p = check_player(userid) g.assassinate(p, target) return json_response({'status': status.OK, 'body': "Ok!"})
def do_mission(userid, v): p = check_player(userid) g.do_mission(p, v) return json_response({'status': status.OK, 'body': "Ok!"})
def vote(userid, v): p = check_player(userid) g.vote(p, v) return json_response({'status': status.OK, 'body': "Ok!"})