def get_most_efficient(spellData, stats, spellDataKeys): """ Returns the most efficient spell for a given stat dictionary. :param spellData: The dictionary of spell data. :param stats: Stat package to evaluate the most efficient spell at. :param spellDataKeys: The list of keys to the spell data dictionary. """ ret = ['', -1, [], [], {}, [], []] for champ in spellDataKeys: if champ == "Teemo" or champ == "Aatrox" or champ == "Rengar": # or champ == "Rumble" or champ == "Vi": continue for x in range(0, 4): currentSpell = Spell.Spell() currentSpell.init_from_riot_api(spellData['data'][champ]['spells'][x]) if currentSpell.get_efficiency(stats) > 0: ret[4][currentSpell.get_name()] = currentSpell.get_efficiency(stats) ret[5].append(champ) ret[2].append(currentSpell.get_name()) if currentSpell.get_efficiency(stats) > ret[1]: ret[0] = currentSpell.get_name() ret[1] = currentSpell.get_efficiency(stats) else: ret[3].append(currentSpell.get_name()) ret[6].append(champ) return ret
def actions(self): attack_damage = self.attack_power basic_attack = spell.Spell(name='Basic Attack', damage=attack_damage, mana_cost=0) all_actions = self.spells.copy() all_actions.insert(0, basic_attack) return all_actions
def calculate(): args = [] spell_name = name_entry.get() for opt, opt_tuple in optval_dict.items(): args.append(opt_tuple[0].get()) # print(f"{opt}: {opt_tuple[0].get()}") if args[1] != 'None': rune_spell = spell.Spell(spell_name, *args) else: rune_spell = None return rune_spell
def __init__(self, text=None): # 1. Set the initial values self.text = text self.spells = {} # 2. Add in the spells (if any) if self.text and len(self.text) > 0: for line in self.text: spl = spell.Spell(text=line) self.spells[spl.name] = spl
def test_empty_init(self): "Test the default Spell creation" # 1. Create default Shop object myobj = spell.Spell() # 2. Make sure it has the default values self.assertEqual(myobj.name, "None") self.assertEqual(myobj.cost, 9999) self.assertEqual(myobj.turns, 0) self.assertEqual(myobj.damage, 0) self.assertEqual(myobj.heal, 0) self.assertEqual(myobj.armor, 0) self.assertEqual(myobj.mana, 0) # 3. Check methods self.assertEqual(str(myobj), "None, 9999, 0, 0, 0, 0, 0")
def get_most_efficient(spellData, stats, spellDataKeys): """ Returns the most efficient spell for a given stat dictionary. :param spellData: The dictionary of spell data. :param stats: Stat package to evaluate the most efficient spell at. :param spellDataKeys: The list of keys to the spell data dictionary. """ ret = ['', -1] for champ in spellDataKeys: if champ == "Rengar" or champ == "Rumble" or champ == "Vi": continue for x in range(0, 4): currentSpell = Spell.Spell() currentSpell.init_from_riot_api( spellData['data'][champ]['spells'][x]) if currentSpell.get_efficiency(stats) is not None: if currentSpell.get_efficiency(stats) > ret[1]: ret[0] = currentSpell.get_name() ret[1] = currentSpell.get_efficiency(stats) return ret
def getSpell(self, s): castsLeft = tryToConvertValue(s.get("castsleft")) casterClass = s.get("class").lower() spellName = s.get("name") spellLevel = int(s.get("level")) # Annoyingly Domain spells seem to get the class="" attribute if casterClass == "": casterClass = "domain" spellData = spell.Spell(self.spellDict(s)) #dbSpell = spell.Spell.searchByName(self.database, spellName) #if len(dbSpell) < 1: # raise RuntimeError("Spell {0} not found".format(spellName)) #else: # dbSpell = dbSpell[0] return casterClass, castsLeft, spellData, spellLevel
def test_text_init(self): "Test Spell creation from text" # 1. Create default Shop object myobj = spell.Spell(text=EXAMPLE_TEXT) # 2. Make sure it has the default values self.assertEqual(myobj.name, "Shield") self.assertEqual(myobj.cost, 113) self.assertEqual(myobj.turns, 6) self.assertEqual(myobj.damage, 6) self.assertEqual(myobj.heal, 0) self.assertEqual(myobj.armor, 7) self.assertEqual(myobj.mana, 0) # 3. Check methods self.assertEqual(str(myobj), "Shield, 113, 6, 6, 0, 7, 0") player_1 = player.Player(name="P1") player_2 = player.Player(name="P2") act = myobj.cast(player_1, player_2) self.assertEqual(player_1["used"], 113) self.assertNotEqual(act, None) self.assertEqual(act.name, myobj.name)
import spell import player from random import randint characterSpellSet00 = [] characterSpellSet01 = [] characterSpellSet02 = [] characterSpellSet = [] characters = [] player_01 = player.Player("", 0, 0, 0, 0, 0, 0, characterSpellSet) computer = player.Player("", 0, 0, 0, 0, 0, 0, characterSpellSet) basicAtack = spell.Spell("Chapuletada", 5, 0) spell_00 = spell.Spell("Flames", 15, 10) spell_01 = spell.Spell("Fire Bolt", 20, 20) spell_02 = spell.Spell("Fireball", 30, 30) spell_03 = spell.Spell("Frost Bite", 15, 10) spell_04 = spell.Spell("Ice Spike", 20, 20) spell_05 = spell.Spell("Ice Storm", 30, 30) spell_06 = spell.Spell("Sparks", 15, 10) spell_07 = spell.Spell("Lightning Bolt", 20, 20) spell_08 = spell.Spell("Chain Lightning", 30, 30) character_00 = player.Player("Markov", 100, 100, 10, 10, 9, 1.5, characterSpellSet00) character_01 = player.Player("Morrigan", 100, 100, 10, 10, 10, 1.5, characterSpellSet01) character_02 = player.Player("Jaina", 100, 100, 10, 10, 8, 1.5, characterSpellSet02) character_00.addSpellSet(basicAtack, spell_00, spell_01, spell_02)
import pygame import monster import spell import trap m1 = monster.Monster(name='Matazza The Zapper', atkdef=(1300, 1000), nivel=3) m2 = monster.Monster(name='Alexandrite Dragon', atkdef=(1900, 1500), nivel=4) print('{0} Vs {1}'.format(m1.name, m2.name)) print(m1.attack(m2)) s = spell.Spell(name='Mystic Typhoon') print(s.name) t = trap.Trap(name='Mirror Force') print(t.name)
def begin_combat(self): for item in self.combatant_frames: action_num = item.choose_actions_ntbk.index( item.choose_actions_ntbk.select()) action_desc = self.action_dict[action_num] parameters = {} # if action is an attack if action_num == 0: target = item.choose_actions_ntbk.attack_frame.target.get() parameters['target'] = self.combat.get_combatant(target) parameters['attack'] = item.combatant.get_attack( item.choose_actions_ntbk.attack_frame.attack.get()) parameters[ 'parry_percentage'] = item.choose_actions_ntbk.attack_frame.parry_percentage.get( ) target_text = " " + target + " with a " + item.choose_actions_ntbk.attack_frame.attack.get( ) log_message = item.combatant.name + " " + action_desc + target_text action = attackaction.AttackAction(self.combat, item.combatant, self.combat.time, action_num, parameters, log_message) # if action is a spell cast elif action_num == 1: target = item.choose_actions_ntbk.cast_spell_frame.target.get() if target and target != "None": parameters['target'] = self.combat.get_combatant(target) else: parameters['target'] = None spell_to_cast = spell.Spell( item.choose_actions_ntbk.cast_spell_frame.spell_list.get(), item.choose_actions_ntbk.cast_spell_frame.spell_level.get( )) parameters['spell'] = spell_to_cast target_text = " at " + target log_message = item.combatant.name + " " + action_desc + target_text action = castspellaction.CastSpellAction( self.combat, item.combatant, self.combat.time, action_num, parameters, log_message) elif action_num == 2: parameters[ 'pace'] = item.choose_actions_ntbk.move_frame.pace.get() log_message = item.combatant.name + " " + action_desc action = moveaction.MoveAction(self.combat, item.combatant, self.combat.time, action_num, parameters, log_message) elif action_num == 3: parameters = [] log_message = item.combatant.name + " " + action_desc action = performskillaction.PerformSkillAction( self.combat, item.combatant, self.combat.time, action_num, parameters, log_message) else: raise (NotImplementedError, "This action type is not implemented yet.") self.combat.add_action(action) item.combatant.current_action = action v.p( verbose_msg, "Action put in list: " + action.log_message + " at time " + str(action.end_time)) prior_log_length = len(self.combat.log) # Call the routine to carry out the actions self.combat.act() for item in self.combatant_frames: item.update_info() for i in range(prior_log_length, len(self.combat.log)): self.combat_log_msg.insert(tk.END, self.combat.log[i])
def main(): api = API.RiotAPI(KEY.KEY) a = api.get_champion_list('spells') # a = api.get_champion_list() # print type(a['data']['MonkeyKing']) # print a['data']['Leblanc'] x = 0 keys = [] for pairs in a['data'].iteritems( ): # Get the list of keys from the API list of spells. Keys are essentially champ names. keys.append(pairs[0]) """for each in keys: print each print len(keys)""" # print(api.get_champion_list('spells')) """print "Number of keys: ", len(keys) print type(keys) # list print type(a['data']) # a['data'] is a dictionary print type(a['data']['MonkeyKing']) #dictionary print type(a['data']['MonkeyKing']['spells']) #list print len(a['data']['MonkeyKing']['spells']) #list with 4 things. all related to wukong. print type(a['data']['MonkeyKing']['spells'][0]) # a dictionary """ """for each in a['data']['Kassadin']['spells'][3]: print each print a['data']['Kassadin']['spells'][3][each]""" """for each in a['data']['Shaco']['spells'][0]: print each print a['data']['Shaco']['spells'][0][each]""" #print a['data']['Xerath']['spells'][2].get('sanitizedTooltip') print a['data']['Soraka']['spells'][1].get( 'sanitizedTooltip') #.get('cooldown') #print a['data']['Lux']['spells'][2].get('sanitizedTooltip') #.get('cooldown') #print a['data']['Lux']['spells'][3].get('sanitizedTooltip') #.get('cooldown') stats = {} for champ in keys: for x in range(0, 4): if a['data'][champ]['spells'][x].get('vars') is not None: for sublist in a['data'][champ]['spells'][x]['vars']: if sublist['link'][0] != '@' and sublist['link'][0] != '.': stats[sublist['link']] = 100 stats['cdr'] = 0.10 LuxQ = Spell.Spell() LuxQ.init_from_riot_api(a['data']['Soraka']['spells'][1]) print LuxQ.get_efficiency(stats) """spells = [] x = 0 for what in keys: spellQ = Spell.Spell() spellW = Spell.Spell() spellE = Spell.Spell() spellR = Spell.Spell() spellQ.init_from_riot_api(a['data'][what]['spells'][0]) spellW.init_from_riot_api(a['data'][what]['spells'][1]) spellE.init_from_riot_api(a['data'][what]['spells'][2]) spellR.init_from_riot_api(a['data'][what]['spells'][3]) spells.append(spellQ) spells.append(spellW) spells.append(spellE) spells.append(spellR) # print spells[0] # print a['data']['FiddleSticks']['spells']""" """print a['data']['MonkeyKing']['spells'][0]['sanitizedDescription'] print a['data']['MonkeyKing']['spells'][0]['sanitizedTooltip'] print a['data']['MonkeyKing']['spells'][0]['effect']""" """ print type(a['data']['MonkeyKing']['spells'][3]['vars']) print len(a['data']['MonkeyKing']['spells'][0]['vars']) print a['data']['MonkeyKing']['spells'][0]['vars'][0] print type(a['data']['MonkeyKing']['spells'][0])""" #print a['data']['MonkeyKing']['spells'][3]['effect'] #print a['data']['MonkeyKing']['spells'][3]['effect'][0] #print a['data']['MonkeyKing']['spells'][3]['effect'][1] #print a['data']['MonkeyKing']['spells'][3]['effect'][2] # https://developer.riotgames.com/docs/static-data # IMPORTANT KEYS # 'name' - Name of the spell # 'cooldown' - a list of the cooldowns # 'resource' - type of resource needed # 'effect' - not entirely certain, it's a list. index 1 appears to be scaling for base effect. # 'vars' - a list of "variables" for the spell. each index is a dictionary that has the keys: # 'coeff' : [coeff], 'link' : scaling type, and 'key' : someKey # 'cost' - the resource cost to cast the spell. # # Not necessarily important, but e1 seems to be base damage. guessing e is short for effect. the values for it seem # to be stored in the 'effect' key # cooldownBurn - cdr in seconds. returns in X/Y/Z # cooldown - cdr in seconds, returns as [x, y, z] # vars - returns a dict with keys 'coeff', scaling type, and 'key' (not sure what this is) # leveltip - I thiiink this is tool tip. # costType - what resource this consumes # description - description (shocker) # # Dict looks like it goes JSONDICT['data'][keyForChampionName]['spells'][intForSpellQWER][keyForSpellAspect] # keyForChampionName - This should be decided by getting a list of keys from iterating through JSONDICT['data'].iteritems() # intForSpellQWER - This should be any value 0-3, maps to q, w, e, r # keyForSpellAspect - probably just going to hardcode this or something. but can be attained by for each'ing in JSONDICT['data'][keyForChampionName][intForSpellQWER] y = 0 """for key, value in keys: print key print value print value['spells'][3]['key'] y+=1""" # Give """a = dummy()
import spell spell.lib.init_env_logger() spell_map = spell.Spell() spell_map.insert("Command Failed on: node-127,node-234") spell_map.insert("Command Failed on: node-128,node-234") spell_map.insert("Command Failed on: node-129,node-235") lcs_object = spell_map.match("Command Failed on: node-130,node-235") for i, token in enumerate(lcs_object.tokens()): print("%d - Token: %s" % (i, token)) for i, line_id in enumerate(lcs_object.line_ids()): print("%d - Line id: %s" % (i, line_id))