コード例 #1
0
if (len(sys.argv) != 6):
    print("Invalid Amount of Command Line Arguements. Exiting...")
    time.sleep(3)
    exit()

#Globals
matchFileName = sys.argv[1]
summonerFileName = sys.argv[2]
starting_summoner = sys.argv[3]
maxMatchCount = int(sys.argv[4])
maxSummonerCount = int(sys.argv[5])
sleepTime = 1.2

#Setting up cass
cass.set_riot_api_key(
    "RGAPI-a846da11-2c86-44e4-8336-00281da07e37"
)  # This overrides the value set in your configuration/settings.
cass.set_default_region("NA")

# Check if matchFile already exists, if so, error out
try:
    f = open(matchFileName)
except:
    print("matchFile named \"" + str(matchFileName) + "\" will be created")
else:
    sys.exit("ERROR: matchFile named \"" + str(matchFileName) +
             "\" already existed. Exiting...")
# Check if summonerFile already exists, if so, error out
try:
    f = open(summonerFileName)
except:
コード例 #2
0
ファイル: bigee.py プロジェクト: jdb0ss/ML
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import cassiopeia as cass
from cassiopeia.data import Season, Queue
cass.set_riot_api_key("RGAPI-91b72378-8538-4678-8249-e5d07974c0f0")
cass.set_default_region("KR")
summonerName = "hide on bush"
trainNum = 100
flg = plt.figure()
ax = flg.gca(projection='3d')
summoner = cass.get_summoner(name=summonerName)
match_history = summoner.match_history
match_history(seasons={Season.season_9}, queues={Queue.ranked_solo_fives})

global_glod = [0, 0]
gold_diff = []
kda = []
x1tmp_train = []
x1_train = []
x2_train = []
x3_train = []
X_train = []

for i in range(0, trainNum):
    flag = 0
    global_glod[0] = global_glod[1] = 0
    for p in match_history[i].red_team.participants:
        if p.summoner.id == summoner.id: flag = 0
        global_glod[0] += p.stats.gold_earned
    for p in match_history[i].blue_team.participants:
コード例 #3
0
# Import Module
import cassiopeia
import window

if __name__ == "__main__":
    cassiopeia.set_riot_api_key("RGAPI-0e61182d-c5e6-4127-a066-96dc96ac8842")
    frame = window.Window()
コード例 #4
0
            main_champ = Counter(champs).most_common(1)[0]

            role_dict.append(main_role)
            champ_dict.append(main_champ)

    return summonerNames, role_dict, champ_dict


def write_output(summonerNames, role_dict, champ_dict):
    #summoner name, (role, games), (champ, games)
    print("\nSummoner name, (Role, games), (Champ, games)")
    for i in range(0, len(summonerNames)):
        print(summonerNames[i], "//", role_dict[i], "//", champ_dict[i])


#%% Main run
if __name__ == "__main__":
    start_time = time.time()

    cass.set_riot_api_key(getAPI_key())  #or replace with your own api key
    cass.set_default_region("KR")  #or replace with another region

    with open('championFull.json', 'r') as champList_file:
        champList = json.load(champList_file)
        champList_file.close()
        champList = champList['keys']

    summonerNames, role_dict, champ_dict = get_challenger_data()
    write_output(summonerNames, role_dict, champ_dict)

    print("\n--- %s seconds ---" % (time.time() - start_time))
コード例 #5
0
api_key = ''
region = 'eune'

import sys
import cassiopeia as cs

cs.set_riot_api_key(api_key)

cs.set_default_region(region)

summoner = cs.get_summoner(name=sys.argv[1])

champion = sys.argv[2]

if champion == "Lee":
    champion = "Lee Sin"
if champion == "Xin":
    champion = "Xin Zhao"

print("\n MASTERY POINTS : ",
      cs.get_champion_mastery(summoner, champion).points)
コード例 #6
0
import cassiopeia as cass
import random
import urllib
import json

API_KEY = 'RGAPI-020d0dfd-fb60-45b9-ad97-e636232d6e2c'
CHAMPION_URL = 'https://ddragon.leagueoflegends.com/cdn/9.14.1/data/en_US/championFull.json'
OPEN_JSON = "stats.json"

# This overrides the value set in your configuration/settings.
cass.set_riot_api_key(API_KEY)
cass.set_default_region("NA")

with open(OPEN_JSON) as json_file:
    data = json.load(json_file)

champions = []


class champ:
    hp = 0
    hpperlevel = 0
    mp = 0
    mpperlevel = 0
    movespeed = 0
    armor = 0
    armorperlevel = 0
    spellblock = 0
    spellblockperlevel = 0
    attackrange = 0
    hpregen = 0
コード例 #7
0
ファイル: bot.py プロジェクト: phost1111/PhostDiscordBotV2
import discord
import cassiopeia as cass
import asyncio
import logging

logging.basicConfig(level=logging.INFO)

client = discord.Client()

open('leaguekey.txt', 'a').close()
with open('leaguekey.txt', 'r') as leaguekeyfile:
    leaguekey = leaguekeyfile.readline()
cass.set_riot_api_key(key=leaguekey)

VERSION = '0.3.5a'
ADMINS = ['139354514091147264']
PREFIX = '!'
ADMINPREFIX = '*'
DELETIONWAITTIME = 5


@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')
    await changePlaying('you suffer', 3)


@client.event
コード例 #8
0
ファイル: scouting.py プロジェクト: Bcastet/Analyst
			lb.pack(side=LEFT)
			index+=1




def create_filter():
	toret = {}
	toret["begin_index"]=None
	toret["end_index"]=None
	toret["begin_time"]=None
	toret["end_time"]=None
	toret["queues"]=420
	toret["seasons"]=None
	toret["champions"]=None
	return toret

cassiopeia.set_riot_api_key("RGAPI-a83c87b7-1d63-49a8-8d80-7f3e7ed4a38b")
cassiopeia.set_default_region("EUW")

filters = create_filter()

sc = (scout("OPY Yasuneri",filters))

fenetre = Tk()
fenetre.geometry("500x500")
label = LabelFrame(fenetre,width=1200)
sc.get_frame(label)
label.pack()

fenetre.mainloop()
コード例 #9
0
import itertools
import random
from PIL import Image
import cassiopeia as cass
# import settings

OUTLINE = 10
CHAMPS = 3

with open("apikey.txt") as f:
    cass.set_riot_api_key(f.read())
cass.set_default_region("EUW")
# cass.apply_settings(settings.sd)


class LazyImage:
    def __init__(self):
        self.to_draw = []
        self.width = 0
        self.height = 0
        self.mode = None

    def paste(self, img, pos):
        self.to_draw.append([img, pos])
        if self.mode is None:
            self.mode = img.mode
        self.width = max(self.width, pos[0] + img.width)
        self.height = max(self.height, pos[1] + img.height)

    def draw(self, color=0, outline=0):
        out_img = Image.new(
コード例 #10
0
def get_match_records(filename: str, start_id: int, max_records: int,
                      sleep_time: int) -> None:
    """Retrieves the first n match records that are valid and is also a '5v5 ranked solo queue' game mode
    from the Riot API.

    Args:
        filename: Name of the file to save the League of Legends match records
        start_id: Match ID to begin looking from (will decrement from said ID number)
        max_records: Total number of successful records to be retrieved
        sleep_time: Number of seconds to wait between each API call

    Returns:
        Does not return anything. However, the data will be written to the filename as specified.
    """
    # Remember to remove the API key when pushing commits to GitHub
    cassiopeia.set_riot_api_key('RGAPI-KEY-GOES-HERE')
    cassiopeia.set_default_region('NA')

    # Iterate matches by ID number and only store matches that are of the "5v5 solo queue ranked" game mode
    read_records = 0
    current_id = start_id
    while read_records < max_records:
        # Cassiopeia API wrapper handles rate-limiting, but apparently its not suited for a personal API key
        time.sleep(sleep_time)

        match = cassiopeia.get_match(current_id)
        if not match.exists:
            print(f"Match ID {match.id} does not exist.")
        elif match.mode != cassiopeia.data.GameMode.classic or match.queue != cassiopeia.data.Queue.ranked_solo_fives:
            print(
                f"Match ID {match.id} does not match criteria of '5v5 ranked solo queue'."
            )
        else:
            print(
                f"Match ID {match.id} added. ({read_records + 1} matches out of {max_records} saved to disk) "
            )

            # a+ is similar to r+ to read and write to a file, but a+ also creates the file if it is missing and
            # appends additional text to the end of the file
            with open(filename, 'a+', newline='', encoding='utf-8') as file:
                csv_writer = csv.writer(file)
                # Write header once at the beginning of the file
                if read_records == 0:
                    csv_writer.writerow([
                        "id", "version", "side", "win", "ban1", "ban2", "ban3",
                        "ban4", "ban5", "champion1", "champion2", "champion3",
                        "champion4", "champion5", "tower_kills",
                        "inhibitor_kills", "dragon_kills", "rift_herald_kills",
                        "baron_kills", "first_tower", "first_inhibitor",
                        "first_dragon", "first_rift_herald", "first_baron"
                    ])

                # Write blue team information into csv
                bteam_info = get_team_stats('blue', match)
                csv_writer.writerow(bteam_info)

                # Write red team information into csv
                rteam_info = get_team_stats('red', match)
                csv_writer.writerow(rteam_info)
            read_records += 1  # This should be in the else statement
        current_id -= 1  # This should not be within the else statement
コード例 #11
0
ファイル: main.py プロジェクト: Satrium/league_crawler
from misc import logger, get_sqlstore

logger.debug("Loading config")
from config import config, generate_cassio_conf
from manager import Manager
from crawler import Crawler
from database import SQLParticipantAdditional
import cassiopeia as cass

cass.apply_settings(generate_cassio_conf())
cass.set_default_region(config["region"])
if "api-key" in config:
    cass.set_riot_api_key(config["api-key"])

manager = Manager()
sqlstore = get_sqlstore(cass)
from cassiopeia.core import League, ChallengerLeague, MasterLeague, Summoner
from cassiopeia.data import Queue

if config["seed"]["type"] == "LEAGUE":
    # Load this league and use it as seeding
    league = None
    if config["seed"]["id"] == "CHALLENGER":
        logger.info("Using challenger league as seed")
        league = ChallengerLeague(queue=Queue.ranked_solo_fives)
    elif config["seed"]["id"] == "MASTER":
        logger.info("Using master league as seed")
        league = MasterLeague(queue=Queue.ranked_solo_fives)
    else:
        logger.info("Using league with id=" + config["seed"]["id"] +
                    " as seed")
コード例 #12
0
ファイル: getMatches.py プロジェクト: tynanseltzer/lolDraft
import cassiopeia as cass
from cassiopeia import Summoner, Match
from cassiopeia.data import Season, Queue

cass.set_riot_api_key(
    "RGAPI-8f0b3a2f-502b-4822-bc30-a6a7b62f8a3d")  # Expires Dec 18
cass.set_default_region("NA")

# Step 2: Get a bunch of matches

with open('../input/summoners.txt') as f:
    summoners = f.read().splitlines()
    print("Length of summoners.txt: " + str(len(summoners)))

with open('../input/match_ids.txt') as f:
    ids = f.read().splitlines()
    print("Length of match_ids.txt: " + str(len(ids)))

start = summoners.index(
    "kennyd15"
)  # Index starting with last one we were looking it before crashing

for i in range(start + 2, len(summoners)):  # Change on crashes

    summoner = cass.get_summoner(name=summoners[i])
    print("Querying match history of " + summoners[i])
    match_history = cass.get_match_history(summoner=summoner,
                                           seasons={Season.season_8},
                                           queues={Queue.ranked_solo_fives})

    # for participant in match_history[0].participants:
コード例 #13
0
ファイル: ten.py プロジェクト: jdb0ss/ML
from collections import Counter
from cassiopeia.data import Season, Queue
from cassiopeia import Summoner, Match
import cassiopeia as cass
import tensorflow.compat.v1 as tf
import numpy as np
tf.disable_v2_behavior()

cass.set_riot_api_key("RGAPI-c4c7f4de-ef97-4904-ad40-ff8ba5a147e6")
cass.set_default_region("KR")
summonerName = "hide on bush"

# xy = np.loadttxt('test.csv', delimiter=',', dtype=np.float32)

summoner = cass.get_summoner(name=summonerName)

match_history = summoner.match_history
match_history(seasons={Season.season_9}, queues={Queue.ranked_solo_fives})

x_train = []
y_train = []

for i in range(20, 40):
    for p in match_history[i].participants:
        if p.summoner.id == summoner.id:
            x_train.append(p.stats.kda)
            y_train.append(p.stats.win)

print("Train Data Set")
for i in range(0, 20):
    print("kda : " + str(x_train[i]) + ", win : " + str(y_train[i]))
コード例 #14
0
            csvString += str(float(v))
            if i + 1 < len(self.properties):
                csvString += ","
            i += 1
        return csvString


if __name__ == '__main__':

    if len(sys.argv) > 1:
        api_key = str(sys.argv[0])
    else:
        api_key = "RGAPI-e4ca6150-7968-4e37-a95a-2ee4e9a422d7"

    cass.set_riot_api_key(
        api_key
    )  # This overrides the value set in your configuration/settings.
    cass.set_default_region("EUW")

    try:
        f = open('ranked_games.csv', "tx")
        f.close()
    except:
        print("File exists")

    data = pd.read_csv('high_diamond_ranked_10min.csv')

    print("Type game index to continue with or type \"new\" to start over:")

    selection = input()
    startIndex = 0
コード例 #15
0
ファイル: scrape.py プロジェクト: jonathanh8686/ARAMTeam
# coding: utf-8

# In[1]:

import cassiopeia as cass
import random
import arrow
from cassiopeia.core import Summoner, MatchHistory, Match
from cassiopeia import Queue, Patch, Match, Season
from cassiopeia.data import Role, Lane, Division, Tier
import json
import matplotlib.pyplot as plt

conf = json.loads(open("config.json", "r").read())

cass.set_riot_api_key(conf["API_KEY"])
cass.set_default_region("NA")

users = ["Catalysis"]
seenUsers = set()

while (len(users) != 0):

    cuser = users[0]
    seenUsers.add(users[0])

    users.pop(0)
    matches = cass.MatchHistory(summoner=Summoner(name=cuser, region="NA"),
                                queues=["ARAM"])
    print(len(matches))
コード例 #16
0
ファイル: bot.py プロジェクト: jason-kuang/Valor
        if (not path.exists("champions/{champion}.json".format(
                champion=name))) or champion.version() != version["version"]:
            champion.update(version["version"])
        abilities = champion.abilities()
        P = "Passive: {name} - {description}\n".format(
            name=abilities["PASSIVE"].name,
            description=abilities["PASSIVE"].description)
        Q = "Q: {name} - {description} | Cooldown: {cooldownBurn}\n".format(
            name=abilities["Q"].name,
            description=abilities["Q"].description,
            cooldownBurn=abilities["Q"].cooldown)
        W = "W: {name} - {description} | Cooldown: {cooldownBurn}\n".format(
            name=abilities["W"].name,
            description=abilities["W"].description,
            cooldownBurn=abilities["W"].cooldown)
        E = "E: {name} - {description} | Cooldown: {cooldownBurn}\n".format(
            name=abilities["E"].name,
            description=abilities["E"].description,
            cooldownBurn=abilities["E"].cooldown)
        R = "R: {name} - {description} | Cooldown: {cooldownBurn}\n".format(
            name=abilities["R"].name,
            description=abilities["R"].description,
            cooldownBurn=abilities["R"].cooldown)
        print("Returned champion data for {champ}".format(champ=name))
        await message.channel.send(P + Q + W + E + R)


with open("logindata.json") as json_data_file:
    logindata = json.load(json_data_file)
    cass.set_riot_api_key(logindata["riotkey"])
    client.run(logindata["discordkey"])
コード例 #17
0
                   description=description)  #b from bigboy
bot.remove_command('help')

##Variables_start
where_i_im = os.path.dirname(os.path.abspath(
    __file__))  #where is the file/folder of this python document...
user_folder = where_i_im + "/users/"
blacklist_folder = user_folder + "blacklist/"
summonerlist_folder = user_folder + "summonerlist/"
help_p1_file_location = where_i_im + "/help_pt1.txt"
help_p2_file_location = where_i_im + "/help_pt2.txt"
client = discord.Client()
#Variables_End

#Config_start
cass.set_riot_api_key(key)
cass.set_default_region("EUW")  #Default region
#Config_end


##Commands_start
@bot.event
async def on_ready():
    print('------')
    print('Logged as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')
    game = discord.Game(
        "No worries, im here for you, type \"b.help\" so i can help!")
    await bot.change_presence(status=discord.Status.online, activity=game)
コード例 #18
0
ファイル: __init__.py プロジェクト: zbee/mobahinted
        'Cache': {},
        'SimpleKVDiskStore': {
            'package': 'cassiopeia_diskstore',
            'path': cassiopeia_path,
        },
        'DDragon': {},
    },
}

# Set up Cassiopeia, either with local key or proxy kernel
try:
    if not os.path.exists('.env'):
        raise Exception('No .env file found')

    load_dotenv('.env')
    cassiopeia.set_riot_api_key(os.getenv('RIOT_API_KEY'))
    cassiopeia_settings['pipeline']['RiotAPI'] = {
        'api_key': os.getenv('RIOT_API_KEY'),
    }
    print('USING: Development Key (RIOT\'s servers)')
except Exception:
    cassiopeia_settings['pipeline']['Kernel'] = {
        'server_url': 'https://mhk-api.zbee.dev',
        'port': '443',
    }
    print('USING: Kernel with key (zbee\'s servers)')

# Load basic settings for Cassiopeia
cassiopeia.apply_settings(cassiopeia_settings)
cassiopeia.set_default_region(settings.region)
コード例 #19
0
import cassiopeia as cass
from datetime import timedelta

cass.set_riot_api_key('RGAPI-34eb3716-5499-481a-a05c-1eeeabdd500b')
region = 'NA'


def gold_diff_for_jg_at_x_min(ign, reg=region, game_num=20, x=10):
    me = cass.get_summoner(region=reg, name=ign)
    matches = me.match_history(begin_index=0, end_index=game_num)
    d = timedelta(minutes=x)

    gold_diff_list = []
    my_gold = 0
    enemy_gold = 0

    for match in matches:
        mee = match.participants[me]
        my_lane = mee.lane
        my_id = mee.id
        my_champ = mee.champion.name
        enemy = 0

        if mee.summoner_spell_d.name != "Smite" and mee.summoner_spell_f.name != "Smite":
            continue

        for p in match.participants:
            if (p.summoner_spell_d.name == "Smite"
                    or p.summoner_spell_f.name == "Smite"
                ) and p.id is not my_id and p.team is not mee.team:
                enemy = p.summoner