Exemplo n.º 1
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.º 2
0
def findRelatedAccounts(multi):
    #step 1
    accounts = getAccountsFromMulti(multi)
    relatedAccounts = {}
    print("Done with step 1.")
    #step 2
    for account in accounts:
        name = account["name"]
        print(name)
        accInfo = {"sus":{},"mostSus":{}}
        matches = riotapicalls.getAllRankedMatchesByAccount(account)
        accInfo["duos"] = findDuos(matches,account)
        relatedAccounts[name] = accInfo
    print("Almost done with step 2.")
    relatedAccounts["duos"] = syncDuos(relatedAccounts) #puts all unique duo partners into relatedAccounts["duos"]
    print("Done with step 2.")
    #step 3
    for duo in relatedAccounts["duos"]:
        if relatedAccounts["duos"][duo]["partners"] > 2 or relatedAccounts["duos"][duo]["games"] > 20:
            account = riotapicalls.getAccountByName(duo)
            if "name" not in account:
                print("error with: " + duo)
            name = account["name"]
            print(name)
            matches = riotapicalls.getAllRankedMatchesByAccount(account)
            #step 4
            relatedAccounts["duos"][name]["duos"] = findDuos(matches,account) #need to decode these duos as well
    print("Almost done with step 4.")
    relatedAccounts["duos"]["duos"] = syncDuos(relatedAccounts["duos"])
    print("Done with step 4.")
    #step 5
    determineSusAccounts(relatedAccounts) #fills in for each original player the "sus" and "mostSus" dicts

    return relatedAccounts
Exemplo n.º 3
0
def handleCmd(cmds):
    cmd = cmds[0].lower()  #main command
    cmdList = [["help"], ["opggScout", "teamName", "opgg"],
               ["namesFromOpgg", "opgg"],
               ["downloadRankedGames", "[name1,name2,...,nameN]"]
               ]  #a list of all the commands supported
    if (cmd == "help"):
        #print out all of the commands from cmdList and their arguments (if any)
        print(
            "Here is a list of commands and their parameters that they take:")
        for c in cmdList:
            if (len(c) == 1):  #takes no parameters
                print(c[0])
            else:
                print(c[0] + ":", end=' ')
                for i in range(1, len(c)):
                    if (i == len(c) - 1):
                        print(c[i])
                    else:
                        print(c[i], end=', ')
    elif (cmd == "opggscout"):
        #creates a scouting report from the given opgg. see opggcalls.opggScout for more details
        if (len(cmds) != 3):
            invalidParameterLength(3, len(cmds))
        else:
            createScoutingReport.createScoutingReport(cmds[1], cmds[2])
    elif (cmd == "namesfromopgg"):
        #grabs all of the summoner names from a given opgg. see opggcalls.getNamesFromOpgg
        if (len(cmds) != 2):
            invalidParameterLength(2, len(cmds))
        else:
            print(opggcalls.getNamesFromOpgg(cmds[1]))
    elif (cmd == "downloadrankedgames"):
        #downloads the ranked games from the supplied names
        if (len(cmds) == 1):
            invalidParameterLength("any number of", len(cmds))
        else:
            for i in range(1, len(cmds)):
                name = cmds[i]
                account = riotapicalls.getAccountByName(name)
                riotapicalls.getAllRankedMatchesByAccount(
                    account
                )  #saves them into a file called name.txt, with a "version" of the season
    else:
        print(
            "Command not recognized. Try \"help\" for a list of recognized commands."
        )
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
Exemplo n.º 5
0
def findRelatedAccountsTest():
    names = ["Noodlz","keep it mello","Poopsers","Celsius HEAT","arf ARF AwOoÒwÓo","lpoklpok","raïlgun"]
    #names = ["duong pro","kim down","the cookie","descraton","youngbin"]
    #names = ["spøøky","mistystumpey","andybendy","rovex","nintendudex","nme toysoldier"]
    #names = ["i am nightshade","móónlight","súnlight","really big meme","argentumsky","dylaran"]
    #names = ["barbecueribs","ino1","easy 10","scherb","lyo"]
    #names = ["the jons","vinnyhuan","golden kiwi","smelp","sharpe","lunarly","0aks"]    #having trouble with Nova Bot (Texas)
    #names = ['lofirelax', 'herking', 'uschovz', 'usctechsupport', 'poı', 'usckamdono', 'usc5050352', 'joejacko', 'gtinybear', 'hey i miss u']#opggcalls.getNamesFromOpgg("https://na.op.gg/multi/query=lofirelax%2Cherking%2Cuschovz%2Cusctechsupport%2Cpo%C4%B1%2Cusckamdono%2Cusc5050352")
    #names = opggcalls.getNamesFromOpgg("https://na.op.gg/multi/query=crecious%2Cimbiglou%2Ctheholyslurp%2Cnatey67%2Ckshuna%2Cmrblackpanda")
    #names = opggcalls.getNamesFromOpgg("https://na.op.gg/multi/query=niles%2CMUIconic%2CMUWolfe%2CValue%2C1Shady%2Csleeptimego%2Ckindjungle%2Chybridzz%2Cevanrl%2CCIyde")
    #names = opggcalls.getNamesFromOpgg("https://na.op.gg/multi/query=gavita%2Cbotcait%2Cdaddyowo%2Cggevosnore%2Cadebolaoluwa%2Cthejawsofdeath%2Caut1stanuser")
    start = time.time()
    accounts = []
    for name in names:
        account = riotapicalls.getAccountByName(name)
        accounts.append(account)
    #print(accounts)
    susAccounts = analysis.findRelatedAccounts(accounts)
    end = time.time()
    elapsedTime = (end-start)/60
    return [elapsedTime,susAccounts,accounts,names]
Exemplo n.º 6
0
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
Exemplo n.º 7
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"