def test_summonersrift_map(): summoner = Summoner(name='Kalturi', region='NA') match = summoner.match_history(queues=[Queue.ranked_solo_fives])[0] for frame in match.timeline.frames: for event in frame.events: if event.type == 'CHAMPION_KILL': SummonersRiftArea.from_position(event.position)
async def display_game_summary(message: Message) -> None: summoner_name = re.compile("/gamesummary (.*)").match( message.content).group(1) summoner = Summoner(name=summoner_name, region="NA") player_match_history = summoner.match_history() output = "```" output += "{:>18} {:>14} {:>14} {:>15} {:>16}".format( "SUMMONER", "KILLS", "DEATHS", "ASSISTS", "KDA") + "\n" output += LeagueClientHelper.display_team_info( player_match_history[0].blue_team.participants) output += "----------------------------------------------------------------------------------\n" output += LeagueClientHelper.display_team_info( player_match_history[0].red_team.participants) output += "```" await message.channel.send(output) Logger.log('Outputting Game Summary for: {summoner_name}')
def print_newest_match(name: str, region: str): summoner = Summoner(name=name, region=region) match_history = summoner.match_history( queues={cass.Queue.ranked_solo_fives}) match = match_history[0] print("Match ID:", match.id) print("Frame interval:", match.timeline.frame_interval) # The cumulative timeline property allows you to get some info about participants during the match. # You access the cumulative timeline by providing the duration into the game that you want the info for. # In this case, we're accessing the game at 15 minutes and 30 seconds. # Some data is only available every one minute. p = match.participants[summoner] p_state = p.cumulative_timeline[datetime.timedelta(minutes=15, seconds=30)] # You can also use a string instead of datetime.timedelta p_state = p.cumulative_timeline["15:30"] items = p_state.items items = [item.name for item in items] skills = p_state.skills print("Champion:", p.champion.name) print("Items:", items) print("Skills:", skills) print("Kills:", p_state.kills) print("Deaths:", p_state.deaths) print("Assists:", p_state.assists) print("KDA:", p_state.kda) print("Level:", p_state.level) print("Position:", p_state.position) print("Exp:", p_state.experience) print("Number of objectives assisted in:", p_state.objectives) print("Gold earned:", p_state.gold_earned) print("Current gold:", p_state.current_gold) print("CS:", p_state.creep_score) print("CS in jungle:", p_state.neutral_minions_killed)
async def on_message(message): # ignore message from itself if message.author == client.user: return # extract content args = message.content.split() # check for search command if args[0] == config.prefix + 'search': # if there is no username, return if (len(args) == 1): return await message.channel.send('Incorrect usage! You need to supply a username as well!') # prepare name spaces = ' ' args.pop(0) username = spaces.join(args) # just for console print('The extracted username is: ' + username) # send notice await message.channel.send('Let me check...') # create summoner object print('Attempting to create summoner object (Region NA)..') summoner_name = Summoner(name=username, region="NA") # attempt to look up match history print('Attempting to look up match history...') try: match_hist = summoner_name.match_history(begin_time=Patch.from_str("10.7", region="NA").start) except Exception as e: print(e) return await message.channel.send('That username does not exist!') # check if you are looking for a win streak or a loss streak looking_for_win = False if (match_hist[0].participants[summoner_name].team.win is True): looking_for_win = True # count match streak match_counter = 1 while (True): next_turnout = match_hist[match_counter].participants[summoner_name].team.win if (looking_for_win and not next_turnout) or (not looking_for_win and next_turnout): break match_counter += 1 # print results print('Printing out result for ' + username) if looking_for_win: return await message.channel.send(username + ' is on a ' + str(match_counter) + ' game winning streak.') else: return await message.channel.send(username + ' is on a ' + str(match_counter) + ' game losing streak.') # if user supplied help command, show search if args[0] == config.prefix + 'help': return await message.channel.send('The proper command is `' + config.prefix + 'search <username>`.') # if user supplied invalid command, show search if args[0][0:2] == config.prefix: return await message.channel.send('Invalid usage! Do `' + config.prefix + 'search <username>`.')
def get_comps(summoners): if len(summoners) < 5: # return None pass champion_pool = [] # Maps names to champions so we don't have to make individual calls to the API name_mapping = { champion.id: champion.name for champion in cass.get_champions(region=region) } count = 0 for player in summoners: if count == 0: position = 'TOP' elif count == 1: position = 'JUNGLE' elif count == 2: position = 'MIDDLE' elif count == 3: position = 'BOTTOM' elif count == 4: position = 'UTILITY' # Summoner specific data summoner = Summoner(name=player, region=region) champion_details = get_champion_details( get_match_stats( summoner.match_history( begin_time=Patch.from_str(start_patch).start, end_time=Patch.from_str(end_patch).end, queues={Queue.ranked_solo_fives}), summoner, name_mapping), position) champion_pool += champion_details count += 1 viable_comps = [] for comp in generate_team_comps(champion_pool): is_viable = is_viable_comp(comp) if is_viable: for champion in comp: if champion['role'] == 'TOP': top = champion elif champion['role'] == 'JUNGLE': jungle = champion elif champion['role'] == 'MIDDLE': middle = champion elif champion['role'] == 'BOTTOM': bottom = champion else: support = champion viable_comp = TeamComposition(top=top, jungle=jungle, mid=middle, bot=bottom, support=support) rating = viable_comp.assess_comp() if rating['score'] == 100: viable_comps.append({ 'champions': viable_comp, 'rating': rating['score'], 'full_score': rating['full_score'] }) else: continue viable_comps = sorted(random.sample(viable_comps, len(viable_comps)), key=lambda i: i['full_score'], reverse=True) return viable_comps[0:20]