Пример #1
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)
Пример #2
0
def main() :
    api = RiotAPI('RGAPI-e6af808d-ed47-4403-b09d-43dadba22b80')
    tmp = api.test()


    print("in main.js")
    print(tmp)
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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)
Пример #6
0
    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)
Пример #7
0
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"
Пример #8
0
def updateSquareItemAssetsAll():
    api = RiotAPI(api_key)
    itemData = api.get_item_data()
    for itemId in itemData['data']:
        api.get_square_item_asset(itemId, itemData)

    return
Пример #9
0
def getGameInfos(matchList, apiNumber):
    api = RiotAPI(apiNumber)
    gameList = []
    for number in matchList:
        matchInfo = api.get_matchInfo(number)
        gameList = gameList + [[number, matchInfo]]
    return gameList
Пример #10
0
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)
Пример #11
0
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)    
Пример #12
0
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)
Пример #13
0
def main():
    clean_match_files()
    api_key = get_api_key()
    summoner_name = None
    champion_name = None

    # Error Checking
    if api_key is None:
        sys.exit(ERROR_MESSAGE['api_key_error'])

    if summoner_name is None:
        sys.exit(ERROR_MESSAGE['summoner_error'])

    if champion_name is None:
        sys.exit(ERROR_MESSAGE['champion_error'])

    champ = {"champion": RiotConstants.CHAMPION_IDS[champion_name]}
    api = RiotAPI(api_key)
    total_kda, kda_ratio, game_count = get_kda(api, summoner_name, champ)
    print(
        RESULT_MESSAGE.format(summoner=summoner_name,
                              champion=champion_name,
                              total_kda=total_kda,
                              game_count=game_count,
                              kda_ratio=kda_ratio))
Пример #14
0
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
Пример #15
0
 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)
Пример #16
0
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
Пример #17
0
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
Пример #18
0
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
Пример #19
0
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
Пример #20
0
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"]
Пример #21
0
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)
Пример #22
0
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']
Пример #23
0
 def __init__(self, name):
     self.name = name
     apiSumm = RiotAPI(Consts.TEMPKEY['key'])
     summID = apiSumm.get_summoner_by_name(name)['id']
     # print("summoner id is " + str(summID))
     apiRank = RiotAPI(Consts.TEMPKEY['key'])
     ranking = apiRank.get_summoner_rank(summID)
     # self.tier = soloTier
     # self.div = soloDiv
     # self.lp = soloLP
     for thing in ranking:
         if (thing['queueType'] == 'RANKED_SOLO_5x5'):
             self.soloTier = thing['tier']
             self.soloDiv = thing['rank']
             self.soloLP = thing['leaguePoints']
     self.rank = 0
     if (self.soloTier == "BRONZE"):
         self.rank += 1000
     elif (self.soloTier == "SILVER"):
         self.rank += 2000
     elif (self.soloTier == "GOLD"):
         self.rank += 3000
     elif (self.soloTier == "PLATINUM"):
         self.rank += 4000
     elif (self.soloTier == "DIAMOND"):
         self.rank += 5000
     elif (self.soloTier == "MASTER"):
         self.rank += 6000
     elif (self.soloTier == "CHALLENGER"):
         self.rank += 7000
     if (self.soloDiv == "V"):
         self.rank += 100
     elif (self.soloDiv == "IV"):
         self.rank += 200
     elif (self.soloDiv == "III"):
         self.rank += 300
     elif (self.soloDiv == "II"):
         self.rank += 400
     elif (self.soloDiv == "I"):
         self.rank += 500
     self.rank += self.soloLP
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)
Пример #25
0
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]
Пример #26
0
def getDetailedMatchDataFromRpc(remoteClient, matchList):
    api = RiotAPI(api_key)
    detailedMatchData = {}
    argList = []
    for game in matchList:
        argList.append({'methodName': 'byMatchId', 'matchId': game['gameId']})
    allMatches = rpcFullRequest(remoteClient, argList)

    for game in allMatches:
        gameId = game['gameId']
        detailedMatchData[gameId] = game
    return detailedMatchData
Пример #27
0
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)
Пример #28
0
    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()))
Пример #29
0
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! "
Пример #30
0
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