Exemplo n.º 1
0
def get_summary_data(game_id):
    d.execute(
        'select round.id, game, round, statement.text as "real", p.text as "fake" from round join statement on statement.id=round.regularStatement join statement p on round.falseStatement=p.id where game={}'
        .format(game_id))
    rs = d.fetchall()
    for r in rs:
        d.execute(
            "select player.id, player.name, player.alien, response.level as 'response' from response join player on player.id=response.player where round={} and player.alien=0"
            .format(r["id"]))
        r["humans"] = d.fetchall()

        d.execute(
            "select player.id, player.name, player.alien, response.level as 'response' from response join player on player.id=response.player where round={} and player.alien=1"
            .format(r["id"]))
        r["aliens"] = d.fetchall()

    return rs
Exemplo n.º 2
0
def get_game(game_id):
    d.execute("SELECT * FROM game WHERE code='{}'".format(game_id))
    return d.fetchone()
Exemplo n.º 3
0
def remove_code(game_id):
    d.execute("UPDATE game SET code=NULL WHERE id={}".format(game_id))
    conn.commit()
Exemplo n.º 4
0
def is_alien(pid):
    d.execute("SELECT alien FROM player WHERE id={}".format(pid))
    return d.fetchone()["alien"] == 1
Exemplo n.º 5
0
def get_members(game_id):
    d.execute("SELECT * FROM player WHERE game={}".format(game_id))
    return d.fetchall()
Exemplo n.º 6
0
def get_game_info(player_id):
    d.execute(
        "select * from game where id=(select game from player where id={})".
        format(player_id))
    return d.fetchone()
Exemplo n.º 7
0
def get_player_info(player_id):
    d.execute("SELECT * FROM player WHERE id={}".format(player_id))
    return d.fetchone()
Exemplo n.º 8
0
def get_category_questions():
    d.execute("SELECT * FROM statement")
    return d.fetchall()
Exemplo n.º 9
0
def get_question(qid):
    d.execute("SELECT * FROM statement WHERE id={}".format(qid))
    return d.fetchone()
Exemplo n.º 10
0
def get_round(rid, game):
    d.execute("SELECT * FROM round WHERE round={} AND game={}".format(rid, game))
    rs = d.fetchone()
    if rs is None:
        return new_round(rid, game)
    return rs
Exemplo n.º 11
0
def get_responses(rid):
    d.execute("select * from response join player on player.id=response.player where round={}".format(rid))
    return d.fetchall()
Exemplo n.º 12
0
def get_round_id(rid):
    d.execute("SELECT * FROM round WHERE id={}".format(rid))
    return d.fetchone()