def main(): # Pull the data champion_roles = pull_data() # Use individual champions darius = Champion(name='Darius', region='NA') leesin = Champion(name='Lee Sin', region='NA') syndra = Champion(name='Syndra', region='NA') draven = Champion(name='Draven', region='NA') braum = Champion(name='Braum', region='NA') champions = [darius, leesin, syndra, draven, braum] roles = get_champion_roles(champions, top=darius, champion_roles=champion_roles) print({role.name: champion.name for role, champion in roles.items()}) # Use Cassiopeia's match.blue_team and/or match.red_team objects summoner = Summoner(name="Kalturi", region="NA") for match in summoner.match_history: roles = get_team_roles(match.blue_team, champion_roles) print({role.name: champion.name for role, champion in roles.items()}) roles = get_team_roles(match.red_team, champion_roles) print({role.name: champion.name for role, champion in roles.items()}) break
async def item(self, champ): champion = Champion(name=champ) for spell in champion.spells: await self.bot.say(spell.name) await self.bot.say(spell.keywords) await self.bot.say("--------")
def test_champions(): champions = Champions(region="NA") for champion in champions: champion.name, champion.id annie = Champion(name="Annie", region="NA") annie.name annie.title for spell in annie.spells: spell.name, spell.keywords annie.info.difficulty annie.passive.name {item.name: count for item, count in annie.recommended_itemsets[0].item_sets[0].items.items()} annie.free_to_play annie._Ghost__all_loaded ziggs = cass.get_champion("Ziggs", region="NA") ziggs.name ziggs.region {item.name: count for item, count in ziggs.recommended_itemsets[0].item_sets[0].items.items()} ziggs.free_to_play for spell in ziggs.spells: for var in spell.variables: spell.name, var ziggs._Ghost__all_loaded
def get_champions(): lux = Champion(name="Lux", id=99, region="NA") print(lux.name) print(lux.championgg.elo) print(lux.championgg.patch) # Lux mid vs. Lux support win rates print(lux.championgg[Role.middle].win_rate) print(lux.championgg[Role.support].win_rate) # Print a bunch of data print(lux.championgg[Role.support].play_rate) print(lux.championgg[Role.support].play_rate_by_role) print(lux.championgg[Role.support].ban_rate) print(lux.championgg[Role.support].games_played) print(lux.championgg[Role.support].damage_composition) print(lux.championgg[Role.support].kills) print(lux.championgg[Role.support].total_damage_taken) print(lux.championgg[Role.support].neutral_minions_killed_in_team_jungle) print(lux.championgg[Role.support].assists) print(lux.championgg[Role.support].neutral_minions_killed_in_enemy_jungle) print(lux.championgg[Role.support].gold_earned) print(lux.championgg[Role.support].deaths) print(lux.championgg[Role.support].minions_killed) print(lux.championgg[Role.support].total_healed) # Get matchup data for Lux mid # (This takes a minute to run the first time but is ~ instantaneous thereafter) for matchup in lux.championgg[Role.middle].matchups: if matchup.nmatches > 100: print( f"{matchup.enemy.champion.name}: {round(matchup.winrate*100)}% ({matchup.nmatches} matches analyzed)" )
async def masteryrole(self, ctx: commands.Context, region: as_region, *, name: str) -> None: """Assign a role for your mastery score.""" async with db_cursor(self.dsn) as cursor: await cursor.execute( "SELECT id FROM champions WHERE guild_id = %s", (ctx.message.guild.id, )) champion_row = await cursor.fetchone() if champion_row is None: await ctx.channel.send( ":x: no champion configured for this guild") return champion = Champion(id=champion_row[0], region=region) summoner = Summoner(name=name, region=region) masterygetter = functools.partial( cassiopeia.get_champion_mastery, champion=champion, summoner=summoner, region=region, ) loop = asyncio.get_event_loop() mastery = await loop.run_in_executor(None, masterygetter) matching_role = find_matching_role(mastery.points) print(f"giving {ctx.message.author} role {matching_role} for " f"{mastery.points:,} points on {name} in {region.value}") await ctx.message.author.add_roles( discord.Object(id=matching_role), reason= f"mastery score of {mastery.points:,} on {name} in {region.value}", ) await ctx.send(":ok_hand: role added!")
def get_team_roles(team: Team, champion_roles=None): roles = _get_team_roles(team, champion_roles)[0] roles = { role: Champion(id=id_, region="NA") for role, id_ in roles.items() } return roles
def get_champions(): # annie = Champion(name="Annie", region="NA") annie = Champion(name="Annie") print(annie.name) print(annie.title) for spell in annie.spells: print(spell.name, spell.keywords) print(annie.info.difficulty) print(annie.passive.name) print({ item.name: count for item, count in annie.recommended_itemsets[0].item_sets[0].items.items() }) print(annie.free_to_play) print(annie._Ghost__all_loaded) print(annie) # ziggs = cass.get_champion(region="NA", "Ziggs") ziggs = cass.get_champion("Ziggs") print(ziggs.name) print(ziggs.region) print({ item.name: count for item, count in ziggs.recommended_itemsets[0].item_sets[0].items.items() }) print(ziggs.free_to_play) for spell in ziggs.spells: for var in spell.variables: print(spell.name, var) print(ziggs._Ghost__all_loaded)
async def getChamps(self, champ): # annie = Champion(name="Annie", region="NA") champion = Champion(name=champ) await self.bot.say(champion.name) await self.bot.say(champion.title) for spell in champion.spells: await self.bot.say(spell.name) await self.bot.say(spell.keywords) await self.bot.say(champion.info.difficulty) await self.bot.say(champion.passive.name) await self.bot.say({item.name: count for item, count in champion.recommended_itemsets[0].item_sets[0].items.items()}) await self.bot.say(champion._Ghost__all_loaded) await self.bot.say(champion.blurb) await self.bot.say("Thank you, come again!")
def get_champion_roles(composition: List[Union["Champion", str, int]], top=None, jungle=None, middle=None, bottom=None, utility=None, champion_roles=None): if champion_roles is None: champion_roles = pull_data() from cassiopeia import Champion # Shallow copy so we don't modify the list in-place composition = [champion for champion in composition] for i, champion in enumerate(composition): if isinstance(champion, str): composition[i] = Champion(name=champion, region='NA').id elif isinstance(champion, Champion): composition[i] = champion.id if isinstance(top, str): top = Champion(name=top, region='NA').id elif isinstance(top, Champion): top = top.id if isinstance(jungle, str): jungle = Champion(name=jungle, region='NA').id elif isinstance(jungle, Champion): jungle = jungle.id if isinstance(middle, str): middle = Champion(name=middle, region='NA').id elif isinstance(middle, Champion): middle = middle.id if isinstance(bottom, str): bottom = Champion(name=bottom, region='NA').id elif isinstance(bottom, Champion): bottom = bottom.id if isinstance(utility, str): utility = Champion(name=utility, region='NA').id elif isinstance(utility, Champion): utility = utility.id positions = get_roles(champion_roles, composition, top, jungle, middle, bottom, utility) positions = { Position(position): Champion(id=id_, region='NA') for position, id_ in positions.items() } return positions
def get_champions(): cls() camp = input('Insira o nome do campeão -> ') annie = Champion(name=camp, region="BR") print(f""" Campeão: {annie.name} Dano de ataque: {annie.stats.attack_damage} (+{annie.stats.attack_damage_per_level} por nível) Vida: {annie.stats.health} (+{annie.stats.health_per_level} por nível) Mana: {annie.stats.mana} (+{annie.stats.mana_per_level} por nível) Armadura: {annie.stats.armor} (+{annie.stats.armor_per_level} por nível) Resistência mágica: {annie.stats.magic_resist} (+{annie.stats.magic_resist_per_level} por nível) """) input('aperte enter para contiuar')
async def get_champion_mastery(self, champion, region, msg) -> ChampionMastery: """Returns ChampionMastery object""" try: champion = Champion(name=champion, region="NA") mastery = ChampionMastery(summoner=self.summoner, champion=champion, region=region) mastery.points return mastery except TypeError as exception: await Exceptions().raise_exception(self.ctx, exception, "cm", msg, champion) return except APIRequestError as exception: await Exceptions().raise_exception(self.ctx, exception, "", msg, None) return
def get_champions(): champions = Champions(region="NA") for champion in champions: print(champion.name, champion.id) # annie = Champion(name="Annie", region="NA") annie = Champion(name="Annie", region="NA") print(annie.name) print(annie.title) for spell in annie.spells: print(spell.name, spell.keywords) print(annie.info.difficulty) print(annie.passive.name) print({item.name: count for item, count in annie.recommended_itemsets[0].item_sets[0].items.items()}) print(annie.free_to_play) print(annie.win_rates)
def test_championmastery(): me = Summoner(name="Kalturi", id=21359666, region="NA") karma = Champion(name="Karma", id=43, region="NA") cm = ChampionMastery(champion=karma, summoner=me, region="NA") cm = cass.get_champion_mastery(champion=karma, summoner=me, region="NA") 'Champion ID:', cm.champion.id 'Mastery points:', cm.points 'Mastery Level:', cm.level 'Points until next level:', cm.points_until_next_level cms = cass.get_champion_masteries(summoner=me, region="NA") cms = me.champion_masteries cms[0].points cms["Karma"].points # Does a ton of calls without a cache "{} has mastery level 6 or higher on:".format(me.name) pro = cms.filter(lambda cm: cm.level >= 6) [cm.champion.name for cm in pro]
def test_championgg(): syndra = Champion(name="Syndra", region="NA") syndra.name syndra.championgg[Role.middle].win_rate syndra.championgg[Role.middle].play_rate syndra.championgg[Role.middle].play_rate_by_role syndra.championgg[Role.middle].ban_rate syndra.championgg[Role.middle].games_played syndra.championgg[Role.middle].damage_composition syndra.championgg[Role.middle].kills syndra.championgg[Role.middle].total_damage_taken syndra.championgg[Role.middle].neutral_minions_killed_in_team_jungle syndra.championgg[Role.middle].assists syndra.championgg[Role.middle].neutral_minions_killed_in_enemy_jungle syndra.championgg[Role.middle].gold_earned syndra.championgg[Role.middle].deaths syndra.championgg[Role.middle].minions_killed syndra.championgg[Role.middle].total_healed syndra.championgg[Role.middle].championgg_metadata["elo"] syndra.championgg[Role.middle].championgg_metadata["patch"]
def get_team_roles(team: Team, champion_roles=None): if champion_roles is None: champion_roles = pull_data() champions = [participant.champion.id for participant in team.participants] smite = None for participant in team.participants: if participant.summoner_spell_d.id == 11 or participant.summoner_spell_f.id == 11: if smite is None: smite = participant.champion.id else: smite = None if smite is None: positions = get_roles(champion_roles, champions) else: positions = get_roles(champion_roles, champions, jungle=smite) positions = { Position(position): Champion(id=id_, region='NA') for position, id_ in positions.items() } return positions
def test_championgg(): if not "CHAMPIONGG_KEY" in os.environ: pytest.xfail("No championgg key provided") syndra = Champion(name="Syndra", region="NA") syndra.name syndra.championgg[Role.middle].win_rate syndra.championgg[Role.middle].play_rate syndra.championgg[Role.middle].play_rate_by_role syndra.championgg[Role.middle].ban_rate syndra.championgg[Role.middle].games_played syndra.championgg[Role.middle].damage_composition syndra.championgg[Role.middle].kills syndra.championgg[Role.middle].total_damage_taken syndra.championgg[Role.middle].neutral_minions_killed_in_team_jungle syndra.championgg[Role.middle].assists syndra.championgg[Role.middle].neutral_minions_killed_in_enemy_jungle syndra.championgg[Role.middle].gold_earned syndra.championgg[Role.middle].deaths syndra.championgg[Role.middle].minions_killed syndra.championgg[Role.middle].total_healed syndra.championgg[Role.middle].championgg_metadata["elo"] syndra.championgg[Role.middle].championgg_metadata["patch"]
def print_champion_mastery(): # Name: Kalturi # ID: 21359666 # Account ID: 34718348 me = Summoner(name="Kalturi", id=21359666) karma = Champion(name="Karma", id=43) #cm = ChampionMastery(champion=karma, summoner=me) cm = cass.get_champion_mastery(champion=karma, summoner=me) print('Champion ID:', cm.champion.id) print('Mastery points:', cm.points) print('Mastery Level:', cm.level) print('Points until next level:', cm.points_until_next_level) cms = cass.get_champion_masteries(summoner=me) cms = me.champion_masteries print(cms[0].points) # print(cms["Karma"].points) # Does a ton of calls without a cache print("{} has mastery level 6 or higher on:".format(me.name)) pro = cms.filter(lambda cm: cm.level >= 6) print([cm.champion.name for cm in pro])
def test_championgg(): annie = Champion(name="Annie", id=1, region="NA") annie.name annie.championgg.win_rate annie.championgg.play_rate annie.championgg.play_rate_by_role annie.championgg.ban_rate annie.championgg.games_played annie.championgg.damage_composition annie.championgg.kills annie.championgg.total_damage_taken annie.championgg.wards_killed annie.championgg.neutral_minions_killed_in_team_jungle annie.championgg.assists annie.championgg.performance_score annie.championgg.neutral_minions_killed_in_enemy_jungle annie.championgg.gold_earned annie.championgg.deaths annie.championgg.minions_killed annie.championgg.total_healed annie.championgg.championgg_metadata["elo"] annie.championgg.championgg_metadata["patch"]
async def champion_information(self, ctx, champ): """Provide the champion name you want after command and it will provide a link for the wikipedia page on said champ. This command is still in progress, so please put multi-word names in quotes.""" try: champion = Champion(name=champ.title(), region=region) champion.blurb # call to trigger exception if not found except NotFoundError: await ctx.send( "Sorry, that champion could not be found. Please make sure you spelled the name correctly." ) wiki_champ_name = champion.name.replace(' ', '_').replace('\'', '%27') # create embed embed = discord.Embed( title=f'{champion.name}, {champion.title}', url= f'https://leagueoflegends.fandom.com/wiki/{wiki_champ_name}/LoL', description=f'{champion.blurb}') embed.set_thumbnail( url= f'http://ddragon.leagueoflegends.com/cdn/11.4.1/img/champion/{champion.name}.png' ) embed.add_field(name='Passive', value=champion.passive.description) embed.add_field(name='Q', value=champion.spells[0].description, inline=False) embed.add_field(name='W', value=champion.spells[1].description, inline=False) embed.add_field(name='E', value=champion.spells[2].description, inline=False) embed.add_field(name='R', value=champion.spells[3].description, inline=False) await ctx.send(embed=embed)
def get_champion_details(champion_stats, position): champion_details = [] # Retrieve mtg and team comp roles for champion in champion_stats: champion_obj = Champion(name=champion[0], region=region) champion_role = get_champion_role(champion_obj) if champion_role != position: continue similar_champions = get_similar_champions(champion_obj, position, strict=True) if len(similar_champions) < 2: similar_champions = get_similar_champions(champion_obj, position, lenient=True) filtered_similar = [] for champion in similar_champions: if champion.name != champion_obj.name: filtered_similar.append(champion) champion_details.append({ 'name': champion_obj.name, 'similar': filtered_similar, 'role': position }) return champion_details[0:6]
def get_similar_champions(champion, position, strict=False, lenient=False): champion_detail = ChampionRole.query.filter_by(name=champion.name).first() query = {} if strict: # find similar champions based on strict similarity for column in champion_detail.__table__.columns: v = str(getattr(champion_detail, column.name)) # Match roles, power spikes, damage type, mtg color if v in ("1", 'PHYSICAL', 'MAGICAL', 'UTILITY', 'X'): query[column.name] = str(getattr(champion_detail, column.name)) elif lenient: for column in champion_detail.__table__.columns: v = str(getattr(champion_detail, column.name)) if v in ("1", 'PHYSICAL', 'MAGICAL', 'UTILITY'): # Ignore power spikes if column.name != 'early_game' and column.name != 'mid_game' and column.name != 'late_game': query[column.name] = str( getattr(champion_detail, column.name)) else: return print( "You gotta identify what strength the search is using my dude.") similar_champions = ChampionRole.query.filter_by(**query).all() similar_and_same_role = [] for x in similar_champions: champion_role = get_champion_role(Champion(name=x.name, region=region)) if champion_role == position: similar_and_same_role.append(x) return similar_and_same_role
async def table_build(self, ctx: commands.Context) -> None: """Build the mastery table.""" if ctx.message.guild.id in self.builds_running: await ctx.channel.send("build already running") return self.builds_running.add(ctx.message.guild.id) try: async with db_cursor(self.dsn) as cursor: await cursor.execute( "SELECT entry_id, id FROM champions WHERE guild_id = %s", (ctx.message.guild.id, ), ) champion_row = await cursor.fetchone() if champion_row is None: await ctx.channel.send( ":x: guild champion must be configured first") return None await cursor.execute( "SELECT entry_id, id, upper(platform::text) FROM summoners WHERE guild_id = %s", (ctx.message.guild.id, ), ) summoners = await cursor.fetchall() if not summoners: await ctx.channel.send(":x: no summoners added") return None await ctx.channel.send( f":ok: starting build for {len(summoners)} summoners") if len(summoners) >= 20: await ctx.channel.send( f":information_source: this will take a while, why not go {go_for_phrase()}?" ) champion = Champion(id=champion_row[1], region=Platform(summoners[0][2]).region) masteries = [] loop = asyncio.get_event_loop() for (entry_id, id_, platform) in summoners: region = Platform(platform).region summoner = Summoner(id=id_, region=region) masterygetter = functools.partial( cassiopeia.get_champion_mastery, champion=champion, summoner=summoner, region=region, ) mastery = await loop.run_in_executor(None, masterygetter) summoner_name = await loop.run_in_executor( None, lambda: summoner.name) # Do not add users with score of 0 if mastery.points: masteries.append( (summoner_name, region.value, mastery.points)) query = (""" INSERT INTO summoner_champion_masteries (champion_entry, summoner_entry, score, last_change) VALUES (%s, %s, %s, %s) ON CONFLICT (champion_entry, summoner_entry) DO UPDATE SET last_change = EXCLUDED.last_change, score = EXCLUDED.score """) await cursor.execute( query, (champion_row[0], entry_id, mastery.points, mastery.last_played.datetime)) else: # Remove users who never played the champion await cursor.execute( "DELETE FROM summoners WHERE entry_id = %s", (entry_id, )) await ctx.channel.send( f":information_source: player `{summoner.name}` on " f"`{region.value}` never played `{champion.name}`, " "automatically dropped from table") print( f"auto-drop {summoner.name} on {region.value} (eid={entry_id})" ) sorted_masteries = sorted(masteries, key=operator.itemgetter(2), reverse=True) head = [ r'\# | Name | Region | Points', '---:|------|--------|-------', ] for position, (name, region, points) in enumerate(sorted_masteries, start=1): head.append(f'{position} | {name} | {region} | {points:,}') output = io.BytesIO('\n'.join(head).encode()) table = discord.File(fp=output, filename='table.txt') await ctx.channel.send(":receipt: build done", file=table) except Exception: await ctx.channel.send( f":warning: sorry, something crashed. congratulations <@{ctx.bot.owner_id}>" ) raise finally: self.builds_running.remove(ctx.message.guild.id)
def getChampionInfo(self, championName): champ = Champion(name = championName, region = self.region) print(champ.name) return champ
async def title(self, champ): """This does stuff!""" champion = Champion(name=champ) await self.bot.say(champion.title)
def get_roles(champion_roles, composition: List[Union[Champion, str, int]], top=None, jungle=None, middle=None, adc=None, support=None, verbose=False): """ Returns a dictionary with keys Top, Jungle, Middle, ADC, Support and values as names of the input champions. """ if isinstance(composition[0], Champion): region = composition[0].region else: region = 'NA' if isinstance(composition[0], str): composition = [ Champion(name=name, region='NA').id for name in composition ] elif isinstance(composition[0], Champion): composition = [champion.id for champion in composition] if isinstance(top, str): top = Champion(name=top, region='NA').id elif isinstance(top, Champion): top = top.id if isinstance(jungle, str): jungle = Champion(name=jungle, region='NA').id elif isinstance(jungle, Champion): jungle = jungle.id if isinstance(middle, str): middle = Champion(name=middle, region='NA').id elif isinstance(middle, Champion): middle = middle.id if isinstance(adc, str): adc = Champion(name=adc, region='NA').id elif isinstance(adc, Champion): adc = adc.id if isinstance(support, str): support = Champion(name=support, region='NA').id elif isinstance(support, Champion): support = support.id second_best_metric = -float('inf') second_best_roles = None second_best_play_percents = None if None not in [top, jungle, middle, adc, support]: best_roles = { Role.top: top, Role.jungle: jungle, Role.middle: middle, Role.adc: adc, Role.support: support } best_play_percents = { top: champion_roles[top][Role.top], jungle: champion_roles[jungle][Role.jungle], middle: champion_roles[middle][Role.middle], adc: champion_roles[adc][Role.adc], support: champion_roles[support][Role.support], } best_metric = sum(v for v in best_play_percents.values()) / 5 else: best_roles = { Role.top: composition[0], Role.jungle: composition[1], Role.middle: composition[2], Role.adc: composition[3], Role.support: composition[4] } best_play_percents = { composition[0]: champion_roles[composition[0]][Role.top], composition[1]: champion_roles[composition[1]][Role.jungle], composition[2]: champion_roles[composition[2]][Role.middle], composition[3]: champion_roles[composition[3]][Role.adc], composition[4]: champion_roles[composition[4]][Role.support], } best_metric = sum(v for v in best_play_percents.values()) / 5 second_best_roles = { Role.top: composition[0], Role.jungle: composition[1], Role.middle: composition[2], Role.adc: composition[3], Role.support: composition[4] } second_best_play_percents = { composition[0]: champion_roles[composition[0]][Role.top], composition[1]: champion_roles[composition[1]][Role.jungle], composition[2]: champion_roles[composition[2]][Role.middle], composition[3]: champion_roles[composition[3]][Role.adc], composition[4]: champion_roles[composition[4]][Role.support], } second_best_metric = sum(v for v in best_play_percents.values()) / 5 for champs in itertools.permutations(composition, 5): roles = { Role.top: champion_roles[champs[0]][Role.top], Role.jungle: champion_roles[champs[1]][Role.jungle], Role.middle: champion_roles[champs[2]][Role.middle], Role.adc: champion_roles[champs[3]][Role.adc], Role.support: champion_roles[champs[4]][Role.support], } if top is not None and champs[0] != top: continue if jungle is not None and champs[1] != jungle: continue if middle is not None and champs[2] != middle: continue if adc is not None and champs[3] != adc: continue if support is not None and champs[4] != support: continue metric = sum(v for v in roles.values()) / 5 if metric > best_metric: second_best_metric = best_metric second_best_roles = best_roles best_metric = metric best_roles = { Role.top: champs[0], Role.jungle: champs[1], Role.middle: champs[2], Role.adc: champs[3], Role.support: champs[4] } best_play_percents = { champs[0]: champion_roles[champs[0]][Role.top], champs[1]: champion_roles[champs[1]][Role.jungle], champs[2]: champion_roles[champs[2]][Role.middle], champs[3]: champion_roles[champs[3]][Role.adc], champs[4]: champion_roles[champs[4]][Role.support], } if best_metric > metric > second_best_metric: second_best_metric = metric second_best_roles = { Role.top: champs[0], Role.jungle: champs[1], Role.middle: champs[2], Role.adc: champs[3], Role.support: champs[4] } second_best_play_percents = { champs[0]: champion_roles[champs[0]][Role.top], champs[1]: champion_roles[champs[1]][Role.jungle], champs[2]: champion_roles[champs[2]][Role.middle], champs[3]: champion_roles[champs[3]][Role.adc], champs[4]: champion_roles[champs[4]][Role.support], } if second_best_roles == best_roles: second_best_roles = None second_best_play_percents = None second_best_metric = -float('inf') count_bad_assignments = 0 for value in best_play_percents.values(): if value < 0: count_bad_assignments += 1 count_secondary_bad_assignments = 0 if second_best_play_percents: found_acceptable_alternative = True for value in second_best_play_percents.values(): if value < 0: count_secondary_bad_assignments += 1 #if count_secondary_bad_assignments > count_bad_assignments: # found_acceptable_alternative = False else: found_acceptable_alternative = False confidence = (best_metric - second_best_metric) / best_metric if found_acceptable_alternative: string = [] for role in [ Role.top, Role.jungle, Role.middle, Role.adc, Role.support ]: if best_roles[role] != second_best_roles[role]: string.append("{}: {}".format(role, second_best_roles[role])) alternative = ', '.join(string) else: alternative = None if verbose: # These commented lines below are useful for debugging #print("Best roles: {}".format(best_metric)) #if second_best_metric > -float('inf'): # print("Second best roles: {}".format(second_best_metric)) # for role, champ in second_best_roles.items(): # print(" {}: {} == {}".format(role, champ, champion_roles[champ][role])) # for role, champion in best_roles.items(): # print(champion, champion_roles[champion]) # print('') for role in [ Role.top, Role.jungle, Role.middle, Role.adc, Role.support ]: print("{}: {} ({}%)".format( role, best_roles[role].name, round(100. * champion_roles[best_roles[role]][role], 2))) print("Probability: {}%".format(round(100. * best_metric, 1))) if not found_acceptable_alternative: print("Confidence: {}%".format(round(100. * confidence, 1))) else: print("Confidence: {}% (Alternative is {})".format( round(100. * confidence, 1), [champion.name for champion in alternative])) print('') best_roles = { role: Champion(id=id_, region=region) for role, id_ in best_roles.items() } if second_best_roles is not None: second_best_roles = { role: Champion(id=id_, region=region) for role, id_ in second_best_roles.items() } return best_roles, best_metric, confidence, second_best_roles
def getChampion(self, championName): champion = Champion(name = championName, region = self.region) return champion