Exemple #1
0
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)})
Exemple #2
0
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!"})
Exemple #3
0
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)
    })
Exemple #4
0
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
        }
    })
Exemple #5
0
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!"})
Exemple #6
0
def abort_game():
    global g
    g = game.Game(session)
    return json_response({'status': status.OK, 'body': "Ok!"})
Exemple #7
0
def start_game(userid):
    p = check_player(userid)
    g.start(p)
    return json_response({'status': status.OK, 'body': "Ok!"})
Exemple #8
0
def use_lady(userid, target):
    p = check_player(userid)

    return json_response({'status': status.OK, 'body': g.use_lady(p, target)})
Exemple #9
0
def kill_merlin(userid, target):
    p = check_player(userid)
    g.assassinate(p, target)

    return json_response({'status': status.OK, 'body': "Ok!"})
Exemple #10
0
def do_mission(userid, v):
    p = check_player(userid)
    g.do_mission(p, v)

    return json_response({'status': status.OK, 'body': "Ok!"})
Exemple #11
0
def vote(userid, v):
    p = check_player(userid)
    g.vote(p, v)

    return json_response({'status': status.OK, 'body': "Ok!"})