コード例 #1
0
def champion_details( champStats ):
	championName = raw_input("Champion: ").title()
	champion = riotapi.get_champion_by_name(championName)
	if champion in champStats:
		champDetails = champStats[champion]
	else:
		print "Champion data not avaliable. Sorry."
		return None
	calculate_ability( champDetails, champion )
コード例 #2
0
def champion_details(champStats):
    championName = raw_input("Champion: ").title()
    champion = riotapi.get_champion_by_name(championName)
    if champion in champStats:
        champDetails = champStats[champion]
    else:
        print "Champion data not avaliable. Sorry."
        return None
    calculate_ability(champDetails, champion)
コード例 #3
0
ファイル: views.py プロジェクト: iamnikiyo/shadowlol
def get_top_champs_by_summoner(summoner,region,numberChamps):
	lista = riotapi.get_ranked_stats(summoner,season=None)
	dictionary = {}
	wins = []
	for key,value in lista.items():
		if str(key) != 'None':
			sumka = value.assists + value.kills
			wins.append(value.games_played)
			listData = [value.games_played,value.assists,value.kills,value.deaths,value.minions_killed,sumka]
			champ = riotapi.get_champion_by_name(str(key))
			dictionary[champ] = listData

	bestof = heapq.nlargest(numberChamps,wins)
	final = {}
	for item in bestof:
		for key,value in dictionary.items():
			if str(item) == str(value[0]):
				final[key] = value
	return final
コード例 #4
0
ファイル: views.py プロジェクト: icobg123/league-of-stats
def summoner(sumName):
    # images_names = os.listdir('myapplication/static/images/planes')
    # planeswalkerNames = planeswalker_dict.keys()
    username = riotapi.get_summoner_by_name(sumName)
    # rankedstats = riotapi.get_ranked_stats(sumName)
    champions = riotapi.get_champions()
    # championIds = riotapi.get_champions()
    # mapping = {champion.id: champion.name for champion in championIds}
    #
    # runes = riotapi.get_rune_pages(sumName)
    sumId = username.id
    match1 = riotapi.get_match_list(username, 3)
    championName = riotapi.get_champion_by_name(match1)
    # match = riotapi.get_match(2034758953)
    masteryStats = riotapi.get_champion_mastery_score(username)
    return render_template('testhome.html',
                           summoner=username,
                           champions=champions,
                           match=match1,
                           championName=championName,
                           masteryscore=masteryStats)
コード例 #5
0
ファイル: ItemBuild.py プロジェクト: Dyn4mo/Wonderland
def GetBuildStatsforChamp(sumnames,cname,numgames=50,jungle=False):

	# Get Summoner Objects and summoner ids
	if len([sumnames])>1:
		summoners = cass.get_summoners_by_name(sumnames)
		sumids = list(map(lambda x: x.id,summoners))
	else:
		summoners = cass.get_summoner_by_name(sumnames)
		sumids = [summoners.id]

	champ = cass.get_champion_by_name(cname)
	matchlist = []
	itemlist = []

	for s in sumids:

		# Get Match History for specific champion for Solo Ranked this season. We can update to expand to other queues or past seasons
		matches = base.get_match_list(s,num_matches=numgames,champion_ids = champ.id,ranked_queues='RANKED_SOLO_5x5',seasons='PRESEASON2016').matches
		matchlist = matchlist + matches

	# Put in check that summoner for participant id matches summoner id
	for m in matchlist:

		# For each match, find participant object matching the champion and get item set
		match = cass.get_match(m.matchId)
		c = list(map(lambda x: x.champion.id,match.participants))
		player = match.participants[c.index(champ.id)]
		its = list(map(lambda x: x.id,filter(None,player.stats.items)))
		itemlist = itemlist + its

	
	# Format Item set and calculate percentages
	itcounts = pd.DataFrame(list(Counter(itemlist).items()),columns=['id','perc'])
	itcounts = pd.merge(itcounts,Loading.items[Loading.items['id'].isin(itemlist)],on=['id'])
	itcounts['perc'] = itcounts['perc']/itcounts['perc'].sum()

	print('numgames=' + str(len(matchlist)))

	return itcounts.sort(columns=['perc'])
コード例 #6
0
ファイル: name-test.py プロジェクト: tarnag57/LoL-neuralnet
# coding=utf-8
"""Test for a champ-list
"""

from cassiopeia import riotapi

#riotparams
riotapi.set_region("EUW")
riotapi.set_api_key("RGAPI-fea9f643-7979-4b87-b857-a8330157d2c8")

file = open("champ_list", "r")

champs = file.read().splitlines()

for champ in champs:
    xxx = riotapi.get_champion_by_name(champ)
    try:
        status = riotapi.get_champion_by_name(champ)
    except:
        print("Error while looking up {0}".format(champ))
コード例 #7
0
def test_champion_by_name():
    int_test_handler.test_result(
        riotapi.get_champion_by_name(int_test_handler.champion_name))
コード例 #8
0
ファイル: summoner.py プロジェクト: apal0934/BlitzcrankBot
    async def champmastery(self, ctx, sumName: str, champName: str,
                           region: str):
        """'Summoner Name' 'Champion' 'Region'"""
        if "'" in sumName:
            await self.bot.send_message(
                ctx.message.channel,
                "Please use double quotes to enclose names.")
            return
        if "'" + champName + "'" in champName:
            await self.bot.send_message(
                ctx.message.channel,
                "Please use double quotes to enclose names.")
            return
        await self.bot.send_typing(ctx.message.channel)
        chest = None
        riotapi.set_region(region)
        champion = riotapi.get_champion_by_name(champName)
        summoner = riotapi.get_summoner_by_name(sumName)
        mastery = riotapi.get_champion_mastery(summoner, champion)
        if " " in mastery.champion.name:
            urlChampName = mastery.champion.name.replace(" ", "")
            url = 'http://ddragon.leagueoflegends.com/cdn/7.3.3/img/champion/{}.png'.format(
                urlChampName)
        elif "Vel'Koz" in mastery.champion.name:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.3.3/img/champion/Velkoz.png'
        elif "Kha'Zix" in mastery.champion.name:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.3.3/img/champion/Khazix.png'
        elif "Rek'Sai" in mastery.champion.name:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.3.3/img/champion/RekSai.png'
        elif "Cho'Gath" in mastery.champion.name:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.8.1/img/champion/Chogath.png'
        elif "Kog'Maw" in mastery.champion.name:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.8.1/img/champion/KogMaw.png'
        else:
            url = 'http://ddragon.leagueoflegends.com/cdn/7.3.3/img/champion/{}.png'.format(
                mastery.champion.name)
        if mastery.chest_granted == True:
            chest = "Yes"
        elif mastery.chest_granted == False:
            chest = "No"

        em = discord.Embed(title="Champion Mastery", colour=0x1affa7)
        em.set_thumbnail(url=url)
        em.add_field(name='Summoner:', value='{}'.format(sumName), inline=True)
        em.add_field(name='Champion:',
                     value="{}".format(champName),
                     inline=True)
        em.add_field(name='Champion level:',
                     value='{}'.format(mastery.level),
                     inline=True)
        em.add_field(name='Champion points:',
                     value='{}'.format(mastery.points),
                     inline=True)
        em.add_field(name='Points to next level:',
                     value='{}'.format(mastery.points_until_next_level),
                     inline=True)
        em.add_field(name='Chest granted:',
                     value='{}'.format(chest),
                     inline=True)

        await self.bot.send_message(ctx.message.channel, '', embed=em)
コード例 #9
0
ファイル: pruebasApi.py プロジェクト: iamnikiyo/shadowlol
from cassiopeia import riotapi
from cassiopeia import baseriotapi
from cassiopeia.type.core.common import LoadPolicy
import json
import heapq

riotapi.set_region("EUW")
riotapi.print_calls(False)
key = "deef6b4f-d2b2-49a1-8aaf-9128a2fc54e3"  # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here.
riotapi.set_api_key(key)
riotapi.set_load_policy("eager")

summoner = riotapi.get_summoner_by_name("bynikiyo")
lista = riotapi.get_ranked_stats(summoner,season=None)
dictionary = {}
wins = []
for key,value in lista.items():
	if str(key) != 'None':
		sumka = value.assists + value.kills
		wins.append(value.games_played)
		listData = [value.games_played,value.assists,value.kills,value.deaths,value.minions_killed,sumka]
		champ = riotapi.get_champion_by_name(str(key))
		dictionary[champ] = listData

bestof = heapq.nlargest(5,wins)
final = {}
for key,value in dictionary.items():
	for item in bestof:
		if str(item) == str(value[0]):
			final[key] = value
print(final)
コード例 #10
0
def test_champion_by_name():
    int_test_handler.test_result(riotapi.get_champion_by_name(int_test_handler.champion_name))
コード例 #11
0
    async def mastery(self, ctx, sum_name: str, champ_name: str, region=None):
        """'Summoner Name' 'Champion Name' '[optional] Region'"""
        if region is None:
            try:
                db = database.Database('guilds.db')
                region = db.find_entry(ctx.guild.id)
                db.close_connection()
            except TypeError:
                embed = utilities.error_embed(
                    ctx,
                    "Please specify a region, or set a default region with `b!region set [region]`."
                )
                await ctx.send("", embed=embed)
                return

        if "'" in sum_name or "'" + champ_name + "'" in champ_name:
            embed = utilities.error_embed(
                ctx, "Please use double quotes to enclose names.")
            await ctx.send("", embed=embed)
            return

        try:
            riotapi.set_region(region)
        except ValueError:
            embed = utilities.error_embed(
                ctx,
                "{0} is not a valid region! Valid regions are listed in `b!region list`."
                .format(region))
            await ctx.send("", embed=embed)
            return

        try:
            summoner = riotapi.get_summoner_by_name(sum_name)
            champion = riotapi.get_champion_by_name(champ_name)
            mastery = riotapi.get_champion_mastery(summoner, champion)
        except APIError as exception:
            await Summoner.raise_exception(self, ctx, exception, sum_name,
                                           region)
            return
        except AttributeError:
            embed = utilities.error_embed(
                ctx,
                "Could not find champion '{0}'. Please remember capitals.".
                format(champ_name))
            utilities.footer(ctx, embed)
            await ctx.send("", embed=embed)
            return

        embed = discord.Embed(colour=0x1AFFA7)
        op_gg = "https://{0}.op.gg/summoner/userName={1}".format(
            region, sum_name.replace(" ", "%20"))
        icon_url = utilities.fix_url(champ_name)
        embed.set_author(name="{0} Mastery - {1} ({2})".format(
            champion.name, summoner.name, region),
                         url=op_gg,
                         icon_url=icon_url)
        embed.add_field(name="Champion Level:",
                        value=mastery.level,
                        inline=True)
        embed.add_field(name="Mastery Points:",
                        value=mastery.points,
                        inline=True)
        embed.add_field(name="Points to next level:",
                        value=mastery.points_until_next_level,
                        inline=True)
        utilities.footer(ctx, embed)
        await ctx.send("", embed=embed)