Esempio n. 1
0
def get_top_champs_by_summoner(summoner,region,numberChamps):
	lista = riotapi.get_ranked_stats(summoner,season=None)
	dictionary = {}
	wins = []
	for key,value in lista.items():
		if str(key) != 'None':
			sumka = value.assists + value.kills
			wins.append(value.games_played)
			listData = [value.games_played,value.assists,value.kills,value.deaths,value.minions_killed,sumka]
			champ = riotapi.get_champion_by_name(str(key))
			dictionary[champ] = listData

	bestof = heapq.nlargest(numberChamps,wins)
	final = {}
	for item in bestof:
		for key,value in dictionary.items():
			if str(item) == str(value[0]):
				final[key] = value
	return final
Esempio n. 2
0
def test_ranked_stats():
    int_test_handler.test_result(riotapi.get_ranked_stats(riotapi.get_summoner_by_id(int_test_handler.summoner_id)))
def champion_stats( summoner ):
	statDict = riotapi.get_ranked_stats(summoner, season = None)
	return statDict
Esempio n. 4
0
def test_ranked_stats():
    int_test_handler.test_result(riotapi.get_ranked_stats(riotapi.get_summoner_by_id(int_test_handler.summoner_id)))
Esempio n. 5
0
def get_champion_stats(summoner):
    return riotapi.get_ranked_stats(summoner)
Esempio n. 6
0
import os
import datetime
from cassiopeia import riotapi
from cassiopeia import baseriotapi
from cassiopeia.type.core.common import LoadPolicy
import json
import heapq

riotapi.set_region("EUW")
riotapi.print_calls(False)
key = "deef6b4f-d2b2-49a1-8aaf-9128a2fc54e3"  # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here.
riotapi.set_api_key(key)
riotapi.set_load_policy("eager")

summoner = riotapi.get_summoner_by_name("bynikiyo")
lista = riotapi.get_ranked_stats(summoner,season=None)
dictionary = {}
wins = []
for key,value in lista.items():
	if str(key) != 'None':
		sumka = value.assists + value.kills
		wins.append(value.games_played)
		listData = [value.games_played,value.assists,value.kills,value.deaths,value.minions_killed,sumka]
		champ = riotapi.get_champion_by_name(str(key))
		dictionary[champ] = listData

bestof = heapq.nlargest(5,wins)
final = {}
for key,value in dictionary.items():
	for item in bestof:
		if str(item) == str(value[0]):
Esempio n. 7
0
def matchlistpage(zone, name):


    # Set region and after region is set, fetch latest API version, maybe move the version to a scheduled task if it uses a call.
    riotapi.set_region(zone)

    if zone in ['na', 'kr', 'euw', 'eune']:
        cassdb = SQLAlchemyDB(connector, host, dbnames[zone]+"?charset=utf8", user, passwd)
        riotapi.set_data_store(cassdb)

    print("======================")
    print(zone)
    print(name)
    print("======================")

    patch = riotapi.get_versions()[0]


    # Used to convert numerals to/from numbers
    romans =    {
                    'I': 1,
                    'II': 2,
                    'III': 3,
                  'IV': 4,
                  'V': 5
                }


    print("==========   DB MADE Trying to get summoner by name     ===========")
    # Get summoner
    s = riotapi.get_summoner_by_name(name)
    print("Summoner object:")
    print(s)
    print("id:{} name:{} level:{}".format(s.id, s.name, s.level))
    print("==========   GOT S, trying to get league entries     ===========")
    try:
        le = riotapi.get_league_entries_by_summoner(s)[0]
        entry = le.entries[0]
        print("Got league entries for ranked")
    except:
        print("Couldnt fetch le/entry. Perhaps unranked.")
        le = None
        entry = None
    print("==========   Trying to get ranked stats     ===========")
    try:
        stats = riotapi.get_ranked_stats(s, season=None)[None]
    except:
        print("Couldnt fetch ranked stats. Maybe not lv30/never did ranked.")
        stats = None
    print("==========   Trying to get matches     ===========")
    ml = riotapi.get_match_list(s, seasons=[x.value for x in Season][-1], num_matches=10)
    if ml is not None:
        matches = [][-10:]
        for x in ml:
            try:
                m_to_add = riotapi.get_match(x)
                matches.append(m_to_add)
            except exc.IntegrityError as ie:
                print("==SQL ERROR ---> {}".format(ie))
                print("==Python traceback==")
                print(traceback.print_exc())
                cassdb.session.rollback()
    else:
        matches = []



    print("==========   Trying to render template     ===========")


    return render_template('matchlist.html',
                            s = s,
                            entry = entry,
                            le = le,
                            matches = matches,
                            patch = patch,
                            stats = stats,
                            zone = zone,
                            round = round,
                            len = len,
                            romans = romans)
Esempio n. 8
0
def get_champion_stats( summoner ):
	return riotapi.get_ranked_stats(summoner)
def champion_stats(summoner):
    statDict = riotapi.get_ranked_stats(summoner, season=None)
    return statDict
Esempio n. 10
0
def ranked_champs():
    summoner_name = 'Sexchange Sally'
    summoner = riotapi.get_summoner_by_name(summoner_name)
    ranked = riotapi.get_ranked_stats(summoner=summoner, season=None)

    return ranked
Esempio n. 11
0
def matchlistpage(zone, name):


    # Set region & fetch latest api version
    riotapi.set_region(zone)

    # Set data store
    # *** REMOVED UNTIL CASSIOPEIA 2.0 ***

    patch = riotapi.get_versions()[0]


    # Roman->number conversion
    romans = {
        'I': 1,
        'II': 2,
        'III': 3,
        'IV': 4,
        'V': 5
    }


    # Get summoner
    s = riotapi.get_summoner_by_name(name)
    print("Summoner object: {}".format(s))
    print("ID: {} NAME: {} LEVEL: {}".format(s.id, s.name, s.level))

    # Get league entries
    try:
        le = riotapi.get_league_entries_by_summoner(s)[0]
        entry = le.entries[0]
        print("Got League entries for ranked")
    except:
        le = None
        entry = None
        print("Couldnt fetch le/entry. Perhaps unranked. Setting le and entry to None. Exception traceback:")
        print(traceback.print_exc())

    # Get ranked stats
    try:
        stats = riotapi.get_ranked_stats(s, season=None)[None]
        print("Got ranked stats")
    except:
        stats = None
        print("Couldnt fetch ranked stats. Perhaps not lv30 or never ranked. Setting stats to None. Exception traceback:")
        traceback.print_exc()

    # Get matches
    # *** DISABLED. PAGE WILL ONLY CHECK IF IN CURRENT GAME THROUGH JAVASCRIPT THEN OFFER CURRENTGAME BUTTON ***


    print("===== RENDERING TEMPLATE =====")

    return render_template('matchlist2.html',
                            s = s,
                            entry = entry,
                            le = le,
                            patch = patch,
                            stats = stats,
                            zone = zone,
                            round = round,
                            len = len,
                            romans = romans)