コード例 #1
0
def getAllRankedMatchesByAccount(account):
    accId = account["accountId"]
    queries = "&queue=420"
    matchList = getMatchList(accId, queries)
    totalGames = matchList["totalGames"]

    matches = dbcalls.fetchMatchesByAccount(account)
    gameIds = []
    for match in matches:
        gameIds.append(match["gameId"])

    count = 0
    forbiddenCount = 0
    seasonId = getMostRecentSeasonId()
    while (count < totalGames):
        for match in matchList["matches"]:
            if ((int)(match["season"]) == (int)(seasonId)):
                gameId = match["gameId"]
                if gameId not in gameIds:
                    m = getMatch(match["gameId"])
                    if "status" in m:
                        if forbiddenCount > 10:
                            return matches
                        else:
                            forbiddenCount += 1
                    matches.append(m)
        count += 100
        queries = "&queue=420&beginIndex=" + (str)(count)
        matchList = getMatchList(accId, queries)
        totalGames = matchList["totalGames"]
    return matches
コード例 #2
0
ファイル: analysis.py プロジェクト: gra483/league-analytics
def findRelatedAccounts(accounts):
    #need to add degrees of relativity, role played, as well as "duo streaks" (it's how I found USC jungler's smurf via opgg)
    susAccs = {"similarAccounts":[]}
    similarAccounts = {}
    for account in accounts:
        name = account["name"]
        matches = dbcalls.fetchMatchesByAccount(account)    #matches are fetched in order of played (oldest to newest)
        #matches = riotapicalls.getAllRankedMatchesByAccount(account)
        playedWith = getPlayedWith(matches,account["id"])
        prunePlayedWith(playedWith)
        susAccs[name] = playedWith
        
        for n in playedWith:
            playedWithAcc = playedWith[n]
            if(n not in similarAccounts):
                similarAccounts[n] = {}
            similarAccounts[n][name] = playedWithAcc
            
    susAccs["similarAccounts"] = list(sorted(similarAccounts.items(), key=lambda kv: weightFunction(kv), reverse=True))
    return susAccs
コード例 #3
0
def findRelatedAccounts(accounts):
    susAccs = {"similarAccounts":[]}
    similarAccounts = {}
    for account in accounts:
        name = account["name"]
        print(name)
        matches = dbcalls.fetchMatchesByAccount(account)
        #matches = riotapicalls.getAllRankedMatchesByAccount(account)
        playedWith = scrapeMatches(matches,account["id"])
        print("matches scraped")
        prunePlayedWith(playedWith)
        print("matches pruned")
        susAccs[name] = playedWith
        
        for n in playedWith:
            playedWithAcc = playedWith[n]
            if(n not in similarAccounts):
                similarAccounts[n] = {}
            similarAccounts[n][name] = playedWithAcc
            
    susAccs["similarAccounts"] = list(sorted(similarAccounts.items(), key=lambda kv: weightFunction(kv), reverse=True))
    return susAccs
コード例 #4
0
ファイル: analysis.py プロジェクト: gra483/league-analytics
def getFingerprint(name):
    fingerprint = {"flash":[0,0],
                   "numMatches":0,
                   "itemMatrix":{}
                   }
    
    account = riotapicalls.getAccountByName(name)
    assert "id" in account, "Invalid name given, no account found for: " + name
    summId = account["id"]
    #matches = riotapicalls.getAllRankedMatchesByAccount(account)
    matches = dbcalls.fetchMatchesByAccount(account)
    
    fingerprint["numMatches"] = len(matches)
    for match in matches:
        pId = findParticipantId(match,summId)
        p = match["participants"][pId-1]    #the info for the participant
            
        #check which key flash is typically on
        if(p["spell1Id"] == 4):  #4 is the id for flash
            fingerprint["flash"][0] += 1
        elif(p["spell2Id"] == 4):    #else statement because may not have flash
            fingerprint["flash"][1] += 1
            
        #gather item data for all the items in the inventory
        inventory = []
        for slot in range(0,7):
            itemNum = p["stats"]["item"+(str)(slot)]
            item = dbcalls.translateItem(itemNum) #if invalid item, it is an empty string
            if(not item == "" and item in ACTIVE_ITEMS):
                inventory.append(item)
                if(item not in fingerprint["itemMatrix"]):
                    fingerprint["itemMatrix"][item] = [0,0,0,0,0,0,0,0]
                fingerprint["itemMatrix"][item][slot] += 1
                fingerprint["itemMatrix"][item][7] += 1 #this is the total count of the item
    print("Done with " + name + " matches.")
        
    fingerprint = handleInventory(fingerprint)
    
    return fingerprint
コード例 #5
0
def createReport(accounts):
    report = {"players": {}, "flexes": {}}
    #flexes = report["flexes"]
    #timelines = []
    for account in accounts:
        if (account):  #if the account is a valid account
            name = account["name"]
            print("Retrieving all ranked matches from \"" + name + "\"...")
            #matches = riotapicalls.getAllRankedMatchesByAccount(account)
            matches = dbcalls.fetchMatchesByAccount(account)
            print((str)(len(matches)) + " ranked matches retrieved from \"" +
                  name + "\".")
            #for match in matches:
            #timelines.append(riotapicalls.getMatchTimeline(match["gameId"]))
            data = scrapeMatches(matches, account)
            report["players"][name] = data
        else:
            print("Invalid account given.")

    report["players"] = createChampPools(report["players"])

    return report
コード例 #6
0
def fetchMatchesByNameTest():
    matches1 = dbcalls.fetchMatchesByName("CrusherCake")
    account = riotapicalls.getAccountByName("mello mental")
    matches2 = dbcalls.fetchMatchesByAccount(account)
    assert len(matches1) > 900, "didn't get CrusherCake ranked matches"
    assert len(matches2) > 0, "didn't get mello mental ranked matches"