def collectItemUsage(): matchesList = collectMatches() # Start by creating dictionaries of every spell, item, rune, and champion names try: itemUsage = { champion.name: [{ spell.name: 0 for spell in kass.get_summoner_spells(region="NA") }, {item.name: 0 for item in kass.get_items(region="NA")}, {rune.name: 0 for rune in kass.get_runes(region="NA")}] for champion in kass.get_champions(region="NA") } except Warning as err: print(err) for match in matchesList: for player in match.participants: currWin = player.stats.win if (currWin): # Only care if there was a win for the champion currChamp = player.champion.name if player.summoner_spell_d.name in itemUsage[currChamp][0]: itemUsage[currChamp][0][player.summoner_spell_d.name] += 1 if player.summoner_spell_f.name in itemUsage[currChamp][0]: itemUsage[currChamp][0][player.summoner_spell_f.name] += 1 for item in player.stats.items: if item is not None and item.name in itemUsage[currChamp][ 1]: itemUsage[currChamp][1][item.name] += 1 for rune in player.runes: if rune is not None and rune.name in itemUsage[currChamp][ 2]: itemUsage[currChamp][2][rune.name] += 1 return itemUsage
def test_summonerspells(): sspells = cass.get_summoner_spells(region="NA") for sspell in sspells: if set(sspell.modes) & {GameMode.classic, GameMode.aram, GameMode.poro_king, GameMode.ascension}: "Name:", sspell.name "Description:", sspell.description sspell = SummonerSpell(name="Ghost", region="NA") sspell.description
def get_summoner_spells(): sspells = cass.get_summoner_spells() for sspell in sspells: #if "Disabled" not in sspell.name: if set(sspell.modes) & { GameMode.classic, GameMode.aram, GameMode.poro_king, GameMode.ascension }: print("Name:", sspell.name) print("Description:", sspell.description) print() sspell = SummonerSpell(name="Ghost") print(sspell.description)
def load_all(self, refresh: bool = False): # Save refresh variable so we don't have to pass it into every method self.refresh = refresh if refresh: cassiopeia.configuration.settings.clear_sinks() cassiopeia.configuration.settings.expire_sinks() # Open the download popup, start downloading data and updating the # progress bar as we go progress_popup = hinter.ui.progress.Progress( 0, 'Downloading and processing: Champions') cassiopeia.get_champions() progress_popup.update(70, 'Downloading and processing: Items') cassiopeia.get_items() progress_popup.update(80, 'Downloading and processing: Maps') cassiopeia.get_maps() progress_popup.update(81, 'Downloading and processing: Spells') cassiopeia.get_summoner_spells() progress_popup.update(82, 'Downloading and processing: Runes') cassiopeia.get_runes() progress_popup.update(85, 'Downloading and processing: Rank icons') self.load_rank_icons(refresh) # Inform user data refresh completed, wait, then close the popup progress_popup.update(100, 'Data refresh complete! Window will close') time.sleep(3) progress_popup.close() # Do not update again until this is called, refresh data loaded checks self.refresh = False
import discord import cassiopeia as riotapi # from cassiopeia.core.common import Map from cassiopeia.core.staticdata import * from cassiopeia.core.staticdata.champion import ChampionSpell, Skin from fuzzywuzzy import fuzz from . import util, config ALLOWED_MODES: Set[str] = { mode.upper() for mode in config["trivia"]["allowed_modes"] } ALLOWED_SPELLS: List[SummonerSpell] = \ [spell for spell in riotapi.get_summoner_spells() if not ALLOWED_MODES.isdisjoint(util.find_in_data(spell, "modes"))] # ALLOWED_MAPS: Set[str] = \ # {str(Map[map.lower()].value) if not map.isdigit() else map for map in config["trivia"]["allowed_maps"]} ALLOWED_MAPS: Set[int] = \ {int(riotapi.get_maps()[map].id) if not map.isdigit() else int(map) for map in config["trivia"]["allowed_maps"]} print(ALLOWED_MAPS) ALLOWED_ITEMS: List[Item] = [] for item in riotapi.get_items(): # print(list(map.id for map in item.maps)) if not ALLOWED_MAPS.isdisjoint(int(map.id) for map in item.maps): ALLOWED_ITEMS.append(item) PERCENT_STATS: List[str] = [ "percent", "spell_vamp", "life_steal", "tenacity", "critical",
def storeMatches(): try: conn = pymysql.connect(user=config.dbUsername, password=config.dbPassword, host=config.dbIP, database=config.dbName) cursor = conn.cursor() except pymysql.Error as err: print(err) # Dict of tables TABLES = {} TABLES['champions'] = ''' CREATE TABLE champions ( champID int NOT NULL, champName varchar(25) NOT NULL, item1 varchar(50), item2 varchar(50), item3 varchar(50), item4 varchar(50), item5 varchar(50), item6 varchar(50), item7 varchar(50), rune1 varchar(35), rune2 varchar(35), rune3 varchar(35), rune4 varchar(35), rune5 varchar(35), rune6 varchar(35), rune7 varchar(35), spell1 varchar(40), spell2 varchar(40), PRIMARY KEY(champName) )''' TABLES['items'] = ''' CREATE TABLE items ( itemID int NOT NULL, itemName varchar(50) NOT NULL, PRIMARY KEY(itemName) )''' TABLES['runes'] = ''' CREATE TABLE runes ( runeID int NOT NULL, runeName varchar(35) NOT NULL, PRIMARY KEY(runeName) )''' TABLES['spells'] = ''' CREATE TABLE spells ( spellID int NOT NULL, spellName varchar(40) NOT NULL, PRIMARY KEY(spellName) )''' # Create the tables from the dict of tables above for name, ddl in TABLES.items(): try: print("Creating table {}: ".format(name), end='') cursor.execute(ddl) conn.commit() except pymysql.Error as err: print(err) else: print("OK") # Fill tables with all champions, items, spells, and runes allChamps = {champion.id: champion.name for champion in kass.get_champions(region="NA")} allItems = {item.id: item.name for item in kass.get_items(region="NA")} allRunes = {rune.id: rune.name for rune in kass.get_runes(region="NA")} allSpells = {spell.id: spell.name for spell in kass.get_summoner_spells(region="NA")} addChamp = ('''INSERT INTO champions (champID, champName) VALUES (%s, %s) ON DUPLICATE KEY UPDATE champName=champName''') addItem = ('''INSERT INTO items (itemID, itemName) VALUES (%s, %s) ON DUPLICATE KEY UPDATE itemName=itemName''') addRune = ('''INSERT INTO runes (runeID, runeName) VALUES (%s, %s) ON DUPLICATE KEY UPDATE runeName=runeName''') addSpell = ('''INSERT INTO spells (spellID, spellName) VALUES (%s, %s) ON DUPLICATE KEY UPDATE spellName=spellName''') try: for champ, name in allChamps.items(): dataChamp = (champ, name) cursor.execute(addChamp, dataChamp) conn.commit() for item, name in allItems.items(): dataItem = (item, name) cursor.execute(addItem, dataItem) conn.commit() for rune, name in allRunes.items(): dataRune = (rune, name) cursor.execute(addRune, dataRune) conn.commit() for spell, name in allSpells.items(): dataSpell = (spell, name) cursor.execute(addSpell, dataSpell) conn.commit() except pymysql.Error as err: print(err) else: print("Tables populated with default data") if conn.open: conn.close() cursor.close()
from sklearn.model_selection import cross_val_score import scipy.optimize #CONSTANTS STARTING_ITEMS = sorted( ("Boots of Speed", "Faerie Charm", "Rejuvenation Bead", "Sapphire Crystal", "Ruby Crystal", "Cloth Armor", "Null-Magic Mantle", "Long Sword", "Hunter's Talisman", "Hunter's Machete", "Dagger", "Brawler's Gloves", "Amplifying Tome", "Doran's Shield", "Doran's Blade", "Doran's Ring", "The Dark Seal", "Cull", "Ancient Coin", "Relic Shield", "Spellthief's Edge", "Corrupting Potion")) STARTING_ITEMS = {STARTING_ITEMS[i]: i for i in range(len(STARTING_ITEMS))} SUMMONER_SPELLS = cass.get_summoner_spells("NA") SUMMONER_SPELLS = sorted([ spell.name for spell in SUMMONER_SPELLS if cass.GameMode.classic in spell.modes ]) SUMMONER_SPELLS = {SUMMONER_SPELLS[i]: i for i in range(len(SUMMONER_SPELLS))} POSITIONS = sorted(('TOP', 'MID', 'BOT', 'JUNGLE')) POSITIONS = {POSITIONS[i]: i for i in range(len(POSITIONS))} # CHAMPIONS = cass.get_champions("NA") # CHAMPIONS = sorted([champion.name for champion in CHAMPIONS]) # CHAMPIONS = {CHAMPIONS[i] : i for i in range(len(CHAMPIONS))} LABELS = ['BOTTOM', 'JUNGLE', 'MIDDLE', 'SUPPORT', 'TOP'] trainingColumns = ['CS','Exp','MonsterKills'] + list(SUMMONER_SPELLS.keys()) + list(POSITIONS.keys()) + \