Beispiel #1
0
def main():
    # Setup riotapi
    riotapi.set_region("NA")
    riotapi.print_calls(False)
    os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428"
    key = os.environ[
        "DEV_KEY"]  # 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(LoadPolicy.eager)

    # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.)
    # db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password")
    # riotapi.set_data_store(db)

    # Gather master names
    master = [entry.summoner for entry in riotapi.get_challenger()]
    print("Pulled Master tier. Got {0} summoners.".format(len(master)))

    gather_start = datetime(2016, 12, 26)
    gather_end = datetime(2016, 12, 27)
    for player in master:
        matches = player.match_list(begin_time=gather_start,
                                    end_time=gather_end)
        matchestoday = len(matches)
        print(matchestoday)

        for match in matches:
            for participant in match.participants:
                print(participant.champion.name)
Beispiel #2
0
def get_region(request):
	if request.method == 'POST':
		reg= request.POST.get("region")
	else:
		reg= "euw"
	riotapi.set_region(reg)
	riotapi.set_api_key(settings.RIOT_KEY)
	summoners = riotapi.get_challenger()
	return summoners
def main():
  riotapi.set_region("kr")
  riotapi.print_calls(True)
  riotapi.set_load_policy(LoadPolicy.lazy)

  riotapi.set_api_key("d045c326-dc9f-4de4-a463-793944aa6984")

  db = SQLAlchemyDB("mysql+mysqlconnector", "localhost", "kr_challenger_522", "root", "0123")
  riotapi.set_data_store(db)

  challenger = [entry.summoner for entry in list(riotapi.get_challenger()[1:10])]

  gather_start = datetime(2015, 11, 12) # 1 day after patch 5.19
  for summoner in challenger:
    for match in summoner.match_list(begin_time=gather_start):
      get_match(match)

  db.close()
Beispiel #4
0
def main():
    riotapi.set_region("kr")
    riotapi.print_calls(True)
    riotapi.set_load_policy(LoadPolicy.lazy)

    riotapi.set_api_key("d045c326-dc9f-4de4-a463-793944aa6984")

    db = SQLAlchemyDB("mysql+mysqlconnector", "localhost", "kr_challenger_522",
                      "root", "0123")
    riotapi.set_data_store(db)

    challenger = [
        entry.summoner for entry in list(riotapi.get_challenger()[1:10])
    ]

    gather_start = datetime(2015, 11, 12)  # 1 day after patch 5.19
    for summoner in challenger:
        for match in summoner.match_list(begin_time=gather_start):
            get_match(match)

    db.close()
Beispiel #5
0
def main():
    # Setup riotapi
    riotapi.set_region("NA")
    riotapi.print_calls(False)
    os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428"
    key = os.environ[
        "DEV_KEY"]  # 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(LoadPolicy.eager)

    # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.)
    # db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password")
    # riotapi.set_data_store(db)

    # Gather master names
    master = [entry.summoner for entry in riotapi.get_challenger()]
    mastertests = master
    print("Pulled Master tier. Got {0} summoners.".format(len(master)))

    #Make empty lists for match information
    matchid = []
    versionpatch = []
    matchdate = []
    maptype = []
    queue = []

    p_names = []
    p_sides = []
    p_champs = []
    p_lanes = []
    p_roles = []
    p_golds = []
    p_wins = []

    #Define a start date, and then for each player in the master list, get the match ID number
    gather_start = datetime(2016, 12, 28,
                            18)  # 1 day after patch 5.14, year month date
    for summoner in master:
        for match in summoner.match_list(begin_time=gather_start):
            # If you are connected to a database, the match will automatically be stored in it without you having to do anything.
            # Simply pull the match, and it's in your database for whenever you need it again!
            # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot
            # and therefore will not count against your rate limit. This is true of all datatypes, not just Match.
            match = get_match(match)
            print("Got {0}".format(match))

            #Then save the match information to some empty lists
            matchid.append(match.id)
            versionpatch.append(match.version)
            matchdate.append(match.creation)
            maptype.append(match.map)
            queue.append(match.queue)

            #Now make empty lists for the player information
            p1name = []
            p1side = []
            p1champ = []
            p1lane = []
            p1role = []
            p1gold = []
            p1win = []

            #Make a loop to get the rest of the participants
            for part in match.participants:
                p1name.append(part.summoner_name)
                p1side.append(part.side)
                p1champ.append(part.champion.name)
                p1lane.append(part.timeline.lane)
                p1role.append(part.timeline.role)
                p1gold.append(part.stats.gold_earned)
                p1win.append(part.stats.win)

            #Save information into the lists
            p_names.append(p1name)
            p_sides.append(p1side)
            p_champs.append(p1champ)
            p_lanes.append(p1lane)
            p_roles.append(p1role)
            p_golds.append(p1gold)
            p_wins.append(p1win)

    #db.close()

    filename = "master_data_28Dec2016.csv"
    columns = [
        'matchid', 'versionpatch', 'matchdate', 'maptype', 'queue', 'p_names',
        'p_sides', 'p_champs', 'p_lanes', 'p_roles', 'p_golds', 'p_wins'
    ]
    df = pd.DataFrame([
        matchid, versionpatch, matchdate, maptype, queue, p_names, p_sides,
        p_champs, p_lanes, p_roles, p_golds, p_wins
    ],
                      index=columns)

    df = df.T
    df.to_csv(filename)
Beispiel #6
0
def get_summoners():
    summoners = [entry.summoner for entry in riotapi.get_master(queue)]
    summoners.extend(
        [entry.summoner for entry in riotapi.get_challenger(queue)])

    return summoners
Beispiel #7
0
import random

from cassiopeia import riotapi

riotapi.set_region("BR")
riotapi.set_api_key("9bb95c2c-6d74-4b3b-911b-9fda01efc0db")



summoner = riotapi.get_summoner_by_name("Yarquen")
print("{name} is a level {level} summoner on the BR server." . format(name=summoner.name, level=summoner.level))

champions = riotapi.get_champions()
random_champion = random.choice(champions)
print("He enjoys playing LoL on all different champions, like {name}.".format(name=random_champion.name))

challenger_league = riotapi.get_challenger()
best_na = challenger_league[0].summoner
print("He's much better at writing Python code than he is at LoL. He'll never be as good as {name}.".format(name=best_na.name))
Beispiel #8
0
# http://cassiopeia.readthedocs.io/en/latest/setup.html#setting-additional-environment-variables

summoner = riotapi.get_summoner_by_name("Verciau")
print(
    "{name} is a level {level} summoner on the NA server. He rocks on these champs:"
    .format(name=summoner.name, level=summoner.level))

ranked = summoner.ranked_stats()

print("{name} has played {numChamps} champions this season.".format(
    name=summoner.name, numChamps=len(ranked)))

for entry in ranked.items():
    winRate = entry[1].wins / entry[1].games_played
    if winRate > 0.5:
        print("Champ: {champ} | Wins: {wins} | Games Played: {played}".format(
            champ=entry[0].name,
            wins=entry[1].wins,
            played=entry[1].games_played))

champions = riotapi.get_champions()
random_champion = random.choice(champions)
print("He enjoys playing LoL on all different champions, like {name}.".format(
    name=random_champion.name))

challenger_league = riotapi.get_challenger()
best_na = challenger_league[0].summoner
print(
    "He's much better at writing Python code than he is at LoL. He'll never be as good as {name}."
    .format(name=best_na.name))
Beispiel #9
0
def test_challenger():
    int_test_handler.test_result(riotapi.get_challenger())
Beispiel #10
0
from cassiopeia import riotapi
from cassiopeia.type.core.common import EventType

#if __name__ == "main":

riotapi.set_region("eune")
riotapi.set_api_key("RGAPI-75966C38-D2B1-4E8A-AF05-BDB617631C74")

summoner = riotapi.get_summoner_by_name("JoC Asuna")
print("{name} is a level {level} summoner on the EUNE server.".format(
    name=summoner.name, level=summoner.level))

challenger_league = riotapi.get_challenger(
)  #for player:challenger_league -> player.name

timestamps = []
player_names = []

#for every player
for player in challenger_league:
    #match_list = player.match_list()
    match_list = summoner.match_list(
    )  #replace this line with the upper modified
    #for every match of the last 2
    for match_idx in range(1, 2):
        match_ref = match_list[-match_idx]
        match = match_ref.match()
        #for every frame
        if match is not None:
            for frame in match.timeline.frames:
                for event in frame:
Beispiel #11
0
# In[2]:

riotapi.set_region("OCE")
riotapi.set_api_key("79428a9e-5d98-469b-9b9b-429c1a750d24")
riotapi.set_rate_limits((10, 10), (500, 600))
riotapi.print_calls(True)

client = MongoClient()
loladb = client.loladb_oce
summoners_collection = loladb.top_summoners
matches_collection = loladb.top_matches
matches_checked = loladb.top_matches_checked

if summoners_collection.count() == 0:
    #Save summoner information to mongodb
    challengers = riotapi.get_challenger()
    summoners_collection.insert_many([json.loads(entry.to_json()) for entry in challengers.data.entries])
    #masters = riotapi.get_master()
    #summoners_collection.insert_many([json.loads(entry.to_json()) for entry in masters.data.entries])


# In[4]:

print summoners_collection.count()
print matches_collection.count()


# In[39]:

#I'll try to find a small subset of players that we can find a lot of matches just between these players
#so we can use the adjusted plus/minus to analyze the player performance
Beispiel #12
0
def main():
    riotapi.set_region("NA")
    riotapi.set_api_key("94e831f6-ef9f-4823-81fc-cfc9342f4428")

    masters = [entry.summoner for entry in riotapi.get_challenger()]
    matches = dtr.Tree('Challenger_Patch6.24')
    matches.make()

    for master in masters[93:]:
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {champion}".format(champion=master.name))
        matchlist = master.match_list(begin_time=datetime(2016, 12, 7), end_time=datetime(2016, 12, 21))
        print(len(matchlist))

        for game in matchlist:
            match = game.match()
            path0 = matches[str(match.id) + '/']
            path0
            m0 = dtr.Treant(path0)
            m0.path

            m0.categories['MatchID'] = match.id
            m0.categories['VersionPatch'] = match.version
            m0.categories['Year'] = match.creation.year
            m0.categories['Month'] = match.creation.month
            m0.categories['Day'] = match.creation.day
            m0.categories['Hour'] = match.creation.hour
            m0.categories['Duration'] = str(match.duration)
            m0.categories['Map'] = str(match.map)
            m0.categories['Mode'] = str(match.mode)
            m0.categories['Type'] = str(match.type)
            m0.categories['Platform'] = str(match.platform)
            m0.categories['Queue'] = str(match.queue)
            m0.categories['Region'] = str(match.region)
            m0.categories['Season'] = str(match.season)
            m0.categories['Red Ban 1'] = [ban.champion.name for ban in match.red_team.bans][0]
            m0.categories['Red Ban 2'] = [ban.champion.name for ban in match.red_team.bans][1]
            if len([ban.champion.name for ban in match.red_team.bans]) > 2:
                m0.categories['Red Ban 3'] = [ban.champion.name for ban in match.red_team.bans][2]
            m0.categories['Blue Ban 1'] = [ban.champion.name for ban in match.blue_team.bans][0]
            if len([ban.champion.name for ban in match.blue_team.bans]) > 1:
                m0.categories['Blue Ban 2'] = [ban.champion.name for ban in match.blue_team.bans][1]
            if len([ban.champion.name for ban in match.blue_team.bans]) > 2:
                m0.categories['Blue Ban 3'] = [ban.champion.name for ban in match.blue_team.bans][2]

            p1 = []
            p1champ = []
            p1win = []
            p1side = []
            p1kills = []
            p1deaths = []
            p1assists = []
            p1kda = []
            p1cs = []
            p1spell1 = []
            p1spell2 = []
            p1level = []
            p1fb = []
            p1gold = []
            p1spent = []
            p1item1 = []
            p1item2 = []
            p1item3 = []
            p1item4 = []
            p1item5 = []
            p1item6 = []
            p1mdamage = []
            p1pdamage = []
            p1lane = []
            p1role = []

            for participant in match.participants:

                p1.append(participant.summoner_name)
                p1champ.append(participant.champion.name)
                p1win.append(participant.stats.win)
                p1side.append(participant.side)
                p1kills.append(participant.stats.kills)
                p1deaths.append(participant.stats.deaths)
                p1assists.append(participant.stats.assists)
                p1kda.append(participant.stats.kda)
                p1cs.append(participant.stats.cs)
                p1spell1.append(participant.summoner_spell_d)
                p1spell2.append(participant.summoner_spell_f)
                p1level.append(participant.stats.champion_level)
                p1fb.append(participant.stats.first_blood)
                p1gold.append(participant.stats.gold_earned)
                p1spent.append(participant.stats.gold_spent)
                items = [item.name if item is not None else None for item in participant.stats.items]
                p1item1.append(items[0])
                p1item2.append(items[1])
                p1item3.append(items[2])
                p1item4.append(items[3])
                p1item5.append(items[4])
                p1item6.append(items[5])
                p1mdamage.append(participant.stats.magic_damage_dealt)
                p1pdamage.append(participant.stats.physical_damage_dealt)
                p1lane.append(participant.timeline.lane)
                p1role.append(participant.timeline.role)


            columns = ['Player Name', 'Champion', 'Win', 'Side', 'Kills', 'Deaths', 'Assists', 'KDA', 'CS', 'SSpell 1', 'SSpell 2', 'End Level', 'First Blood?', 'Gold Earned', 'Gold Spent', 'Item1', 'Item2', 'Item3', 'Item4', 'Item5', 'Item6', 'Magic Dmg', 'Physical Dmg', 'Lane', 'Role']
            df = pd.DataFrame([p1, p1champ, p1win, p1side, p1kills, p1deaths, p1assists, p1kda, p1cs, p1spell1, p1spell2, p1level, p1fb, p1gold, p1spent, p1item1, p1item2, p1item3, p1item4, p1item5, p1item6, p1mdamage, p1pdamage, p1lane, p1role], index = columns)
            df = df.T

            m0.draw()
            m0['match.csv']
            filename = "match.csv"
            df.to_csv(m0[filename].abspath)
Beispiel #13
0
def test_challenger():
    int_test_handler.test_result(riotapi.get_challenger())
Beispiel #14
0
def top_players(request,region):
	riotapi.set_region(region)
	riotapi.set_api_key(settings.RIOT_KEY)
	summoners = riotapi.get_challenger()
	list_pages = pagination(request,summoners,5)
	return render(request,'top_players.html',{"listTopPlayers" : list_pages })