Beispiel #1
0
    def stats(self, mess, args):
        """The ranked win rate and KDA"""

        summ_id = self.get_player_id(mess)
        teams = RiotAPI.get_teams(summ_id)
        if teams is None:
            return "You must be in a game to check stats"
        friendly, enemies = teams

        self.send_simple_reply(mess, "Looking up stats...")

        lines = ["Your team:"]
        for summonerID, champID in friendly.iteritems():
            champ_stats = RiotAPI.get_stats(summonerID, champID)
            to_send = ">>" + RiotAPI.get_champion_name(champID) + ": "
            to_send += self.format_stats(champ_stats)
            lines += [to_send]

        lines += ["Enemy team:"]
        for summonerID, champID  in enemies.iteritems():
            champ_stats = RiotAPI.get_stats(summonerID, champID)
            to_send = ">>" + RiotAPI.get_champion_name(champID) + ": "
            to_send += self.format_stats(champ_stats)
            lines += [to_send]

        pprint(lines)
        # Send response to user
        for line in lines[:-1]:
            self.send_simple_reply(mess, line)
            time.sleep(0.25)
        self.send_simple_reply(mess, lines[-1])
Beispiel #2
0
def result(request):

	# Grab summoner name from form when submitted
	if request.method == 'POST':
		form = summonerForm(request.POST)
		data = request.POST.get('summoner')

	# Grab summoner information
	summoner = data
	summonerName = RiotAPI.formatSummonerName(summoner)
	summonerDict = RiotAPI.getSummoner(summonerName)

	# Grab match data for summoner
	summonerID = summonerDict['accountId']
	summonerIcon = summonerDict['profileIconId']
	recentGames = RiotAPI.getRecentMatches(summonerID)

	length = len(recentGames)

	return render(request, 'Match_History/result.html', {
		'summoner': summoner,
		'id' : summonerID,
		'icon' : summonerIcon,
		'recent' : recentGames,
		'length' : length,
		'form' : form
	})
Beispiel #3
0
def search_summoner(APIKey):
        region = 'kr'#(str)(input('Region: '))
        summonerName = 'timon'#(str)(input('Summoner Name: '))

        summonerDataJSON = api.getSummonerData(region,summonerName,APIKey)
        summonerID = str(summonerDataJSON['id'])
        jsonData = api.getPositionsData(region, summonerID, APIKey)
        print_pretty_json(jsonData)
Beispiel #4
0
def challenger_crawl(APIKey):
        challengerData = api.getChallengerLeaguesData('kr','RANKED_SOLO_5x5',APIKey)
        masterData = api.getMasterLeaguesData('kr','RANKED_SOLO_5x5',APIKey)

        challengerEntries = challengerData['entries']
        masterEntries = masterData['entries']

        with open('ma_chal.csv', 'w', encoding='utf-8', newline='') as f:
                wr = csv.writer(f)

                for data in challengerEntries:
                        wr.writerow([data['playerOrTeamId'], data['playerOrTeamName']])
                for data in masterEntries:
                        wr.writerow([data['playerOrTeamId'], data['playerOrTeamName']])
Beispiel #5
0
    def tilt(self, mess, args):
        """The win/loss history each player's recent games"""

        summ_id = self.get_player_id(mess)
        num_hours = 12
        if len(args.split()) > 0:
            try:
                num_hours = int(args.split()[0])
            except ValueError:
                pass

        teams = RiotAPI.get_teams(summ_id)
        if teams is None:
            return "You must be in a game to check match history"
        friendly, enemies = teams

        self.send_simple_reply(mess, "Looking up match history...")

        lines = ["Match history for the last %d hours:" % num_hours]
        lines += ["Your team:"]
        for summonerID, champID in friendly.iteritems():
            to_send = ">>" + RiotAPI.get_champion_name(champID) + ": "
            to_send += RiotAPI.get_recent_winrate(summonerID,
                                                  num_hours * TIME_HOUR)
            lines += [to_send]

        lines += ["Enemy team:"]
        for summonerID, champID in enemies.iteritems():
            to_send = ">>" + RiotAPI.get_champion_name(champID) + ": "
            to_send += RiotAPI.get_recent_winrate(summonerID,
                                                  num_hours * TIME_HOUR)
            lines += [to_send]

        pprint(lines)
        # Send response to user
        for line in lines[:-1]:
            self.send_simple_reply(mess, line)
            time.sleep(0.25)
        self.send_simple_reply(mess, lines[-1])
Beispiel #6
0
def crawl_complete_matchlist(summoner_id,  region, APIKey):
        more_matches=True

        ## Start with empty matchlist
        matchlist={"matches": [], "totalGames": 0}
        begin_index=0
        while more_matches:
                new_matchlist = api.getMatchListsToIndex(region, summoner_id, begin_index, begin_index + MATCHLIST_PAGE_LIMIT, APIKey)
                if "matches" in new_matchlist.keys():
                        matchlist["matches"] = matchlist["matches"] + new_matchlist["matches"]
                        matchlist["totalGames"] = matchlist["totalGames"] + new_matchlist["totalGames"]
                        begin_index += MATCHLIST_PAGE_LIMIT
                else:
                        more_matches=False
Beispiel #7
0
import RiotAPI
import sys
import pprint
import time

max_depth = 6
user_ids = []
usernames = []
used_user_ids = []
used_game_ids = []
api = RiotAPI.riotAPI('e2a3eff8-772e-4e7a-a7c0-52edda53d1bc')


def restart_line():
    sys.stdout.write('\r')
    sys.stdout.flush()


def parse_WR(game):

    game_state = str(game['stats']['win'])
    game_state[0].upper()
    result = int(game_state == 'True') ^ int(game['stats']['team'] / 100)

    if result & 1:
        winner = 200
    else:
        winner = 100

    teamwin = []
    teamlose = []
Beispiel #8
0
                    'cid2': int(winner),
                    'c1wins': 0,
                    'c2wins': 1
                })
    # Get users in current game and return them
    for player in current_Game['fellowPlayers']:
        user_Ids.append(player['summonerId'])
    return user_Ids


# Handling command line argument
clargs = sys.argv
clargs.pop(0)

# Api initialisation
api = RiotAPI.RiotAPI(clargs[0])
clargs.pop(0)

# Rate limit Setting
rate_Limit = float(clargs[0])
clargs.pop(0)

# Setting maximum depth
max_Depth = int(clargs[0])
clargs.pop(0)

# Whether to resume from saved details
if int(clargs[0]) == 1:
    # Open files and fill the used arrays with the details
    with open('used_games', 'r') as used_Games_File:
        for line in used_Games_File:
Beispiel #9
0
import RiotAPI
import sys
import pprint
import time

max_depth = 6
user_ids = []
usernames = []
used_user_ids = []
used_game_ids = []
api = RiotAPI.riotAPI('e2a3eff8-772e-4e7a-a7c0-52edda53d1bc')

def restart_line():
    sys.stdout.write('\r')
    sys.stdout.flush()

def parse_WR(game):

    game_state = str(game['stats']['win'])
    game_state[0].upper()
    result = int(game_state == 'True') ^ int(game['stats']['team'] / 100)

    if result & 1:
        winner = 200
    else:
        winner = 100

    teamwin = []
    teamlose = []

    for player in game['fellowPlayers']:
Beispiel #10
0
    """Function that returns the date and time of a given game by converting from milliseconds from epoch
    input: json_index from getRecentGames ex: getRecentGames[0] for most recent game
    output: integer of end game in milliseconds from epoch
    """
    return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(end_date/1000 - time_played))[5:16]

def getIP(json_index):
    return json_index['ipEarned']


def check_date(dateOne, dateTwo):
    return dateOne == dateTwo

def sum_daily_ip(recentGames, date):
    sum1 = 0
    for i in range(len(recentGames)):
        current = recentGames[i]
        time_played = getTimePlayed(current)
        end_date = getEndDate(current)
        if check_date(getDateOfGame(time_played, end_date),date):
            sum1 += getIP(current)
    return sum1

######Unit tesiting area######
if __name__ == "__main__":
    my_id = RA.getSummonerID(["BruttonGuster"])
    x = RA.getRecentGames(my_id[0])['games']
    print(x)
    print(getDateOfGame(getTimePlayed(x[9]), getEndDate(x[9])))
    print(sum_daily_ip(x,"08 Mar 2017"))