Exemplo n.º 1
0
def championstats(champion, role):
    champbuild = ChampionBuilds.query.filter_by(key=champion.capitalize(), role=role).first()
    champgen = ChampionGeneral.query.filter_by(key=champion.capitalize(), role=role).first()

    # If someone enters bad url directly like /champions/noob/top, redirect to champ landing
    if champbuild is None or champgen is None:
        error = "Champion or role for champion not found. Try another."
        champs = sorted(riotapi.get_champions(), key=lambda champion: champion.name)
        roles = ChampionGeneral.query.order_by(ChampionGeneral.key).all()
        return render_template('championlanding.html', error=error, champs=champs, roles=roles)

    # Items
    popularitems = champbuild.popularitems.split(",")
    winningitems = champbuild.winningitems.split(",")
    popstartitems = champbuild.popstartitems.split(",")
    winstartitems = champbuild.winstartitems.split(",")

    # Skills
    popularskills = champbuild.popularskills
    winningskills = champbuild.winningskills
    # Result is a string, which is already iterable letter by letter. No split needed.

    # Masteries
    popularmasteries = [x.split("-") for x in champbuild.popularmasteries.split(",")]
    winningmasteries = [x.split("-") for x in champbuild.winningmasteries.split(",")]
    # Makes list structured like [ [points, masteryid], [points, masteryid], ... ]

    # Runes
    popularrunes = [x.split("-") for x in champbuild.popularrunes.split(",")]
    winningrunes = [x.split("-") for x in champbuild.winningrunes.split(",")]
    # Makes list structured like [ [points, runeid], [points, runeid], ... ]

    poprunes = riotapi.get_runes(ids=[int(i[1]) for i in popularrunes])
    winrunes = riotapi.get_runes(ids=[int(i[1]) for i in winningrunes])

    print(poprunes)



    return render_template('championstats2.html',
                            str=str,
                            champbuild=champbuild,
                            champgen=champgen,
                            champion=champion,
                            len=len,
                            enumerate=enumerate,
                            popularitems=popularitems, winningitems=winningitems, popstartitems=popstartitems, winstartitems=winstartitems,
                            popularskills=popularskills, winningskills=winningskills,
                            popularmasteries=popularmasteries, winningmasteries=winningmasteries,
                            popularrunes=popularrunes, winningrunes=winningrunes, poprunes=poprunes, winrunes=winrunes)
    def _init_runes(all_runes=None):
        if not all_runes:
            all_runes = {rune.id: rune for rune in riotapi.get_runes()}
            RunePage._runes_by_id = {id_: Rune(data) for id_, data in all_runes.items()}
        else:
            RunePage._runes_by_id = all_runes

        RunePage._runes_by_name = {rune.name: rune for _, rune in RunePage._runes_by_id.items()}
Exemplo n.º 3
0
def test_runes():
    int_test_handler.test_result(riotapi.get_runes())
Exemplo n.º 4
0
def test_runes():
    int_test_handler.test_result(riotapi.get_runes())