def getCurrentMatch(summonerName, region="NA"): riotapi.set_region(region) summoner = riotapi.get_summoner_by_name(summonerName) match = riotapi.get_current_game(summoner) if match is None: return None roleMap = allRoles(match) # for x in roleMap: # print x.champion.name, x.side.name, roleMap[x] if len(roleMap.keys()) < 10: print "Role confusion!" return None statMap = {} rankMap = {} nonNormMap = {} for p in match.participants: role = roleMap[p] stats, nonNorm, rank = avgPerformance.getAvgPerformance(p, role) if stats is None: #currently filling with avg gold? stats = getAvg() rank = "unranked" statMap[p.side.name+role] = list(stats) rankMap[p] = rank nonNormMap[p] = nonNorm print p.summoner_name, p.side.name+role statVector = (statMap['blueTop']+statMap['blueMid']+statMap['blueJung']+ statMap['blueSup']+statMap['blueADC']+statMap['redTop']+ statMap['redMid']+statMap['redJung']+statMap['redSup']+ statMap['redADC']) model = fetchModel(match) results = model.predict_proba(statVector) return format.prepareReturn(roleMap, rankMap, nonNormMap, results, match)
def getCurrentMatch(summonerName, region="NA"): riotapi.set_region(region) try: summoner = riotapi.get_summoner_by_name(summonerName) match = riotapi.get_current_game(summoner) except APIError as e: print e return None if match is None: return None if match.mode.name != "classic": print "Not classic" return None roleMap = allRoles(match) if len(roleMap.keys()) < 10: roleMap = assignRandom(match) print "Role confusion!" statMap = {} rankMap = {} nonNormMap = {} for p in match.participants: role = roleMap[p] try: stats, nonNorm, rank = avgPerformance.getAvgPerformance(p, role) except: stats = getAvg(p.side.name+role) rank = "unranked" nonNorm = [0, 0, 0, 0, 0, 0] statMap[p.side.name+role] = list(stats) rankMap[p] = rank nonNormMap[p] = nonNorm print p.summoner_name, p.side.name+role statVector = (statMap['blueTop']+statMap['blueMid']+statMap['blueJung']+ statMap['blueSup']+statMap['blueADC']+statMap['redTop']+ statMap['redMid']+statMap['redJung']+statMap['redSup']+ statMap['redADC']) model = fetchModel(match, rankMap) results = model.predict_proba(statVector) return format.prepareReturn(roleMap, rankMap, nonNormMap, results, match)