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
def show_parties(id): party = party_repository.select(id) players = party_repository.players(id) characters = party_repository.characters(id) num_of_players = len(party_repository.players(party.id)) average_level = party_repository.party_level(id) lowest_armour = party_repository.lowest_armour(id) all_contacts = party_repository.all_contact(id) highest_perception = party_repository.highest_perception(id) highest_insight = party_repository.highest_insight(id) total_weight = party_repository.total_weight(id) magic_percent = party_repository.party_magic_compare(id) return render_template("/parties/show.html", party=party, players=players, characters=characters, num_of_players=num_of_players, average_level=average_level, lowest_armour=lowest_armour, all_contacts=all_contacts, highest_perception=highest_perception, highest_insight=highest_insight, total_weight=total_weight, magic_percent=magic_percent)
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)
def edit_party(id): party = party_repository.select(id) return render_template("/parties/edit.html", party=party)
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)