def getSquareRuneAsset(conn, runeId): api = RiotAPI(api_key) runeData = {} if conn: runeData = requestLocalRuneData(conn) tree = isTree(runeId, runeData) return api.get_square_rune_asset(runeId, runeData, tree)
def get_role_data(champ_id_list): api=RiotAPI(API_KEY) champ_data = api.get_champion_tags().json()['data'] role_dict={'Assassin':[], 'Marksman':[], 'Mage':[], 'Support':[], 'Tank':[], 'Fighter':[]} for value in champ_data.itervalues(): role_dict[value['tags'][0]].append(value['id']) return role_dict
def get_champ_id_list(): api=RiotAPI(API_KEY) champ_data = api.get_champion().json()['data'] champ_id_list = [value['id'] for value in champ_data.itervalues()] champ_names_by_id ={value['id']: key for key,value in champ_data.iteritems()} champ_id_by_name = {value: key for key,value in champ_names_by_id.iteritems()} return champ_id_list, champ_names_by_id, champ_id_by_name
def main(): api = RiotAPI('RGAPI-50243412-7c12-4043-844c-77773a52e424') name = 'MonkaS Gun Kelly' r = api.get_summoner_by_name(name) Matchs = api.get_matchs(r['accountId']) lista_matchs = Matchs['matches'] mid = 0 bot = 0 jungler = 0 top = 0 none = 0 for a in range(len(lista_matchs)): #print lista_matchs[a]['lane'] if lista_matchs[a]['lane'] == 'TOP': top = top + 1 elif lista_matchs[a]['lane'] == 'JUNGLE': jungler = jungler + 1 elif lista_matchs[a]['lane'] == 'MID': mid = mid + 1 elif lista_matchs[a]['lane'] == 'BOTTOM': bot = bot + 1 elif lista_matchs[a]['lane'] == 'NONE': none = none + 1 print "Hola", name print "Tu nivel es ", r['summonerLevel'] print "Has jugado de top", top, "veces en las ultimas 100 partidas" print "Has jugado de jungler", jungler, "veces en las ultimas 100 partidas" print "Has jugado de mid", mid, "veces en las ultimas 100 partidas" print "Has jugado de bot", bot, "veces en las ultimas 100 partidas" print "No se ha identificado el rol en:", none, "situaciones"
def main(): api = RiotAPI('YOUR API KEY HERE!') res = api.get_summoner_by_name('streetjustlce') ID = (res['streetjustlce']['id']) res2 = api.stats_by_summoner_summary(ID) print((res2['playerStatSummaries'][-2]["wins"]) / (res2['playerStatSummaries'][-2]["losses"]))
def main(): api = RiotAPI("""< Riot API Key >""") sn = api.get_summoner_by_name('SpookyDaMoose') print(sn) r = api.get_champion_ids() database = ChampDatabase(r) matrix = database.populateChampMatrix(r)
def _parse_items(items, csv_data, champidx, pop_items, itemDict): #trinket not taken into consideration api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') item1 = items['item0'] item2 = items['item1'] item3 = items['item2'] item4 = items['item3'] item5 = items['item4'] item6 = items['item5'] itemList = [item1, item2, item3, item4, item5, item6] for item in itemList: #make sure an item is there if item == 0: continue #get item data cur_item = item_cache.find(item) if cur_item is False: cur_item = api.get_item_by_id(item, {'itemData': 'stats'}) if cur_item is False: return csv_data #iterate through item stats for key, value in cur_item['stats'].items(): data_col = Consts.STAT_TO_MATRIX[key] csv_data[champidx, data_col] += value item_cache.place(item, cur_item) #put item in item dict unless no itemDict if itemDict is False: return csv_data name = _get_name(champidx) item_dict = pop_items[name] if item not in item_dict: item_dict[item] = 1 else: item_dict[item] += 1 return csv_data
def main(): # definitions api = RiotAPI('3e888957-13a3-4ba2-901c-fae3e421d998') # get reference data with open('itemReference.json', 'r') as data_file: itemRef = json.load(data_file) with open('championReference.json', 'r') as data_file: championRef = json.load(data_file) # get match ids matchIdLocation = '/home/lenneth/Documents/RiotAPI project/json data/5.11/NORMAL_5X5/NA.json' with open(matchIdLocation, 'r') as data_file: matchIds = json.load(data_file) #pprint(matchIds[:10]) for matchId in matchIds[:10]: data = api.get_match(matchId) # write the data into a file so its not needed # to access the API all the time #with open('matchReference14.json', 'w') as outfile: #json.dump(r, outfile, indent=4) # check if match is valid or not if(mParser.matchValid(data, itemRef) == False): print('ahhh') else: # this writes to file as well mParser.makeParticipantDictionaries(data, itemRef, championRef)
def getGameInfos(matchList, apiNumber): api = RiotAPI(apiNumber) gameList = [] for number in matchList: matchInfo = api.get_matchInfo(number) gameList = gameList + [[number, matchInfo]] return gameList
def make_spells_dict(): champ_dict = {} api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') champs = api.get_all_champs() for champ in champs['data'].keys(): champ_dict[champ] = {} return champ_dict
def getData(player_name): api2 = RiotAPI() api2.api_key = 'aa7ee812-3a61-47c1-8ddf-357cd4eef032' api2.region = 'na' response = api2.get_summoner_by_name(player_name) try: for key in response.keys(): try: account_name = key except: print("ERROR ACCOUNT NAME DOES NOT EXIST, EXITING") print("ERROR 2") exit() except: print("ERROR SUMMONER DOES NOT EXIST, EXITING") print("ERROR 1") exit() summonerId = response[account_name]["id"] games = api2.games_by_summoner(summonerId) fileExt = str("/Users/Ben/Documents/"+player_name+"_games.txt") myfile = open(fileExt,"w") json.dump((games),myfile)
def rank(self, message): self.send_typing(message.channel) player = self.get_player(message) username = player[0] region = player[1] if region.upper() not in self.regions: self.send_message(message.channel, 'Invalid region') return None riot = RiotAPI(self.riot_key, region) if username == "me": username = message.author.name try: rank = riot.get_summoner_rank("".join(username.split(" "))) to_return = "The summoner {username} is ranked {tier} {division} and currently has {LP} LPs. (S6 winrate: {winrate})".format( username=username, tier=rank[0].capitalize(), division=rank[1], LP=str(rank[2]), winrate=str(rank[3]) + "%") except (ValueError, KeyError): try: level = riot.get_summoner_level("".join(username.split(" "))) to_return = "The summoner {username} is unranked and is level {level}.".format( username=username, level=str(level)) except: to_return = "The summoner {username} does not exist or is not on the {region} server.".format( username=username, region=region) self.send_message(message.channel, to_return)
def main() : api = RiotAPI('RGAPI-e6af808d-ed47-4403-b09d-43dadba22b80') tmp = api.test() print("in main.js") print(tmp)
def _parse_items(items, csv_data, champidx, pop_items, itemDict): #trinket not taken into consideration api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') item1 = items['item0'] item2 = items['item1'] item3 = items['item2'] item4 = items['item3'] item5 = items['item4'] item6 = items['item5'] itemList = [item1, item2, item3, item4, item5, item6] for item in itemList: #make sure an item is there if item == 0: continue #get item data cur_item = item_cache.find(item) if cur_item is False: cur_item = api.get_item_by_id(item, {'itemData': 'stats'}) if cur_item is False: return csv_data #iterate through item stats for key, value in cur_item['stats'].items(): data_col = Consts.STAT_TO_MATRIX[key] csv_data[champidx, data_col]+= value item_cache.place(item, cur_item) #put item in item dict unless no itemDict if itemDict is False: return csv_data name = _get_name(champidx) item_dict = pop_items[name] if item not in item_dict: item_dict[item] = 1 else: item_dict[item] += 1 return csv_data
def main(): # definitions api = RiotAPI('3e888957-13a3-4ba2-901c-fae3e421d998') # get reference data with open('itemReference.json', 'r') as data_file: itemRef = json.load(data_file) with open('championReference.json', 'r') as data_file: championRef = json.load(data_file) # get match ids matchIdLocation = '/home/lenneth/Documents/RiotAPI project/json data/5.11/NORMAL_5X5/NA.json' with open(matchIdLocation, 'r') as data_file: matchIds = json.load(data_file) #pprint(matchIds[:10]) for matchId in matchIds[:10]: data = api.get_match(matchId) # write the data into a file so its not needed # to access the API all the time #with open('matchReference14.json', 'w') as outfile: #json.dump(r, outfile, indent=4) # check if match is valid or not if (mParser.matchValid(data, itemRef) == False): print('ahhh') else: # this writes to file as well mParser.makeParticipantDictionaries(data, itemRef, championRef)
def updateSquareItemAssetsAll(): api = RiotAPI(api_key) itemData = api.get_item_data() for itemId in itemData['data']: api.get_square_item_asset(itemId, itemData) return
def getDetailedMatchData(matchList): api = RiotAPI(api_key) detailedMatchData = {} for game in matchList: print("requesting offsite data") gameId = game['gameId'] detailedMatchData[gameId] = api.get_match_info(gameId) return detailedMatchData
def getMatchList(accountId, queueNumber=None, startIndex=0, endIndex=100): api = RiotAPI(api_key) args = {'beginIndex' : startIndex, 'endIndex' : endIndex} if queueNumber: args['queue'] = queueNumber fullMatchDataAll = api.get_match_list(accountId, args) matchList = fullMatchDataAll['matches'] return matchList
def _fill_champ_id_range(csv_data, data_col_base): #fill out champ ids and attack range api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') champs = api.get_all_champs({'champData': 'stats'}) for col in range(csv_data.shape[0]): name = _get_name(col) csv_data[col][0] = champs['data'][name]['id'] csv_data[col][data_col_base + Consts.VARIABLE_TO_MATRIX['atk_range']] = champs['data'][name]['stats']['attackrange']
def free_champs(self, message): self.send_typing(message.channel) riot = RiotAPI(self.riot_key) free_champs = riot.get_free_champions() to_send = "The free champions this week are {champions} and {last}.".format( champions=", ".join(free_champs[0:len(free_champs) - 1]), last=free_champs[len(free_champs) - 1]) self.send_message(message.channel, to_send)
def updateSquareChampionAssetsAll(): api = RiotAPI(api_key) championData = api.get_champ_data() for name in championData['data']: championId = championData['data'][name]['key'] api.get_square_champ_asset(championId, championData) return
def updateSquareSsAssetsAll(): api = RiotAPI(api_key) ssData = api.get_ss_data() for spellName in ssData['data']: spellId = ssData['data'][spellName]['key'] api.get_square_ss_asset(spellId, ssData) return
def updateSquareRuneAssetsAll(): api = RiotAPI(api_key) runeData = api.get_rune_data() for key, runeTrees in runeData.items(): isTree = False if key == 'trees': isTree = True for runeId in runeTrees: api.get_square_rune_asset(runeId, runeData, isTree)
def load_api_name(name, region): api = RiotAPI(API_KEY_HERE, Consts.REGIONS[region]) name_request = api.get_summoner_by_name(name) if ("status" in name_request.text): print("Summoner not found, re-enter information or quit") name, region = get_name_region() load_api_name(name, region) info = json.loads(name_request.text) return api, info["id"]
def free_champs(self, message): self.send_typing(message.channel) riot = RiotAPI(self.riot_key) free_champs = riot.get_free_champions() to_send = "The free champions this week are {champions} and {last}.".format( champions=", ".join(free_champs[0:len(free_champs) - 1]), last=free_champs[len(free_champs) - 1] ) self.send_message(message.channel, to_send)
def getMatchList(args): api = RiotAPI(api_key) accountId = args.pop('accountId') #prevents API request from submitting a bad URL if not args['queue']: del args['queue'] fullMatchDataAll = api.get_match_list(accountId, args) return fullMatchDataAll
def add_summoner(summoner_name, c): api = RiotAPI(API_KEY) try: response = api.get_summoner_by_name(summoner_name) if response.status_code != 200: raise Exception("Status code:" + str(response.status_code)) seed_id = response.json()[summoner_name]['id'] c.execute("insert into summoner_ids values (?,0)", (seed_id,)) except Exception as e: print 'Exception', e
def _fill_champ_id_range(csv_data, data_col_base): #fill out champ ids and attack range api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') champs = api.get_all_champs({'champData': 'stats'}) for col in range(csv_data.shape[0]): name = _get_name(col) csv_data[col][0] = champs['data'][name]['id'] csv_data[col][data_col_base + Consts.VARIABLE_TO_MATRIX['atk_range']] = champs['data'][ name]['stats']['attackrange']
def main(): # THIS CODE IS RUN ONE TIME ONLY api = RiotAPI('3e888957-13a3-4ba2-901c-fae3e421d998') r = api.get_match(1900729148) #r = api.get_itemList() # write the data into a file so its not needed # to access the API all the time with open('matchReference14.json', 'w') as outfile: json.dump(r, outfile, indent=4)
def sortMatchesByPartnerOld(matchList, Partner, apiNumber): api = RiotAPI(apiNumber) positiveCriterium = [] negativeCriterium = [] for number in matchList: names = api.get_summoner_of_match(number) flattenedNames = [value for sublist in names for value in sublist] if Partner in flattenedNames: positiveCriterium = positiveCriterium + [number] else: negativeCriterium = negativeCriterium + [number] return [positiveCriterium, negativeCriterium]
def main(): api = RiotAPI('RGAPI-7937d1e9-ed86-4f57-bc41-da3f528e2674') r = api.get_match_id('2787975451') # Sub dictionaries that contain the information we want playerData = r['participantIdentities'] matchData = r['participants'] dataDF = participantIdentities(playerData, matchData) dataDF = dataDF[Consts.IDEAL_LIST_ORDER] dataDF.to_csv('match.csv', index=False)
def main(): api = RiotAPI('a14bbd5a-586a-469d-97dd-9beddfd95e2b') #my old key res = api.get_summoner_by_name('streetjustlce') #result of summoner by name func print (type(res)) #should be a dictionary print(res) #is the summoner info dictionary ID = (res['streetjustlce']['id']) #summoner id found from res print(ID) #actual res2 = api.stats_by_summoner_summary(ID) #result of the stats by summoner func, used ID found earlier! print(type(res2)) #should once again be a dictionary #print(res2) #this is a HUGE dictionary, much easier to see what is returned by looking at the Riot dev website! print((res2['playerStatSummaries'][-2]["wins"]) / (res2['playerStatSummaries'][-2]["losses"]))
def main(): #apikey api = RiotAPI('6a4f80c7-39db-45df-b5eb-5357f54d8c80') print('please enter a summoner name to lookup!') #summoners name summoner_name = raw_input('>> ') #pulls basic info about the summoners name like ID r = api.get_summoner_by_name(summoner_name) #summoners id summoner_id = r[summoner_name]['id'] #concatenates id to a string ID = str(summoner_id) print ID #pulls stats from a players ranked games r_stats = api.get_summoner_ranked_stats(ID) """ looks up the whole json file of the summoners league you can request to look up ['tier'](bronze, silver, gold, etc) or you can see the bracket['queue'] """ summoner_league_lookup = api.get_summoner_league(summoner_id) #looks up what bracket the summoner is queueing in queue_bracket = summoner_league_lookup[ID][0]['queue'] #Styalizes the output to something nicer if queue_bracket == 'RANKED_SOLO_5x5': queue_bracket = 'Solo Queue' #loops through players stats of the ranks season and pulls all the champions into ids then turns the id into a name and looks up the total pentakills achived on a champion this season for c in r_stats['champions']: print "Champion " + champs[c['id']] + "'s Number of PentaKills " + str( c['stats']['totalPentaKills']) #Asks user if they'd like to search again print "Look up another person> Yes or No" check = raw_input('>> ') if check == 'Yes': main() elif check == 'yes': main() elif check == 'YES': main() else: print "Thanks for searching! "
async def gameranks(self, message): await self.send_typing(message.channel) player = self.get_player(message) username = player[0] region = player[1] if region.upper() not in self.regions: await self.send_message(message.channel, 'Invalid region') return None if username in ["me", '']: if message.author.id in self.aliases: username, region = self.aliases[message.author.id] else: username = message.author.name riot = RiotAPI(self.riot_key, region) ranks = riot.get_game_ranks("".join(username.split(" "))) if not ranks: await self.send_message( message.channel, "The summoner {username} is " "not currently in a game or does not exist.".format( username=username)) return None to_send = "" #"**Red team**:\n" for player in ranks: if ranks.index(player) == len(ranks) / 2: await self.send_message(message.channel, "", embed=discord.Embed( title="Red team", description=to_send, color=discord.Colour.dark_red())) to_send = "" #"\n**Blue team**:\n" if player[2] == "unranked": to_send += "{name} (**{champion}**): Unranked\n".format( name=player[0], champion=player[1]) else: to_send += "{name} (**{champion}**): {tier} {division}\n".format( name=player[0], champion=player[1], tier=player[2].capitalize(), division=player[3]) await self.send_message(message.channel, "", embed=discord.Embed( title="Blue team", description=to_send, color=discord.Colour.dark_blue()))
def champion(request): context = {} championKey = request.GET.get('championName', None) summonerName = request.GET.get('summonerName', None) region = request.GET.get('region', None) if not summonerName or not region or not championKey: #TODO: ADD ERROR PAGE(?) print 'error' return render(request, 'templates/main.html') else: api = RiotAPI(RiotConstants.API_KEY, region) championName = api.getChampionNameByKey(championKey) context['summonerName'] = summonerName summonerName = summonerName.replace(' ','') summonerId = api.getSummonerByName(summonerName)[summonerName.lower()]['id'] championId = api.getChampionId(championName) context['championMasteryFor5'] = RiotConstants.MASTERY_POINTS[5] context['championName'] = championName context['region'] = region context['champion'] = api.getChampionMastery(summonerId, championId) context['championImage'] = api.getChampionBackgroundImage(championKey) # creating a list of champions for dropdown in champion search bar. championListOrdered = [] for k,v in api.getChampionListByName().items(): championListOrdered.append([v['name'],v['key']]) championListOrdered.sort() context['orderedChampionList'] = championListOrdered return render(request,'templates/champion.html', context)
def _parse_runes(runes, csv_data, champidx): api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') for rune in runes: runeId = rune['runeId'] cur_rune = rune_cache.find(runeId) if cur_rune is False: cur_rune = api.get_rune_by_id(runeId, {'runeData': 'stats'}) if cur_rune is False: return csv_data for key, value in cur_rune['stats'].items(): data_col = Consts.STAT_TO_MATRIX[key] csv_data[champidx][data_col] += value * rune['rank'] rune_cache.place(runeId, cur_rune) return csv_data
def main(): api = RiotAPI(mykey) choice = raw_input("Input 1 for summoner name or 2 for champion lore \n") if choice=='1': myname = raw_input("Input summoner name, no caps \n") r = api.get_summoner_by_name(myname) #myid = r[myname]['id'] print r elif choice=='2': champion_name = raw_input("Input champion name \n") r = api.get_champion_data() print r['data'][champion_name]['lore'] else: main()
def Get_LastMatch_KDA(Summoner_Name): api = RiotAPI(API_key) r3 = api.get_match_by_matchID(lines[int(Consts.PLAYER_INDEX[Summoner_Name])][1]) print(r3["participantIdentities"][6]["player"]["summonerName"]) for index in range(9): if r3["participantIdentities"][index]["player"]["summonerName"] == Summoner_Name: pID = r3["participantIdentities"][index]["participantId"] K = r3["participants"][pID-1]["stats"]["kills"] D = r3["participants"][pID-1]["stats"]["deaths"] A = r3["participants"][pID-1]["stats"]["assists"] Score = (K + A)/max(D,1) print("Summoner: " + Summoner_Name + ", KDA: " + str(K) + "/" + str(D) + "/" + str(A) + ", Score: " + str(Score)) else: return
def sortMatchesByPartner(matchList, Partner, apiNumber): #assumes you don't have the matchInfo yet api = RiotAPI(apiNumber) positiveCriterium = [] negativeCriterium = [] for number in matchList: matchInfo = api.get_matchInfo(number) summonerNames = [] for var in matchInfo['participantIdentities']: summonerNames = summonerNames + [var['player']['summonerName']] if Partner in summonerNames: positiveCriterium = positiveCriterium + [[number, matchInfo]] else: negativeCriterium = negativeCriterium + [[number, matchInfo]] return [positiveCriterium, negativeCriterium]
def main(): summoner_name = "Snow Eater" api = RiotAPI(summoner_name, 'RGAPI-d46320fe-7ca6-4d00-9976-7fc3d3cbc9b4') #result = api.get_summoner_by_name('Pedobabar') #result = api.get_my_jungle_ennemi() #get_jungler_featured_game() #Permet presque a coup sur de trouver une game en normal match_info_jungler = api.get_jungler_featured_game() print match_info_jungler jungler = api.get_summoner_by_name(match_info_jungler['summonerName']) print jungler result = api.get_matchlist_by_account(jungler['accountId'], match_info_jungler['championId']) print result
def collect_champions(api_key): csvfile = 'champions_data.csv' output = open(csvfile,'a') api = RiotAPI(api_key) r = api.get_champion_list() while r is None or r.get('data') is None : r = api.get_champion_list() print(r.get('data')) for champion in r.get('data'): temp = r.get('data')[champion] c = [temp.get('name'),temp.get('id')] writer = csv.writer(output, lineterminator='\n') writer.writerow(c) output.close()
def main(): for region in REGIONS: try: api_client = RiotAPI(API_KEY, region=region) except NameError as e: print e sys.exit(1) match_req_api = ["match"] for patch in PATCHES: for queueType in QUEUETYPES: input_path = INPUT_PATH_BASE.format(patch=patch, queueType=queueType, region=region) with open(input_path, 'r') as fp: input_matches = json.load(fp) total_count = len(input_matches) batch_count = total_count / MATCHES_PER_FILE print "{} input matches".format(len(input_matches)) print "with {} matches per file, there will be {} batches".format(MATCHES_PER_FILE, batch_count) for fileindex in range(batch_count): combined_resp = {} for sequence in range(MATCHES_PER_FILE): match_index = (fileindex * MATCHES_PER_FILE) + sequence match_id = "{}".format(input_matches[match_index]) print "calling match api on id {}".format(match_id) match_req_ids = {"matchId": match_id, "includeTimeline": "true"} req = Request(match_req_api, match_req_ids) try: resp = api_client.call(req) except Exception as e: print e sys.exit(1) combined_resp["sequence{}".format(sequence)] = resp output_path = OUTPUT_PATH_BASE.format(patch=patch, queueType=queueType, region=region, filepatch=patch.replace(".", ""), filequeue=QUEUETYPES[queueType], fileregion=region.lower(), fileindex=fileindex) print "dumping to {}".format(output_path) with open(output_path, 'w') as fp: json.dump(combined_resp, fp) print "done" sys.exit(0)
def third_main(): #np.set_printoptions(threshold=np.inf) api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') api_euw = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2', Consts.REGIONS['europe_west']) api_eune = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2', Consts.REGIONS['europe_nordic_and_east']) api_kr = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2', Consts.REGIONS['korea']) #loading the NA match ids #data = json.loads(open('./BILGEWATER/EUW.json').read()) #data += json.loads(open('./BILGEWATER/EUW.json').read()) data = json.loads(open('./BILGEWATER/NA.json').read()) pop_spells = make_spells_dict() match_num = 1 for matchid in data: if match_num > 700: break print("On match number " + str(match_num)) #if match_num <= 10000: #print(matchid) #match = api_euw.get_match_info(matchid, {'includeTimeline': True}) #else: match = api.get_match_info(matchid, {'includeTimeline': True}) if match is False or match['matchDuration'] < 1000: print("Broken Match") continue for champ in match['participants']: #get champ id and name championID = champ['championId'] champ_name = champion_cache.find(championID) if champ_name is False: champ_name = api.get_champ_by_id(championID)['key'] champion_cache.place(championID, champ_name) #combination so it does not matter which order summoner spells are chosen spell1id = champ['spell2Id'] + champ['spell1Id'] spell2id = champ['spell1Id'] * champ['spell2Id'] if champ['spell2Id'] in pop_spells[champ_name]: pop_spells[champ_name][champ['spell2Id']] += 1 else: pop_spells[champ_name][champ['spell2Id']] = 1 if champ['spell1Id'] in pop_spells[champ_name]: pop_spells[champ_name][champ['spell1Id']] += 1 else: pop_spells[champ_name][champ['spell1Id']] = 1 #print(pop_spells) #add to team list match_num+=1 with open('spell_dict.json', 'w') as fp: json.dump(pop_spells, fp)
def index_post(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): api = RiotAPI(Consts.DEVKEY) input_text = form.openid.data input_text = input_text.lower() processed_text = input_text.replace(" ", "") summonername = {'name': processed_text} apicall = api.get_summoner_by_name(summonername['name']) if apicall[0] != 200: error = apicall[0] if error == 404: msg = "Summoner does not exist!" else: msg = "Error " + str(error) + ". Oops!" return render_template("index_error.html", form=form, error=msg) summonerdata = apicall[1] summonerlevel = summonerdata[summonername['name']]['summonerLevel'] summonerid = summonerdata[summonername['name']]['id'] summonerrank = api.get_summoner_rank(summonerid)[1] outputname = summonerdata[summonername['name']]['name'] if summonerlevel < 30: msg = "Summoner is not level 30 yet!" return render_template("index_error.html", form=form, error=msg) if summonerrank == 0: msg = "Summoner is unranked!" return render_template("index_error.html", form=form, error=msg) outputtier = summonerrank[str(summonerid)][0]['tier'] outputdivision = summonerrank[str(summonerid)][0]['entries'][0]['division'] outputlp = str(summonerrank[str(summonerid)][0]['entries'][0]['leaguePoints']) return render_template("index.html", form=form, name=outputname, tier=outputtier, division=outputdivision, lp=outputlp) else: return render_template("index_blank.html", form=form)
def main(): #The api key is not hardcoded because it should not be publicly available on github api_key = input('Enter API key: ') print('') api = RiotAPI(api_key) champData = api.get_all_champions()['data'] champList = [] for item in champData.keys(): champList.append((champData[item]['id'],champData[item]['key'])) write_champs('champions.json',champList) avatardir = os.path.dirname(os.path.abspath(__file__))+"/portraits/" if not os.path.exists(avatardir): os.makedirs(avatardir) for item in champList: portrait = api.get_champion_portrait(item[1]) write_portrait("portraits/"+str(item[0])+".png",portrait)
def gameranks(self, message): self.send_typing(message.channel) player = self.get_player(message) username = player[0] region = player[1] if region.upper() not in self.regions: self.send_message(message.channel, 'Invalid region') return None if username == "me": username = message.author.name riot = RiotAPI(self.riot_key, region) ranks = riot.get_game_ranks("".join(username.split(" "))) if not ranks: self.send_message(message.channel, "The summoner {username} is " "not currently in a game or does not exist.".format( username=username ) ) return None to_send = "**Red team**:\n" for player in ranks: if ranks.index(player) == len(ranks)/2: to_send += "\n**Blue team**:\n" if player[2] == "unranked": to_send += "{name} (**{champion}**): Unranked\n".format( name=player[0], champion=player[1] ) else: to_send += "{name} (**{champion}**): {tier} {division}\n".format( name=player[0], champion=player[1], tier=player[2].capitalize(), division=player[3] ) self.send_message(message.channel, to_send)
def summoner(request): context = {} summonerName = request.GET.get('summonerName', None) region = request.GET.get('region', None) context['errorFlag'] = "false" if not summonerName or not region: #TODO: ADD ERROR PAGE(?) print 'error' return render(request, 'templates/main.html') else: api = RiotAPI(RiotConstants.API_KEY, region) # Catches TypeError when user enters invalid summoner name. try: context['summonerName'] = summonerName context['region'] = region summonerName = summonerName.replace(' ','') summonerId = api.getSummonerByName(summonerName)[summonerName.lower()]['id'] championList = api.getChampionMasteryList(summonerId,10) context['championList'] = championList # creating a list of champions for dropdown in champion search bar. championListOrdered = [] for k,v in api.getChampionListByName().items(): championListOrdered.append([v['name'],v['key']]) championListOrdered.sort() context['orderedChampionList'] = championListOrdered # recentMatchesData returns a list with two elements. The first is a # list of the labels for the graphs (days) and the second is a list # of champion point values corresponding to the day labels. recentMatchesData = api.getRecentMatches(summonerId) recentMatchesDataParsed = graphParser.parseRecentMatches(recentMatchesData) context['graphLabels'] = recentMatchesDataParsed[0] context['graphData'] = recentMatchesDataParsed[1] return render(request,'templates/summoner.html', context) except TypeError: print("TypeError") context['errorFlag'] = "true" context['summonerName'] = summonerName return render(request, 'templates/main.html', context)
def main(): try: api = RiotAPI(API_KEY, region="north_america") except NameError as e: print e sys.exit(1) target_api = ["summoner", "by-name"] target_names = {"summonerNames":["aznchipmunk", "tovrikthethird", "omgnubness", "g0dzspeed"]} try: req = Request(target_api, target_names) get_summoner_response = api.call(req) except Exception as e: print e sys.exit(1) for name in target_names["summonerNames"]: print "{} (id {}):".format(get_summoner_response[name]["name"], get_summoner_response[name]["id"]) target_api = ["league", "by-summoner", "entry"] target_args = {"summonerIds":get_summoner_response[name]["id"]} req = Request(target_api, target_args) try: response = api.call(req) except HTTPError, e: print e sys.exit(1) for item in response[str(get_summoner_response[name]["id"])]: if item["queue"] == "RANKED_SOLO_5x5": try: latest_game = item["entries"][0] print "Most recent match: {}, {} {}, {} LP".format(item["name"], item["tier"], latest_game["division"], latest_game["leaguePoints"]) try: print "In series: {}".format(latest_game["miniSeries"]["progress"]) except: print "Not in series." print "Overall {}W / {}L, {:.2g}%".format( latest_game["wins"], latest_game["losses"], float(100 * latest_game["wins"])/(latest_game["wins"] + latest_game["losses"])) except: print "No match history found."
def _parse_masteries(masteries): api = RiotAPI('be8ccf5f-5d08-453f-84f2-ec89ddd7cea2') offense = 0 defense = 0 utility = 0 for mastery in masteries: masteryId = mastery['masteryId'] cur_mastery = mastery_cache.find(masteryId) if cur_mastery is False: cur_mastery = api.get_mastery_by_id(masteryId, {'masteryData': 'masteryTree'}) # print('Mastery not in cache') #else: # print('Mastery in cache') if cur_mastery['masteryTree'] == 'Offense': offense += mastery['rank'] elif cur_mastery['masteryTree'] == 'Defense': defense += mastery['rank'] elif cur_mastery['masteryTree'] == 'Utility': utility += mastery['rank'] mastery_cache.place(masteryId, cur_mastery) if (offense + defense + utility) > 30: print("Error with masteries!") return offense, defense, utility
def main(): if len(sys.argv) == 3: summoner_name = sys.argv[1].lower() region = sys.argv[2].lower() platform_id = get_platform_id(region) api = RiotAPI('key', region) champions = api.get_all_champions() game = api.get_current_game(summoner_name, platform_id) if game != 'error': summoners_info = api.get_summoners_info(game['participants']) for player in game['participants']: print player['summonerName'] + ' (' + get_champion_name(champions, player[ 'championId']) + '): ' + get_summoner_league(summoners_info[str(player['summonerId'])]) else: print 'This summoner is not in game' else: print 'Invalid syntax'
def rank(self, message): self.send_typing(message.channel) player = self.get_player(message) username = player[0] region = player[1] if region.upper() not in self.regions: self.send_message(message.channel, 'Invalid region') return None riot = RiotAPI(self.riot_key, region) if username == "me": username = message.author.name try: rank = riot.get_summoner_rank("".join(username.split(" "))) to_return = "The summoner {username} is ranked {tier} {division} and currently has {LP} LPs. (S6 winrate: {winrate})".format( username=username, tier=rank[0].capitalize(), division=rank[1], LP=str(rank[2]), winrate=str(rank[3]) + "%" ) except (ValueError, KeyError): try: level = riot.get_summoner_level("".join(username.split(" "))) to_return = "The summoner {username} is unranked and is level {level}.".format( username=username, level=str(level) ) except: to_return = "The summoner {username} does not exist or is not on the {region} server.".format( username=username, region=region ) self.send_message(message.channel, to_return)
def main(): global api global r global g global theNumber global pics global champs global items pics = {} api = RiotAPI('335deea3-d338-4acd-a515-1905b5e4a51f') inpt = "rwandapanda" r = api.get_summoner_by_name(inpt) name = inpt.lower().replace(" ","") g = api.get_game(r[name]['id']) champs = getAllChamps() champs.organiseChamps() items = getAllItems() items.organiseItems() theNumber = 1 getStatsForAllGames(theNumber)
def main(): connection = MongoClient('mongodb://*****:*****@ds061661.mongolab.com:61661/heroku_260s8zg7') db = connection.get_database('heroku_260s8zg7').users names = [] for record in db.find(): names.append(record['summoner']) api = RiotAPI('dbd62bf4-f29c-4f9b-a778-e255139cf35b') for name in names: if(name != 'ladder'): r = api.get_summoner_by_name(name) strippedName = name.replace(" ", "") strippedName = strippedName.lower() print r id = r[strippedName]['id'] print id r2 = api.get_league_by_name(name, id) ranked = 0 #print r2[str(id)][0]['entries'][0]['division'] for element in r2[str(id)]: if(element['queue'] == 'RANKED_SOLO_5x5'): db.update({'summoner': name}, {'$set': {'tier': element['tier']}}) db.update({'summoner': name}, {'$set': {'division': element['entries'][0]['division']}}) db.update({'summoner': name}, {'$set': {'points': element['entries'][0]['leaguePoints']}}) print 'Name: ' + name + ', Rank: ' + element['tier'] + ' ' + element['entries'][0]['division'] + ', ' + str(element['entries'][0]['leaguePoints']) + ' Points' ranked = 1 if(ranked == 0): db.update({'summoner': name}, {'$set': {'tier': 'Unranked'}}) db.update({'summoner': name}, {'$set': {'division': 'I'}}) db.update({'summoner': name}, {'$set': {'points':'0'}}) print 'Name: ' + name + ', Rank: Unranked, 0 Points' sleep(10) connection.close()
def main(): api = RiotAPI('API KEY HERE') for match in BR511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('br', strmatch) BRGames511R[strmatch] = game print(len(BRGames511R)) #helps keep track of X/10,000 requests completed except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\BR.json', 'w') as fp: json.dump(BRGames511R, fp) for match in EUNE511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('eune', strmatch) EUNEGames511R[strmatch] = game print(len(EUNEGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\EUNE.json', 'w') as fp: json.dump(EUNEGames511R, fp) for match in EUW511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('euw', strmatch) EUWGames511R[strmatch] = game print(len(EUWGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\EUW.json', 'w') as fp: json.dump(EUWGames511R, fp) for match in KR511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('kr', strmatch) KRGames511R[strmatch] = game print(len(KRGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\KR.json', 'w') as fp: json.dump(KRGames511R, fp) for match in LAN511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('lan', strmatch) LANGames511R[strmatch] = game print(len(LANGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\LAN.json', 'w') as fp: json.dump(LANGames511R, fp) for match in LAS511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('las', strmatch) LASGames511R[strmatch] = game print(len(LASGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\LAS.json', 'w') as fp: json.dump(LASGames511R, fp) for match in NA511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('na', strmatch) NAGames511R[strmatch] = game print(len(NAGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\NA.json', 'w') as fp: json.dump(NAGames511R, fp) for match in OCE511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('oce', strmatch) OCEGames511R[strmatch] = game print(len(OCEGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\OCE.json', 'w') as fp: json.dump(OCEGames511R, fp) for match in RU511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('ru', strmatch) RUGames511R[strmatch] = game print(len(RUGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\RU.json', 'w') as fp: json.dump(RUGames511R, fp) for match in TR511R: while True: try: strmatch = str(match) game = api.get_match_by_matchid('tr', strmatch) TRGames511R[strmatch] = game print(len(TRGames511R)) except: continue break with open(r'E:\Python Programs\API Challenge Aug 2015\API Challenge Executed Requests\5.11\RANKED_SOLO\TR.json', 'w') as fp: json.dump(TRGames511R, fp)
def main(): #Lets start our program by calling this function. #It will create an object that will help us to connect to Riot API. api = RiotAPI('9c971f8a-e6f3-44ce-b85a-7e3c78cc96a7') baseADPerLevel = [50, 60, 70, 80, 100] addedAD = [0, 100, 300, 400, 500] addedAP = [0, 10, 20, 30, 40] addedCDR = [0, 0.05, 0.10, 0.15, 0.4] winnerQ = [0, 0, 0, 0, 0] winnerQName = [0, 0, 0, 0, 0] winnerW = [0, 0, 0, 0, 0] winnerWName = [0, 0, 0, 0, 0] winnerE = [0, 0, 0, 0, 0] winnerEName = [0, 0, 0, 0, 0] winnerR = [0, 0, 0, 0, 0] winnerRName = [0, 0, 0, 0, 0] #Here is my big list of champion IDs. This is what I use the grab each champs static data using Riot API. champIDList = ['266','412','23', '79', '69', '13', '78', '14', '1', '111', '43', '99', '103','2','112', '34', '86', '27', '127', '57', '25', '28', '105', '74', '238', '68', '37', '82', '96', '55', '117', '22', '30', '12', '122', '67', '77', '110', '89','126','134', '80', '92', '121', '76', '3', '85', '45', '432', '150', '90', '254', '10', '39', '64', '60', '106', '20', '4', '24', '102', '429', '36', '223', '63', '131', '113', '8', '154', '421', '133', '84', '18', '120', '15', '236', '107', '19', '72', '54', '157', '101', '17', '75', '58', '119', '35', '50', '115', '91', '40', '245', '61', '114', '9', '33', '31', '7', '16', '26', '56', '222', '83', '6', '203', '21', '62', '53', '98', '201', '5', '29', '11', '44', '32', '41', '48', '38', '161', '143', '267', '59', '81', '42', '104', '51', '268', '115'] #champIDList = ['266','412','23', '79', '69', '13', '78', '14', '1'] print "Hello User. Welcome to the RitoPlsNerf Skills Calculator (Only compatible with Patch 5.22). Before using this program, I recommend taking a look at readme.txt and rules.txt included in the ZIP file.\n" print "I also highly recommend running this program in IDLE or some full screen interface. Command Prompt may alter the formatting of certain things. If you are using a Terminal" print "than be sure to make the window as big as possible\n" raw_input("PRESS ENTER to continue.........") print ("\n") print "In order to begin I first need to grab each champions JSON Data (using Riot API) and parse the data I need into an object made just for that champion.\n" print "This will allow me to use that data efficiently instead of constantly going through Riot's API.\n" print "Grabbing all the data I need may take 30-60 SECONDS depending on your internet/computer. The good part is, once this is done you don't need to do it again!\n" print "Type in the word BEGIN below to st" \ "art making our objects, it may take a minute!\n" #Basic user input here. userInput01 = (str)(raw_input('Type BEGIN here: ')) userInput01 = userInput01.lower() #I include this in case the user types something incorrect. while (userInput01 != 'begin'): print "Incorrect input! Try again." userInput01 = (str)(raw_input('Type here: ')) userInput01 = userInput01.lower() if (userInput01 == 'begin'): print "Preparing to hack into Riot Games Kappa Kappa Kappa TSM DoubleLift" championObjectList =[] #This is where I grab each champs JSON and parse it into an object. #I then put that object in a list I can reference later. for id in champIDList: championJSON = api.get_champion_by_id(id) champObject = Champion(championJSON) #champObject._printValues() championObjectList.append(champObject) else: print "Your input was incorrect! The program will now exit...\n" sys.exit() print "Okay! I have made an object for each champion. Now we can do a bunch of fun stuff!\n" print "Before we start, let me run down how this program works. You will be prompted to input varying amounts of CDR, AP, and AD ALL according to a champions level. This program uses Levels 1, 5, 9, 13, and 18.\n" raw_input("PRESS ENTER to continue.........\n") print "As an example I have included some predefined sample input below. These are the stats for a Hybrid AD champion (like Corki), which is why it gains some AP per level.\n" print "Remember you can customize this all you want later in the program!\n" print " AD", " ","AP", " ","CDR" print "Level 1: ","%.2f" %addedAD[0], " ", "%.2f" %addedAP[0], " ", "%.2f" %addedCDR[0] print "Level 5: ","%.2f" %addedAD[1], " ", "%.2f" %addedAP[1], " ", "%.2f" %addedCDR[1] print "Level 9: ","%.2f" %addedAD[2], " ", "%.2f" %addedAP[2], " ", "%.2f" %addedCDR[2] print "Level 13: ","%.2f" %addedAD[3], " ", "%.2f" %addedAP[3], " ", "%.2f" %addedCDR[3] print "Level 18: ","%.2f" %addedAD[4], " ", "%.2f" %addedAP[4], " ", "%.2f" %addedCDR[4] print "\n" i = 0 while (i == 0): print "RiotPlsNerf Skills Calculator Menu\n" print "Note: Typing in an option incorrectly will cause program to exit\n" print "Type in the word RUN to use my predefined values for AP, AD, and CDR (I HIGHLY recommend doing this first)\n" print "Type in the word CUSTOM to use your own values for AP, AD, and CDR\n" print "Type in the word SKILLS to look at the efficiency of a specific champion's skill. (Note: This only works properly if you use RUN or CUSTOM beforehand)\n" print "Type in the word GET to look at a specific champions object\n" print "Type in the word LEAVE to exit from the program" userInput01 = (str)(raw_input('Type preferred option here: ')) userInput01 = userInput01.lower() if (userInput01 == 'RUN' or userInput01 == 'run' or userInput01 == 'Run' or userInput01 == 'CUSTOM' or userInput01 == 'custom' or userInput01 == 'Custom'): baseADPerLevel = [50, 60, 70, 80, 100] addedAD = [10, 100, 300, 400, 500] addedAP = [0, 5, 10, 20, 40] addedCDR = [0, 0.05, 0.10, 0.15, 0.4] w = 0 #This is how the "Custom" fucntion is built. if (userInput01 == 'CUSTOM' or userInput01 == 'custom' or userInput01 == 'Custom'): while (w == 0): print "\n" print "P A R T O N E" print "Lets go step by step so that you can accurately input your numbers for AP, AD, and CDR. Only input NUMBERS for everything (decimals are okay)" raw_input("PRESS ENTER to continue.........\n") print "Level 1, how much AD do you want your champ to have?" AD1 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) while (AD1 > 1000 or AD1 < 0): print "Your previous input had the incorrect bounds. Try again!" AD1 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) print "\nLevel 5, how much AD do you want your champ to have?" AD2 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) while (AD2 > 1000 or AD2 < 0): print "Your previous input had the incorrect bounds. Try again!" AD2 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) print "\nLevel 9, how much AD do you want your champ to have?" AD3 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) while (AD3 > 1000 or AD3 < 0): print "Your previous input had the incorrect bounds. Try again!" AD3 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) print "\nLevel 13, how much AD do you want your champ to have?" AD4 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) while (AD4 > 1000 or AD4 < 0): print "Your previous input had the incorrect bounds. Try again!" AD4 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) print "\nLevel 18, how much AD do you want your champ to have?" AD5 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) while (AD5 > 1000 or AD5 < 0): print "Your previous input had the incorrect bounds. Try again!" AD5 = float(raw_input('Type your input here (Keep number between 0 and 1000): ')) print "\n" addedAD = [AD1, AD2, AD3, AD4, AD5] print "P A R T T W 0" print "Now you can input the amount of AP you want to give your champ!" raw_input("PRESS ENTER to continue.........\n") print "\n" print "Level 1, how much AP do you want your champ to have?" AP1 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) while (AP1 > 1500 or AP1 < 0): print "Your previous input had the incorrect bounds. Try again!" AP1 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) print "\nLevel 5, how much AP do you want your champ to have?" AP2 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) while (AP2 > 1500 or AP2 < 0): print "Your previous input had the incorrect bounds. Try again!" AP2 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) print "\nLevel 9, how much AP do you want your champ to have?" AP3 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) while (AP3 > 1500 or AP3 < 0): print "Your previous input had the incorrect bounds. Try again!" AP3 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) print "\nLevel 13, how much AP do you want your champ to have?" AP4 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) while (AP4 > 1500 or AP4 < 0): print "Your previous input had the incorrect bounds. Try again!" AP4 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) print "\nLevel 18, how much AP do you want your champ to have?" AP5 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) while (AP5 > 1500 or AP5 < 0): print "Your previous input had the incorrect bounds. Try again!" AP5 = float(raw_input('Type your input here (Keep number between 0 and 1500): ')) print "\n" addedAP = [AP1, AP2, AP3, AP4, AP5] print "P A R T T H R E E" print "Time to plug in your numbeers for CoolDown Reduction (CDR)!" print "IMPORTANT: Input CDR PERCENT as a DECIMAL! (Example: for 20% CDR type in 0.20)" raw_input("PRESS ENTER to continue.........\n") print "\nLevel 1, how much CDR do you want your champ to have?" CDR1 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) while (CDR1 > 0.4 or CDR1 < 0): print "Your previous input had the incorrect bounds. Try again!" CDR1 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) print "\nLevel 5, how much CDR do you want your champ to have?" CDR2 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) while (CDR2 > 0.4 or CDR2 < 0): print "Your previous input had the incorrect bounds. Try again!" CDR2 = float(raw_input('Type your input here (Keep number between 0 and 0.40): ')) print "\nLevel 9, how much CDR do you want your champ to have?" CDR3 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) while (CDR3 > 0.4 or CDR3 < 0): print "Your previous input had the incorrect bounds. Try again!" CDR3 = float(raw_input('Type your input here (Keep number between 0 and 0.40): ')) print "\nLevel 13, how much CDR do you want your champ to have?" CDR4 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) while (CDR4 > 0.4 or CDR4 < 0): print "Your previous input had the incorrect bounds. Try again!" CDR4= float(raw_input('Type your input here (Keep number between 0 and 0.40): ')) print "\nLevel 18, how much CDR do you want your champ to have?" CDR5 = float(raw_input('Type your input here (Keep number between 0.00 and 0.40): ')) while (CDR5 > 0.4 or CDR5 < 0): print "Your previous input had the incorrect bounds. Try again!" CDR5= float(raw_input('Type your input here (Keep number between 0 and 0.40): ')) addedCDR = [CDR1, CDR2, CDR3, CDR4, CDR5] print "\n" print "Here is what your input looks like when it is organized" print " AD", " ","AP", " ","CDR" print "Level 1: ","%.2f" %addedAD[0], " ", "%.2f" %addedAP[0], " ", "%.2f" %addedCDR[0] print "Level 5: ","%.2f" %addedAD[1], " ", "%.2f" %addedAP[1], " ", "%.2f" %addedCDR[1] print "Level 9: ","%.2f" %addedAD[2], " ", "%.2f" %addedAP[2], " ", "%.2f" %addedCDR[2] print "Level 13: ","%.2f" %addedAD[3], " ", "%.2f" %addedAP[3], " ", "%.2f" %addedCDR[3] print "Level 18: ","%.2f" %addedAD[4], " ", "%.2f" %addedAP[4], " ", "%.2f" %addedCDR[4] print "Type in the word READY to move forward with the numbers above" print "Type in the word AGAIN to input your numbers from the beginning" userInput01 = (str)(raw_input('Type preferred option here: ')) userInput01 = userInput01.lower() if (userInput01 == 'READY' or userInput01 == 'ready' or userInput01 == 'Ready'): w = 1 break; if (userInput01 == 'AGAIN' or userInput01 == 'again' or userInput01 == 'Again'): w = 0 continue; else: print "Your input was incorrect! The program will now exit...\n" sys.exit() #This is where I grab the most efficient spells and assign them accordingly. #I go through every single object in my list. for i in range (0, len(champIDList)): currentObject = championObjectList[i] print currentObject._returnChampName() currentObject._printValues() currentObject._clearEfficiencyLists() #I go through "R" values first and create a list for that champion efficiencies. for k in range (3, 6): #Calculating the actual efficiencies is all done in my champion class. Check that out for more info. rList = currentObject._calculateREfficiency((k-2), baseADPerLevel[k-1], addedAD[k-1], addedAP[k-1], addedCDR[k-1]) #Here I am just assigning the winners. if rList[0] > winnerR[0]: winnerR[0] = rList[0] winnerRName[0] = currentObject._returnChampName() if rList[1] > winnerR[1]: winnerR[1] = rList[1] winnerRName[1] = currentObject._returnChampName() if rList[2] > winnerR[2]: winnerR[2] = rList[2] winnerRName[2] = currentObject._returnChampName() #Now lets do Q, W, E, R for j in range (1, 6): #print "The AP Ratio is ", addedAP qList = currentObject._calculateQEfficiency(j, baseADPerLevel[j-1], addedAD[j-1], addedAP[j-1], addedCDR[j-1]) wList = currentObject._calculateWEfficiency(j, baseADPerLevel[j-1], addedAD[j-1], addedAP[j-1], addedCDR[j-1]) eList = currentObject._calculateEEfficiency(j, baseADPerLevel[j-1], addedAD[j-1], addedAP[j-1], addedCDR[j-1]) #print "Q List: ", qList if qList[0] > winnerQ[0]: winnerQ[0] = qList[0] winnerQName[0] = currentObject._returnChampName() if qList[1] > winnerQ[1]: winnerQ[1] = qList[1] winnerQName[1] = currentObject._returnChampName() if qList[2] > winnerQ[2]: winnerQ[2] = qList[2] winnerQName[2] = currentObject._returnChampName() if qList[3] > winnerQ[3]: winnerQ[3] = qList[3] winnerQName[3] = currentObject._returnChampName() if qList[4] > winnerQ[4]: winnerQ[4] = qList[4] winnerQName[4] = currentObject._returnChampName() if wList[0] > winnerW[0]: winnerW[0] = wList[0] winnerWName[0] = currentObject._returnChampName() if wList[1] > winnerW[1]: winnerW[1] = wList[1] winnerWName[1] = currentObject._returnChampName() if wList[2] > winnerW[2]: winnerW[2] = wList[2] winnerWName[2] = currentObject._returnChampName() if wList[3] > winnerW[3]: winnerW[3] = wList[3] winnerWName[3] = currentObject._returnChampName() if wList[4] > winnerW[4]: winnerW[4] = wList[4] winnerWName[4] = currentObject._returnChampName() if eList[0] > winnerE[0]: winnerE[0] = eList[0] winnerEName[0] = currentObject._returnChampName() if eList[1] > winnerE[1]: winnerE[1] = eList[1] winnerEName[1] = currentObject._returnChampName() if eList[2] > winnerE[2]: winnerE[2] = eList[2] winnerEName[2] = currentObject._returnChampName() if eList[3] > winnerE[3]: winnerE[3] = eList[3] winnerEName[3] = currentObject._returnChampName() if eList[4] > winnerE[4]: winnerE[4] = eList[4] winnerEName[4] = currentObject._returnChampName() _easyPrinter(winnerQ, winnerQName, winnerW, winnerWName, winnerE, winnerEName, winnerR, winnerRName) #I zero everything out just in case to avoid weird numbers. winnerQ = [0, 0, 0, 0, 0] winnerQName = [0, 0, 0, 0, 0] winnerW = [0, 0, 0, 0, 0] winnerWName = [0, 0, 0, 0, 0] winnerE = [0, 0, 0, 0, 0] winnerEName = [0, 0, 0, 0, 0] winnerR = [0, 0, 0, 0, 0] winnerRName = [0, 0, 0, 0, 0] print "\n" i = 0 elif (userInput01 == 'LEAVE' or userInput01 == 'leave' or userInput01 == 'Leave'): print "Thanks for using RitoPlsNerf OP Skills Calculator" sys.exit() elif (userInput01 == 'GET' or userInput01 == 'get' or userInput01 == 'Get'): print "\n" print "Type in the name of the champion you want to retrieve the object of. Be sure to capitalize the correct letters and spell correctly\n" print "For champion names greater than one word, simply type in the first part of it (ex. to search Twisted Faith, simply type the word Twisted)\n" print "IMPORTANT: The values in the object are not necessarily the values used in the calculations. Some values are manually changed within the program\n" champInput = (str)(raw_input('Type champion name exactly how it looks: ')) winnerChampObject = 0 #This is a real simple function that grabs the champ name that correspond with the one the user eneters. It then spits out the data using #a function from the champion class. for p in range (0, len(championObjectList)): #print championObjectList[p]._returnChampName() if (champInput in championObjectList[p]._returnChampName()): winnerChampObject = championObjectList[p] print winnerChampObject._printValues() break if (winnerChampObject == 0): print "\nCouldn't find that champion. Sure you spelled everything right? Taking you back to the menu now.\n" elif (userInput01 == 'SKILLS' or userInput01 == 'skills' or userInput01 == 'Skills'): print "\n" print "Type in the name of the champ you want to retrieve the skill efficiencies of. Be sure to capitalize the correct letters and spell correctly\n" print "For champion names greater than one word, simply type in the first part of it (ex. to search Twisted Faith, simply type the word Twisted)\n" champInput2 = (str)(raw_input('Type champion name exactly how it looks: ')) #winner2ChampObject = 0 print len(championObjectList) for p in range (0, len(championObjectList)): #print championObjectList[p]._returnChampName() if (champInput2 in championObjectList[p]._returnChampName()): winner2ChampObject = championObjectList[p] print winner2ChampObject._printEff() break if (winner2ChampObject == 0): print "Couldn't find that champion. Sure you spelled everything right? Taking you back to the menu now." else: print "Your input was incorrect! The program will now exit...\n" sys.exit()
def main(): api = RiotAPI('3e888957-13a3-4ba2-901c-fae3e421d998') r = api.get_summoner_by_name('sadmilk') #print(r['anti213']['id']) r1 = api.get_stats(r['sadmilk']['id'], 'ranked') pprint(r1)