Exemplo n.º 1
0
def syncDuos(relatedAccounts):
    duos = {}
    for name in relatedAccounts:
        if "duos" in relatedAccounts[name]:
            changeDict = {}
            partners = relatedAccounts[name]["duos"]
            for summId in partners:
                account = riotapicalls.getAccountBySummId(summId)
                dName = account["name"]
                changeDict[dName] = summId
                duoStats = partners[summId]
                if dName not in duos:
                    duoInfo = {"games":duoStats["games"],"partners":1}
                    duoInfo[name] = duoStats
                    duos[dName] = duoInfo
                else:
                    duos[dName]["games"] += duoStats["games"]
                    duos[dName][name] = duoStats
                    duos[dName]["partners"] += 1
                        
            for name in changeDict:
                summId = changeDict[name]
                partners[name] = partners[summId]
                del partners[summId]
    return duos
Exemplo n.º 2
0
def getPlayedWith(matches,summId):
    playedWith = {}
    summIds = {}
    for match in matches:
        pId = findParticipantId(match,summId)
        assert not pId == -1, "didn't find pId for some reason | " + (str)(match["gameId"]) + " | " + (str)(len(playedWith))
        start = (pId//6)*5   #either 0 or 1 after divison, then 0 or 5
        assert start == 0 or start == 5, "dun goofed " + (str)(start) + " | " + (str)(pId)
        for i in range(start,start+5):  #loop through the 5 players on their team
            if(not i == pId-1): 
                player = match["participantIdentities"][i]["player"]
                pSummId = player["summonerId"]
                if pSummId not in summIds:
                    summIds[pSummId] = 1
                else:
                    summIds[pSummId] += 1
                    
    for sId in summIds:
        acc = riotapicalls.getAccountBySummId(sId)
        name = acc["name"]
        if(name in playedWith):
            playedWith[name] += 1
        else:
            playedWith[name] = 1
        
    return playedWith
Exemplo n.º 3
0
def getAccountTests():
    name = "arf ARF AwOoÒwÓo"
    name = name.lower() #lowercase for case sensitivity
    
    account = riotapicalls.getAccountByName(name)
    assert account["name"].lower() == name, "getAccountByName from server/db: " + account["name"] + " vs " + name
    account = riotapicalls.getAccountByAccId(account["accountId"])
    assert account["name"].lower() == name, "getAccountByAccId from db: " + account["name"] + " vs " + name
    account = riotapicalls.getAccountByPuuid(account["puuid"])
    assert account["name"].lower() == name, "getAccountByPuuid from db: " + account["name"] + " vs " + name
    account = riotapicalls.getAccountBySummId(account["id"])
    assert account["name"].lower() == name, "getAccountBySummId from db: " + account["name"] + " vs " + name
    account = riotapicalls.getAccountByName(name)
    assert account["name"].lower() == name, "getAccountByName from db: " + account["name"] + " vs " + name
    
    print("passed getAccountTests")
Exemplo n.º 4
0
def runLeaderboard(accounts):
    leaderboard = []
    #update all the identities (change summoner names to summonerId's)
    for name in accounts:        
        newIdentities = []
        for identity in accounts[name]: 
            if(len(identity) < 45):
                account = riotapicalls.getAccountByName(identity)
                if("id" in account):
                    newIdentities.append(account["id"])
                else:
                    print(identity + " no longer valid.")
            else:
                newIdentities.append(identity)
        accounts[name] = newIdentities
        
    #now that identities are updated to only have valid summonerId's, let's ranked them on the leaderboard
    for name in accounts:
        highAcc = ""
        highRank = ""
        highScore = -1
        for summId in accounts[name]:
            rankInfo = riotapicalls.getLeagueBySummonerId(summId)
            soloQueue = {}
            for queue in rankInfo:
                if(queue["queueType"] == "RANKED_SOLO_5x5"):
                    soloQueue = queue
            score = -1
            if(soloQueue):
                score = getScore(soloQueue)
            
            if(score > highScore):
                highAcc = riotapicalls.getAccountBySummId(summId)["name"]
                highScore = score
                highRank = rankName(soloQueue)
        leaderboard.append([name,highRank,highAcc,highScore])
    
    leaderboard.sort(key=lambda x:x[3])
    leaderboard.reverse() #sorts the leaderboard in order of the highScore
    
    writeLeaderboard(leaderboard)
                
    return accounts