Exemplo n.º 1
0
def getGameIdByOwlId(owl_id):
    db = get_db()
    game_id = None
    result = db.execute('SELECT id FROM game WHERE owl_id = ?', (owl_id,)).fetchone()
    if result:
        game_id = result[0]
    return game_id
Exemplo n.º 2
0
def insertGame(owl_id):
    # Initiate game & counters
    db = get_db()
    db.execute('INSERT INTO game (owl_id) VALUES (?)', (owl_id,))
    game_id = db.execute('SELECT last_insert_rowid()').fetchone()
    db.execute('INSERT INTO counters (game_id) VALUES (?)', (game_id[0],))
    db.commit()
    return game_id[0]
Exemplo n.º 3
0
def getMousePopulation(game_id):
    db = get_db()
    counters_mice_pop = db.execute('SELECT mousePopulation FROM counters WHERE game_id = ?', (game_id,)).fetchone()
    return counters_mice_pop[0]
Exemplo n.º 4
0
def getEndOfDay(game_id):
    db = get_db()
    counters_end_day = db.execute('SELECT endOfDay FROM counters WHERE game_id = ?', (game_id,)).fetchone()
    return counters_end_day[0]
Exemplo n.º 5
0
def getOwls():
    db = get_db()
    return db.execute('SELECT * FROM owl',).fetchall()
Exemplo n.º 6
0
def getOwlByGameId(game_id):
    db = get_db()
    owl = db.execute('SELECT o.* FROM game g            \
        JOIN owl o ON o.id = g.owl_id                   \
            WHERE g.id = ?', (game_id,)).fetchone()
    return owl
Exemplo n.º 7
0
def getOwlById(owl_id):
    db = get_db()
    return db.execute('SELECT * FROM owl WHERE id = ?', (owl_id,)).fetchone()
Exemplo n.º 8
0
def getOwlIdByName(nom):
    db = get_db()
    owl_id = db.execute('SELECT id FROM owl WHERE nom = ?', (nom,)).fetchone()
    return owl_id
Exemplo n.º 9
0
def updateMousePopulation(game_id, new_value):
    db = get_db()
    db.execute('UPDATE counters SET mousePopulation = ? WHERE game_id = ?', (new_value, game_id,))
    db.commit()
    return
Exemplo n.º 10
0
def updateDay(game_id, new_value):
    db = get_db()
    db.execute('UPDATE counters SET day = ? WHERE game_id = ?', (new_value, game_id,))
    db.commit()
    return
Exemplo n.º 11
0
def insertOwl(nom):
    db = get_db()
    db.execute('INSERT INTO owl (nom) VALUES (?)', (nom,))
    db.commit()
    owl_id = db.execute('SELECT last_insert_rowid()').fetchone()
    return owl_id[0]
Exemplo n.º 12
0
def updateOwlMiceCount(owl_id, new_value):
    db = get_db()
    db.execute('UPDATE owl SET mice = ? WHERE id = ?', (new_value, owl_id,))
    db.commit()
    return
Exemplo n.º 13
0
def updateLife(owl_id, new_value):
    db = get_db()
    db.execute('UPDATE owl SET life = ? WHERE id = ?', (new_value, owl_id,))
    db.commit()
    return