Skip to main content
edited tags
Link
konijn
  • 33.8k
  • 5
  • 69
  • 264
Tweeted twitter.com/StackCodeReview/status/1293472298142400513
Became Hot Network Question
edited title
Link
Zeta
  • 19.3k
  • 2
  • 55
  • 89

Any way to better this program and is this project too simple to be working on(first project in python)? League of Legends Summoner Analysis

import requests
from getId import idcollect
from games import GAME
from wins import win_calc

#Key for riot API
Key = '**********************'

#ASKING USER FOR SUMMONER NAME
summonerName = input('Enter summoner name:')

#Objects
ids=idcollect()
game=GAME()
wins=win_calc()

#Collecting the acc id of summoner name
accId=ids.ID_collected(summonerName,Key)

#Collecting game id lists
game_list=[]
game_list=game.find_game_ids(accId,Key)

#Collecting wins list
win_list=[]
win_list=game.game_data(game_list,Key,summonerName)

#Calcuate whether the summoner is good or not
wins.is_dis_mane_good(win_list)





 
 
import requests


class GAME:


    def find_game_ids(self,accId,key):
        
        i=0
        GAMEID = []
        Idgame=20       
        url_match_list=('https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/'+(accId)+'?queue=420&endIndex=20&api_key='+(key))
        response2=requests.get(url_match_list)
        #Adding 20 games into the list
        while Idgame>0:
            GAMEID.append('https://na1.api.riotgames.com/lol/match/v4/matches/'+str(response2.json()['matches'][i]['gameId'])+'?api_key='+(key))
            i=i+1
            Idgame=Idgame-1

        return GAMEID


    def game_data(self,game_list,key,sumName):

        wins=[]
        deaths=[]
        deaths= []
        kills=[]
        assists=[]
        visions=[]
        csTotal=[]
        
        
        #Finding the data of said summoner in each game id
        for urls in game_list:

            
            response=requests.get(urls)
            Loop=0
            index=0
            while Loop<=10:
                
                if response.json()['participantIdentities'][index]['player']['summonerName']!=sumName:
                    Loop= Loop+1
                    index=index+1
                elif response.json()['participantIdentities'][index]['player']['summonerName']==sumName:
                    
                    deaths.append(response.json()['participants'][index]['stats']['deaths'])
                    kills.append(response.json()['participants'][index]['stats']['kills'])
                    assists.append(response.json()['participants'][index]['stats']['assists'])
                    visions.append(response.json()['participants'][index]['stats']['visionScore'])
                    csTotal.append(response.json()['participants'][index]['stats']['totalMinionsKilled'])
                    wins.append(response.json()['participants'][index]['stats']['win'])
                
                    break
        #Finding avg of each stat
        deaths=sum(deaths)/20            
        kills=sum(kills)/20
        assists=sum(assists)/20
        visions=sum(visions)/20
        csTotal=sum(csTotal)/20

        print('The avg kills is '+str(kills)+'\nThe avg deaths is '+str(deaths)+'\nThe avg assists is '+str(assists)+'\nThe avg visions is '+str(visions)+'\nThe avg cs total is '+str(csTotal))

        return wins






 
 
import requests

class idcollect:
    
    def ID_collected(self,sumName,key):
        #COLLECTING DATA TO BE INSERTING FOR MATCHLIST DATABASE
        url=('https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/'+(sumName)+'?api_key='+(key))
        response=requests.get(url)
        accId=(response.json()['accountId'])
        return accId





 
 
import random

class win_calc:


    def is_dis_mane_good(self,winlist):
        
        winlist=sum(winlist)/20

        if (winlist<.33):
            trash=['DIS MANE STINKS','run while you can','I repeat, YOU ARE NOT WINNING THIS','I predict a fat L','Have fun trying to carry this person','He is a walking trash can','He needs to find a new game','BAD LUCK!!!']
            print (random.choice(trash))

        elif (winlist>.33 and winlist<=.5):
            notgood=['Losing a bit','Not very good','He needs lots of help','Your back might hurt a little','Does not win much'] 
            print (random.choice(notgood))

        elif (winlist>.5 and winlist<=.65):
            ight=['He is ight','He can win a lil','You guys have a decent chance to win','Serviceable','Should be a dub']
            print (random.choice(ight))

        elif (winlist>.65):
            good=['DUB!','You getting carried','His back gonna hurt a bit','winner winner chicken dinner','Dude wins TOO MUCH','You aint even gotta try','GODLIKE']
            print (random.choice(good))
import requests
from getId import idcollect
from games import GAME
from wins import win_calc

#Key for riot API
Key = '**********************'

#ASKING USER FOR SUMMONER NAME
summonerName = input('Enter summoner name:')

#Objects
ids=idcollect()
game=GAME()
wins=win_calc()

#Collecting the acc id of summoner name
accId=ids.ID_collected(summonerName,Key)

#Collecting game id lists
game_list=[]
game_list=game.find_game_ids(accId,Key)

#Collecting wins list
win_list=[]
win_list=game.game_data(game_list,Key,summonerName)

#Calcuate whether the summoner is good or not
wins.is_dis_mane_good(win_list)





 
import requests


class GAME:


    def find_game_ids(self,accId,key):
        
        i=0
        GAMEID = []
        Idgame=20       
        url_match_list=('https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/'+(accId)+'?queue=420&endIndex=20&api_key='+(key))
        response2=requests.get(url_match_list)
        #Adding 20 games into the list
        while Idgame>0:
            GAMEID.append('https://na1.api.riotgames.com/lol/match/v4/matches/'+str(response2.json()['matches'][i]['gameId'])+'?api_key='+(key))
            i=i+1
            Idgame=Idgame-1

        return GAMEID


    def game_data(self,game_list,key,sumName):

        wins=[]
        deaths=[]
        deaths= []
        kills=[]
        assists=[]
        visions=[]
        csTotal=[]
        
        
        #Finding the data of said summoner in each game id
        for urls in game_list:

            
            response=requests.get(urls)
            Loop=0
            index=0
            while Loop<=10:
                
                if response.json()['participantIdentities'][index]['player']['summonerName']!=sumName:
                    Loop= Loop+1
                    index=index+1
                elif response.json()['participantIdentities'][index]['player']['summonerName']==sumName:
                    
                    deaths.append(response.json()['participants'][index]['stats']['deaths'])
                    kills.append(response.json()['participants'][index]['stats']['kills'])
                    assists.append(response.json()['participants'][index]['stats']['assists'])
                    visions.append(response.json()['participants'][index]['stats']['visionScore'])
                    csTotal.append(response.json()['participants'][index]['stats']['totalMinionsKilled'])
                    wins.append(response.json()['participants'][index]['stats']['win'])
                
                    break
        #Finding avg of each stat
        deaths=sum(deaths)/20            
        kills=sum(kills)/20
        assists=sum(assists)/20
        visions=sum(visions)/20
        csTotal=sum(csTotal)/20

        print('The avg kills is '+str(kills)+'\nThe avg deaths is '+str(deaths)+'\nThe avg assists is '+str(assists)+'\nThe avg visions is '+str(visions)+'\nThe avg cs total is '+str(csTotal))

        return wins






 
import requests

class idcollect:
    
    def ID_collected(self,sumName,key):
        #COLLECTING DATA TO BE INSERTING FOR MATCHLIST DATABASE
        url=('https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/'+(sumName)+'?api_key='+(key))
        response=requests.get(url)
        accId=(response.json()['accountId'])
        return accId





 
import random

class win_calc:


    def is_dis_mane_good(self,winlist):
        
        winlist=sum(winlist)/20

        if (winlist<.33):
            trash=['DIS MANE STINKS','run while you can','I repeat, YOU ARE NOT WINNING THIS','I predict a fat L','Have fun trying to carry this person','He is a walking trash can','He needs to find a new game','BAD LUCK!!!']
            print (random.choice(trash))

        elif (winlist>.33 and winlist<=.5):
            notgood=['Losing a bit','Not very good','He needs lots of help','Your back might hurt a little','Does not win much'] 
            print (random.choice(notgood))

        elif (winlist>.5 and winlist<=.65):
            ight=['He is ight','He can win a lil','You guys have a decent chance to win','Serviceable','Should be a dub']
            print (random.choice(ight))

        elif (winlist>.65):
            good=['DUB!','You getting carried','His back gonna hurt a bit','winner winner chicken dinner','Dude wins TOO MUCH','You aint even gotta try','GODLIKE']
            print (random.choice(good))
import requests
from getId import idcollect
from games import GAME
from wins import win_calc

#Key for riot API
Key = '**********************'

#ASKING USER FOR SUMMONER NAME
summonerName = input('Enter summoner name:')

#Objects
ids=idcollect()
game=GAME()
wins=win_calc()

#Collecting the acc id of summoner name
accId=ids.ID_collected(summonerName,Key)

#Collecting game id lists
game_list=[]
game_list=game.find_game_ids(accId,Key)

#Collecting wins list
win_list=[]
win_list=game.game_data(game_list,Key,summonerName)

#Calcuate whether the summoner is good or not
wins.is_dis_mane_good(win_list)
 
import requests


class GAME:


    def find_game_ids(self,accId,key):
        
        i=0
        GAMEID = []
        Idgame=20       
        url_match_list=('https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/'+(accId)+'?queue=420&endIndex=20&api_key='+(key))
        response2=requests.get(url_match_list)
        #Adding 20 games into the list
        while Idgame>0:
            GAMEID.append('https://na1.api.riotgames.com/lol/match/v4/matches/'+str(response2.json()['matches'][i]['gameId'])+'?api_key='+(key))
            i=i+1
            Idgame=Idgame-1

        return GAMEID


    def game_data(self,game_list,key,sumName):

        wins=[]
        deaths=[]
        deaths= []
        kills=[]
        assists=[]
        visions=[]
        csTotal=[]
        
        
        #Finding the data of said summoner in each game id
        for urls in game_list:

            
            response=requests.get(urls)
            Loop=0
            index=0
            while Loop<=10:
                
                if response.json()['participantIdentities'][index]['player']['summonerName']!=sumName:
                    Loop= Loop+1
                    index=index+1
                elif response.json()['participantIdentities'][index]['player']['summonerName']==sumName:
                    
                    deaths.append(response.json()['participants'][index]['stats']['deaths'])
                    kills.append(response.json()['participants'][index]['stats']['kills'])
                    assists.append(response.json()['participants'][index]['stats']['assists'])
                    visions.append(response.json()['participants'][index]['stats']['visionScore'])
                    csTotal.append(response.json()['participants'][index]['stats']['totalMinionsKilled'])
                    wins.append(response.json()['participants'][index]['stats']['win'])
                
                    break
        #Finding avg of each stat
        deaths=sum(deaths)/20            
        kills=sum(kills)/20
        assists=sum(assists)/20
        visions=sum(visions)/20
        csTotal=sum(csTotal)/20

        print('The avg kills is '+str(kills)+'\nThe avg deaths is '+str(deaths)+'\nThe avg assists is '+str(assists)+'\nThe avg visions is '+str(visions)+'\nThe avg cs total is '+str(csTotal))

        return wins
 
import requests

class idcollect:
    
    def ID_collected(self,sumName,key):
        #COLLECTING DATA TO BE INSERTING FOR MATCHLIST DATABASE
        url=('https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/'+(sumName)+'?api_key='+(key))
        response=requests.get(url)
        accId=(response.json()['accountId'])
        return accId
 
import random

class win_calc:


    def is_dis_mane_good(self,winlist):
        
        winlist=sum(winlist)/20

        if (winlist<.33):
            trash=['DIS MANE STINKS','run while you can','I repeat, YOU ARE NOT WINNING THIS','I predict a fat L','Have fun trying to carry this person','He is a walking trash can','He needs to find a new game','BAD LUCK!!!']
            print (random.choice(trash))

        elif (winlist>.33 and winlist<=.5):
            notgood=['Losing a bit','Not very good','He needs lots of help','Your back might hurt a little','Does not win much'] 
            print (random.choice(notgood))

        elif (winlist>.5 and winlist<=.65):
            ight=['He is ight','He can win a lil','You guys have a decent chance to win','Serviceable','Should be a dub']
            print (random.choice(ight))

        elif (winlist>.65):
            good=['DUB!','You getting carried','His back gonna hurt a bit','winner winner chicken dinner','Dude wins TOO MUCH','You aint even gotta try','GODLIKE']
            print (random.choice(good))
Source Link
Loading