def show_player(id):
    player = player_repository.select(id)
    parties = player_repository.parties(id)
    characters = player_repository.characters(id)
    return render_template("/players/show.html",
                           player=player,
                           parties=parties,
                           characters=characters)
def select(id):
    character = None
    sql = "SELECT * FROM characters WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]
    player = player_repository.select(result["player_id"])
    party = party_repository.select(result["party_id"])

    if result is not None:
        character = Character(result['name'], result['race'], result['archetype'], result['level'], result['armour'], result['magic'], result['weight'], result['perception'], result['insight'], result['immunity'], result['vision'], result['language'], result['aura'], result['enmity'], result['exhaustion'], player, party, result['id'])
    return character
def characters(id):
    player_characters = []
    sql = "SELECT characters.* FROM characters WHERE player_id = %s"
    values = [id]
    results = run_sql(sql, values)
    for result in results:
        player = player_repository.select(id)
        party = party_repository.select(result['party_id'])
        character = Character(result['name'], result['race'], result['archetype'], result['level'], result['armour'], result['magic'], result['weight'], result['perception'], result['insight'], result['immunity'], result['vision'], result['language'], result['aura'], result['enmity'], result['exhaustion'], player, party, result['id'])
        player_characters.append(character)
    return player_characters
def select_all():
    characters = []

    sql = "SELECT * FROM characters"
    results = run_sql(sql)

    for result in results:
        player = player_repository.select(result["player_id"])
        party = party_repository.select(result["party_id"])
        character = Character(result['name'], result['race'], result['archetype'], result['level'], result['armour'], result['magic'], result['weight'], result['perception'], result['insight'], result['immunity'], result['vision'], result['language'], result['aura'], result['enmity'], result['exhaustion'], player, party, result['id'])
        characters.append(character)
    return characters
Пример #5
0
def update_character(id):
    name = request.form["name"]
    race = request.form["race"]
    archetype = request.form["archetype"]
    level = request.form["level"]
    armour = request.form["armour"]
    magic = request.form["magic"]
    weight = request.form["weight"]
    perception = request.form["perception"]
    insight = request.form["insight"]
    immunity = request.form["immunity"]
    vision = request.form["vision"]
    language = request.form["language"]
    aura = request.form["aura"]
    enmity = request.form["enmity"]
    exhaustion = request.form["exhaustion"]
    player_id = request.form["player_id"]
    party_id = request.form["party_id"]
    player = player_repository.select(player_id)
    party = party_repository.select(party_id)
    character = Character(name, race, archetype, level, armour, magic, weight, perception, insight, immunity, vision, language, aura, enmity, exhaustion, player, party, id)
    character_repository.update(character)
    return show_characters(character.id)
Пример #6
0
def show_characters(id):
    character = character_repository.select(id)
    player = player_repository.select(character.player.id)
    party = party_repository.select(character.party.id)
    return render_template("/characters/show.html", character=character, player=player, party=party)
def edit_player(id):
    player = player_repository.select(id)
    return render_template("/players/edit.html", player=player)