def command(player, text): txt = text.split('.') if txt[0] == 'spawn': if len(txt) == 3 and txt[1] in POKEMON.keys(): if txt[2].isnumeric() and 1 <= int(txt[2]) <= 100: info = POKEMON[txt[1]] p = Pokemon(txt[1], info[4], int(txt[2])) e = PVE_Encounter(player, player.curr_location) e.enemy = p return True, e elif len(txt) == 4 and txt[1] in POKEMON.keys(): if txt[2].isnumeric() and 1 <= int( txt[2]) <= 100 and txt[3] == 'shiny': info = POKEMON[txt[1]] p = Pokemon(txt[1], info[4], int(txt[2])) p.shiny = True e = PVE_Encounter(player, player.curr_location) e.enemy = p return True, e elif txt[0] == 'give': if len(txt) == 2 and txt[1] in ITEMS: player.bag.add_item(ITEMS[txt[1]]) return True, None elif len(txt) == 3 and txt[1] in ITEMS and txt[2].isnumeric(): if int(txt[2]) > 0: for i in range(int(txt[2])): player.bag.add_item(ITEMS[txt[1]]) return True, None return False, None
def initializeGame(): moves = [] pokemon = [] moves.append(Move('Tackle', 'No additional effect.', 40, 100, 35, 0, 0, 1)) moves.append(Move('Scratch', 'No additional effect.', 40, 100, 35, 0, 0, 1)) moves.append( Move('Growl', 'Lowers opponent\'s Attack by one stage.', 0, 100, 40, 2, 0, 0)) moves.append( Move('Tail Whip', 'Lowers opponent\'s Defense by one stage.', 0, 100, 30, 2, 0, 0)) moves.append(Move('Ember', 'May induce burn.', 40, 100, 25, 1, 9, 1)) moves.append( Move('Water Gun', 'No additional effect.', 40, 100, 25, 1, 10, 1)) moves.append( Move('Vine Whip', 'No additional effect.', 45, 100, 25, 0, 11, 1)) pokemon.append(Pokemon("BULBASAUR", "Bulbasaur", 11, 3)) pokemon[0].setStats(21, 11, 11, 13, 13, 11) pokemon[0].learnMove(moves[0]) # Tackle pokemon[0].learnMove(moves[2]) # Growl pokemon.append(Pokemon("CHARMANDER", "Charmander", 9)) pokemon[1].setStats(20, 11, 10, 12, 11, 13) pokemon[1].learnMove(moves[1]) # Sratch pokemon[1].learnMove(moves[2]) # Growl pokemon.append(Pokemon("SQUIRTLE", "Squirtle", 10)) pokemon[2].setStats(20, 11, 13, 11, 12, 10) pokemon[2].learnMove(moves[0]) # Tackle pokemon[2].learnMove(moves[3]) # Tail Whip return pokemon, moves
def generateTeam(tier=''): team = [] if tier == 'uber': for _ in range(6): next_pokemon = choice(uberList) poke_object = Pokemon(next_pokemon, pokeDict[next_pokemon]["name"], pokeDict[next_pokemon]["types"], pokeDict[next_pokemon]["stats"], pokeDict[next_pokemon]["moves"]) team.append(poke_object) finishedTeam = getMoves(team) return finishedTeam else: ids = list(set(pokeDict.keys()) - set(uberList)) for _ in range(6): next_pokemon = choice(ids) poke_object = Pokemon(next_pokemon, pokeDict[next_pokemon]["name"], pokeDict[next_pokemon]["types"], pokeDict[next_pokemon]["stats"], pokeDict[next_pokemon]["moves"]) team.append(poke_object) finishedTeam = getMoves(team) return finishedTeam
def initialize_pokemons(): pokemon = [] pokemon.append(Pokemon("Balbasaur", "fű", "víz")) pokemon.append(Pokemon("Pikatchu", "elektromos", "víz")) pokemon.append(Pokemon("Charizard", "tűz", "fű")) pokemon.append(Pokemon("Balbasaur", "víz", "tűz")) pokemon.append(Pokemon("Kingler", "víz", "tűz")) return pokemon
def play(): wrestlers = __get_wrestlers() w = wrestlers[0] winner = Pokemon(w['number'],w['name'],w['alive']) l = wrestlers[1] loser = Pokemon(l['number'],l['name'],l['alive']) battle_number = __get_battle_number() alive_number = __get_alive_pokemon().count() return Game(battle_number, alive_number, winner, loser)
def __init__(self): x = 'stuff.csv' reader = csv.reader(open(x, newline='')) line = next(reader) line = next(reader) line = next(reader) #first pk self.temp = Pokemon(line) self.temp.ToString() self.temp.Level(16)
def setUp(self): self.valid_pokemon1 = Pokemon([Type(7),Type(8)], Stats(2, 3, 4, 5, 6), [Move("atk", Type(2), 100, 30, 200), Move("atk", Type(2), 100, 30, 100)], "teste", 5) self.valid_pokemon2 = Pokemon([Type(3),Type(4)], Stats(10, 11, 3, 13, 14), [Move("atk", Type(1), 7, 8, 9)], "NameTest2", 1) self.valid_type_list = [Type(7),Type(8)] self.valid_stats = Stats(10, 3, 4, 5, 6) self.valid_name = "NameTest" self.valid_level = 5 self.valid_move = [Move("atk", Type(2), 100, 30, 5), Move("atk2", Type(2), 100, 30, 100)] self.valid_movelist = MoveList([Move("atk", Type(2), 100, 30, 5), Move("atk2", Type(2), 100, 30, 100)]) pass
def get_enemy(self): """ choose a pokemon from the ones available in the location """ l = [] for pokemon in self.location.pokemon: for i in range(int(pokemon[1])): l.append(pokemon) pokemon = l[random.randint(0, len(l) - 1)] self.enemy = Pokemon(pokemon[0], random.randint(pokemon[2], pokemon[3]), int(pokemon[4]))
def init(self): #A set of boolean variables are intialized below to organize which game screen is to be drawn in redrawAll self.startScreen = True self.instructions = False self.stageOne = False self.stageTwo = False self.stageThree = False self.won = False self.scores = False self.enterName = False self.lost = False self.fail = False #if you don't even collect pokeballs, you just fail #Game condition values self.pokeballs = 0 self.score = 0 self.pokemonList = [] #Counters self.stageOneCounter = 20 #countdown timer for stageOne self.stageOneCounterTimer = 0 self.stageThreeCounter = 20 self.stageThreeCounterTimer = 0 #Initializations User.init() user = User(self.width / 2, self.height / 2, 'Lonely') self.userGroup = pygame.sprite.GroupSingle(user) self.user = self.userGroup.sprite self.otherPlayerGroup = pygame.sprite.Group() Obstacle.init() self.obstacleGroup = pygame.sprite.Group() Pokeball.init() self.pokeballGroup = pygame.sprite.Group() self.pokeballProb = range( 50 ) #check 2/3 every second currently checking every 1/50 seconds so decrease probability by 50 (multiply value by 50) Enemy.init() self.enemyGroup = pygame.sprite.Group() PokeballBullet.init() self.pokeballBullets = pygame.sprite.Group() self.otherPokeballBullets = pygame.sprite.Group() Pokemon.init() self.pokemonGroup = pygame.sprite.Group()
def printPokeStats(Pokemon): os.system('clear') Pokemon.printSimpleStats() print('OT: ' + str(Pokemon.trainer_ot).zfill(5)) print('Nature: ' + natures[Pokemon.gainStat][Pokemon.loseStat]), if Pokemon.loseStat == Pokemon.gainStat: print('(NEUTRAL)') else: print('(UP: ' + statName[Pokemon.gainStat] + ', DOWN: ' + statName[Pokemon.loseStat] + ')') Pokemon.printPokeBaseStats() printMoves(Pokemon)
def printGenericStats(Pokemon): os.system('clear') print(Pokemon.species) #print('Level: ' + str(Pokemon.level)) print('Type: '), for i in range(0, len(Pokemon.typing)): if Pokemon.typing[i] != 18: print('| ' + typelist[Pokemon.typing[i]]), print('|') Pokemon.printGenericBaseStats() printMoves(Pokemon)
def sosPokemon(self, index): address = self.sosAddress + (index * 484) blockData = self.citra.read_memory(address, 232) statsData = self.citra.read_memory(address + 344, 22) data = blockData + statsData return Pokemon(data)
def makePokemon(obstacles): pokemon = pygame.sprite.Group() pokemonList = [] keyList = [] Pokemon.init() while len(pokemon) < 8: x3 = random.randint(0, 1200) y3 = random.randint(0, 800 - 150) #don't spawn under score rect pokemon.add(Pokemon(x3, y3)) if len(pygame.sprite.spritecollide(Pokemon(x3, y3), obstacles, False)) > 0: pokemon.remove(Pokemon(x3, y3)) for i in pokemon: pokemonList.append( str(i.x) + '=' + str(i.y) + '=' + str(i.key) + '=' + str(i.vX) + '=' + str(i.vY) + '=' + str(i.angleSpeed)) return pokemonList
def wildPokemon(self): address = self.wildAddress blockData = self.citra.read_memory(address, 232) statsData = self.citra.read_memory(address + 344, 22) data = blockData + statsData return Pokemon(data)
def createTeamFromListOfDicts(self, poke_dict_list): pokemon_list = [] for pokemon in poke_dict_list: p_id = pokemon['id'] move_list = pokemon['moves'] new_poke = Pokemon(p_id, pokeDict[p_id]['name'], pokeDict[p_id]['types'], pokeDict[p_id]['stats'], pokeDict[p_id]['moves']) move_dict = {} for move in move_list: move_dict[move] = moveDict[move] move_dict[move]['current_pp'] = move_dict[move]['pp'] new_poke.moves = move_dict pokemon_list.append(new_poke) self.pokemon = pokemon_list
def getPaddedPics(pokes): max_d = 380 # from a notebook imgs = [] for poke in pokes: if poke.load_pic("pokepics"): imgs.append(Pokemon.pad_data(poke.img, max_d, max_d)) else: print(poke, "has no image! Appending `None`") imgs.append(None) return imgs
def getParent(self, num): if num == 1: address = self.parent1Address else: address = self.parent2Address blockData = self.citra.read_memory(address, 232) statsData = self.citra.read_memory(address + 344, 22) data = blockData + statsData return Pokemon(data)
def crear(self, nombre, especie, tipo, foto): for poke in self.pokemon: if poke.nombre == nombre: print('el nombre del usuario ya está en uso') return False nuevo = Pokemon(self.contador, nombre, especie, tipo, foto) self.pokemon.append(nuevo) self.contador += 1 return True
def __updte_status_image(): game = database_client.get_game_collection() pokemons = game.find().sort("number",1) sprites_urls = [ (int(p['number']),Pokemon(p['number'], p['name'], p['alive']).get_sprites_path()) for p in pokemons ] pool = multiprocessing.Pool(7) sprites = list(pool.map(index_and_open_image, sprites_urls)) sorted_sprites = sorted(sprites, key=lambda sprite: sprite[0]) img = generate_status_image(sorted_sprites) amazon_client.update_status_image(img)
class TestPokeXmler(unittest.TestCase): def setUp(self): self.valid_pokemon = Pokemon(\ Type.Normal, Stats(100,100,100,100,100), MoveList(Move("move1",Type.Normal,3,2,1))) def test_init(self): self.assertTrue(isinstance(pokexmler(self.valid_pokemon), pokexmler)) # só pra ver que funciona depois vou tirar: print(pokexmler(self.valid_pokemon).tostring()) def test_PokeToXml(self): self.assertEqual(self.valid_pokemon.pokes_to_xml(), self.valid_pokemon) def test_Tree(self): self.assertEqual(self.valid_pokemon.tree(), self.valid_pokemon) def test_Tostring(self): self.assertTrue(self.valid_pokemon.tostring(), self.valid_pokemon) self.assertRaises(RuntimeError, self.valid_pokemon.tostring(), object()) def test_SrtToPokes(self): self.assertRaises(TypeError, self.valid_pokemon.str_to_pokes(), self.valid_pokemon)
def readPokemon(self, text): info = text[1:].split(",") pokemon = Pokemon(int(info[6]), int(info[1])) pokemon.hp = float(info[2]) pokemon.xp = int(info[3]) pokemon.status = Status(info[4]) if info[5] == "True": pokemon.shiny = True else: pokemon.shiny = False pokemon.attacks = [] for potentialAttacks in info[7:]: if potentialAttacks[0] == '(': pokemon.attacks.append(self.readAttack(potentialAttacks)) return pokemon
def read_create_pokemon_from_file(): fr = open("pokemon.csv") fr_list = [] list_of_pokemon = [] fr.readline() var = 0 for i in fr.readlines(): fr_list.append(i.strip().split(",")) list_of_pokemon.append(Pokemon(fr_list[var][0], fr_list[var][1], fr_list[var][2], fr_list[var][3], float(fr_list[var][4]), float(fr_list[var][5]), float(fr_list[var][6]), float(fr_list[var][7]), float(fr_list[var][8]), float(fr_list[var][9]), float(fr_list[var][10]), int(fr_list[var][11]), fr_list[var][12])) var += 1 fr.close() for pokemon in list_of_pokemon: blabla.store(pokemon.name, pokemon) return list_of_pokemon
def get_all_pokemon(): resp = requests.get("https://pokemondb.net/pokedex/national") soup = bs.BeautifulSoup(resp.text, 'lxml') cards = soup.find_all('span', {'class': 'infocard'}) if not cards: cards = soup.find_all('div', {'class': "infocard"}) pokemon = [] for card in cards: name = get_name(card) num = get_num(card) types = get_type(card) page = get_page(card) if len(types) > 1: type2 = types[1] else: type2 = None pokemon.append(Pokemon(name, num, types[0], type2, page)) return pokemon
def build(self): self.Poke_Dex = [] find = False x = 'stuff.csv' while (find != True): try: reader = csv.reader(open(x, newline='')) find = True except: x = input("input File not found reenter file name and path") #for row in reader: #print(row, len(row)) line = next(reader) line = next(reader) line = next(reader) #first pk for row in range(9): print(line) temp = Pokemon(line) self.Poke_Dex.append(temp) line = next(reader)
def create_pokemon(self): pok = Pokemon() pok.name = input('Enter pokemon name: ') pok.type = input('Enter pokemon type: ') for i in range(4): attack = Attack() attack.name = input('Enter the name of attack' + str(i) + ' for damage range ' + str(pok.damage_levels[i])) attack.damage = pok.damage_levels[i] pok.attacks.append(attack) self.pokemons.append(pok) pkl.pickler(self.pokemons, 'pokemons.pkl') print('Successful created: ') pok.show_specs() time.sleep(2) clear_output()
def generate_random_pokemon(): # I chose to represent each Pokemon's base stats, which will be normalized to a total of 600, # using a Gamma distribution. This will ensure that a Pokemon will never have negative stats, # and will tend to create similar but variable stat distributions. There are likely many other # great ways to generate these stats, but I liked this technique. stats = [math.floor(random.gammavariate(5, 20)) for x in range(0, 6)] type_primary = random.choice(types) type_secondary = random.choice(types) move_type = random.choice(types) damage_category = random.choice(["Physical", "Special"]) pokemon = Pokemon(stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], type_primary, type_secondary, move_type, damage_category, show_age=True, show_name=True) return pokemon
def tryMutation(self, move_mutation_rate, poke_mutation_rate): do_poke_mutation = random.random() < poke_mutation_rate do_move_mutation = random.random() < move_mutation_rate if do_poke_mutation: new_pokemon_key = random.choice(pokeList) poke_object = Pokemon(new_pokemon_key, pokeDict[new_pokemon_key]["name"], pokeDict[new_pokemon_key]["types"], pokeDict[new_pokemon_key]["stats"], pokeDict[new_pokemon_key]["moves"]) poke_object.generateMoves() poke_to_mutate = random.choice(self.pokemon) poke_object.combineMoves(poke_to_mutate) if do_move_mutation: poke_to_mutate = random.choice(self.pokemon) poke_to_mutate.doMoveMutation()
def catch_pokemon(self, player): if self.find_square(player.x, player.y).type == "G": found_pokemon = Pokemon(random.randint(0,4),random.randint(0,400) + 100,random.randint(0,400) + 100) xp_level = found_pokemon.health * found_pokemon.power while(True): print("do you want to throw a pókeball? (y/n) def: y") if input() != "n": if player.inv.get_stack(1) != False: player.inv.set_stack(1,player.inv.get_stack(1).amount - 1) success = random.randint(0,xp_level) if(success < 30000): player.inv.add_pokemon(found_pokemon) print("\"Gotcha!\"") break else: print("You don't have any pókeballs") print("Get some more in the premium store only 5.99€ for 10") break else: print("Why didn't you catch the pokemon? Well, maybe next time.") break else: print("Where do you see a pókemon?")
def __init__(self, theirTeam, driver, room, theirName): self.theirTeam = makePokemonArray(theirTeam) self.myTeam = [ Pokemon("Pikachu"), Pokemon("Charizard"), Pokemon("Blastoise"), Pokemon("Venusaur"), Pokemon("Snorlax"), Pokemon("Espeon") ] self.driver = driver self.theirName = theirName self.room = room self.BattleOptions = { "attk1": None, "attk2": None, "attk3": None, "attk4": None, "mega": None, "switch1": None, "switch2": None, "switch3": None, "switch4": None, "switch5": None, "switch6": None } self.chooseLead() while (not self.isBattleOver()): try: self.chooseAction() except: #print("No options to load!") sleep(10) print("And the winner is: " + self.winner) getItem(self.driver, "//*[@id=\"header\"]/div[2]/div/ul[2]/li/button").click()
def mousePressEvent(self, e): # left click event if e.buttons() == QtCore.Qt.LeftButton: # get x, y pos x = e.x() y = e.y() # Page 1: start button if self.page == 0 and x > 300 and x < 500 and y > 500 and y < 600: self.page = 1 elif self.page == 0 and x > 700 and x < 900 and y > 500 and y < 600: self.page = 1 self.Ultimate = True # Page 2: select Pokemons # boardary 40, 1120 + 50, 200, ----------------------------------------------need change if more pokemons if self.page == 1 and x > 40 and x < 1170 and y > 200 and y < 400 + 50 * root3: # change 400 to 500: add one more row i_x, i_y = int((x - 40) / 120), int((y - 200) / 100) # Ultimate Mode if self.Ultimate: # click on pokemons if len(self.Play1_Pokemons) < 3 and [ i_x, i_y ] not in self.Play1_Pokemons: self.Play1_Pokemons.append([ i_x, i_y ]) #---------------------------------need more logical elif len(self.Play1_Pokemons) == 3 and [ i_x, i_y ] not in self.Play2_Pokemons and len( self.Play2_Pokemons) < 3: self.Play2_Pokemons.append([i_x, i_y]) # Normal Mode else: if len(self.Play1_Pokemons) < 2 and [ i_x, i_y ] not in self.Play1_Pokemons and i_y == 0: self.Play1_Pokemons.append([i_x, i_y]) elif len(self.Play1_Pokemons) == 2 and [ i_x, i_y ] not in self.Play1_Pokemons and i_y == 1: self.Play1_Pokemons.append([i_x, i_y]) elif len(self.Play1_Pokemons) == 3 and [ i_x, i_y ] not in self.Play2_Pokemons and len( self.Play2_Pokemons) < 2 and i_y == 0: self.Play2_Pokemons.append([i_x, i_y]) elif len(self.Play1_Pokemons) == 3 and [ i_x, i_y ] not in self.Play2_Pokemons and len( self.Play2_Pokemons) == 2 and i_y == 1: self.Play2_Pokemons.append([i_x, i_y]) # click on Pokemon remove it - Player 1 elif self.page == 1 and x > 40 and x < 330 and y > 700 and y < 700 + 50 * root3: i_x = int((x - 40) / 120) if (i_x < len(self.Play1_Pokemons)): self.Play1_Pokemons.pop(i_x) # click on Pokemon remove it - Player 2 elif self.page == 1 and x > 880 and x < 1170 and y > 700 and y < 700 + 50 * root3: i_x = int((x - 880) / 120) if (i_x < len(self.Play2_Pokemons)): self.Play2_Pokemons.pop(i_x) #start the game elif self.page == 1 and len(self.Play1_Pokemons) == 3 and len( self.Play2_Pokemons ) == 3 and x > 500 and x < 610 and y < 660 and y > 600: self.page = 2 self.P1P.append( Pokemon( 1, 0, self.Play1_Pokemons[0][1] * 10 + self.Play1_Pokemons[0][0], 1)) self.P1P.append( Pokemon( 2, 0, self.Play1_Pokemons[1][1] * 10 + self.Play1_Pokemons[1][0], 2)) self.P1P.append( Pokemon( 0, 0, self.Play1_Pokemons[2][1] * 10 + self.Play1_Pokemons[2][0], 3)) self.P2P.append( Pokemon( 18, 9, self.Play2_Pokemons[0][1] * 10 + self.Play2_Pokemons[0][0], 4)) # 18, 9 self.P2P.append( Pokemon( 17, 9, self.Play2_Pokemons[1][1] * 10 + self.Play2_Pokemons[1][0], 5)) # 17, 9 self.P2P.append( Pokemon( 19, 9, self.Play2_Pokemons[2][1] * 10 + self.Play2_Pokemons[2][0], 6)) # 19, 9 for i in self.P1P: self.p1uid.append( i.uid) # Player 1 Pokemon list - used for later # Page 3: Map and Algo elif self.page == 2: # check click points point = self.posToIndex(x, y) # click on Pokemons # if nothing have been selected if not self.select_poke: for i in self.P1P: if point[0] == i.x and point[1] == i.y: self.select_poke = True self.target_poke = i for i in self.P2P: if point[0] == i.x and point[1] == i.y: self.select_poke = True self.target_poke = i # selected poke flag == true then ... else: # already select one pokemon # check whether switch to another pokemon / require no buttons pushed another_flag = False #print(self.spell1,self.spell2,self.ulti) if not self.spell1 and not self.spell2 and not self.ulti: for i in self.P1P: if point[0] == i.x and point[1] == i.y: another_flag = True self.target_poke = i for i in self.P2P: if point[0] == i.x and point[1] == i.y: another_flag = True self.target_poke = i # if Player click on one pokemon and one action button then ... if another_flag or self.checkButtonClick(x, y): pass elif (self.move or self.spell1 or self.spell2 or self.ulti ) and (self.target_poke.uid in self.p1uid or len(self.p1uid) <= len(self.moved) ) and self.target_poke.uid not in self.moved: # action holding - dont move but attack if self.move: pass # Spelling algorithm elif self.spell1 or self.spell2 or self.ulti: if self.spell1: type_spell = 1 elif self.spell2: type_spell = 2 elif self.ulti: type_spell = 3 if self.target_poke.pid == 0: Spell.id0_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 1: Spell.id1_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 2: Spell.id2_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 3: Spell.id3_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved, self.turn) elif self.target_poke.pid == 4: Spell.id4_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved, self.turn) elif self.target_poke.pid == 5: Spell.id5_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 6: Spell.id6_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 7: Spell.id7_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 8: Spell.id8_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 9: Spell.id9_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 10: Spell.id10_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 11: Spell.id11_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 12: Spell.id12_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 13: Spell.id13_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 14: Spell.id14_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved, self.thunder) elif self.target_poke.pid == 15: Spell.id15_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 16: Spell.id16_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 17: Spell.id17_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 18: Spell.id18_spell(self.map, self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) elif self.target_poke.pid == 19: Spell.id19_spell(self.P1P, self.P2P, self.target_poke, point, type_spell, self.moved) self.spell1, self.spell2, self.ulti = False, False, False # short case for movement elif self.checkMovement(point[0], point[1]) and ( self.target_poke.uid in self.p1uid or len(self.p1uid) <= len(self.moved) ) and self.target_poke.uid not in self.moved: self.movePokemon(point[0], point[1]) self.attackEnemy() else: self.spell1, self.spell2, self.ulti = False, False, False # check all six pokemons finished if len(self.moved) == len(self.P1P) + len(self.P2P): self.moved = [] self.water_extra = [] star_check = False for a in self.P1P: self.endOfRound(a, self.P1P) # star check if a.type == 'star' or a.type2 == 'star': star_check = True star = a for a in self.P2P: self.endOfRound(a, self.P2P) # star check if a.type == 'star' or a.type2 == 'star': star_check = True star = a if star_check and self.turn % 7 == 0: self.star_effect(a.x, a.y) # thunder count down if self.thunder != []: if self.thunder[0][1] != 0: self.thunder[0][1] -= 1 self.turn = self.turn + 1 # check pokemon alive and stun for a in self.P1P: # check alive if a.cur_HP <= 0: if a.pid == 17 and a.ult and a.once: a.cur_HP = a.HP a.ult = False else: self.P1P.remove(a) self.p1uid.remove(a.uid) # special ult check self.specialUltCheck(a, self.moved, True) # check stun if a.stun != 0 and a.uid not in self.moved: self.moved.append(a.uid) a.stun -= 1 for a in self.P2P: #check alive if a.cur_HP <= 0: if a.pid == 17 and a.ult and a.once: a.cur_HP = a.HP a.ult = False else: self.P2P.remove(a) # special ult check self.specialUltCheck(a, self.moved, True) # check stun if len(self.moved ) >= 3 and a.stun != 0 and a.uid not in self.moved: self.moved.append(a.uid) a.stun -= 1 # reload page self.update()
def setPoke(self, name): self.pokemon = Pokemon(name, 123)
class testPokemon(unittest.TestCase): def setUp(self): self.valid_pokemon1 = Pokemon([Type(7),Type(8)], Stats(2, 3, 4, 5, 6), [Move("atk", Type(2), 100, 30, 200), Move("atk", Type(2), 100, 30, 100)], "teste", 5) self.valid_pokemon2 = Pokemon([Type(3),Type(4)], Stats(10, 11, 3, 13, 14), [Move("atk", Type(1), 7, 8, 9)], "NameTest2", 1) self.valid_type_list = [Type(7),Type(8)] self.valid_stats = Stats(10, 3, 4, 5, 6) self.valid_name = "NameTest" self.valid_level = 5 self.valid_move = [Move("atk", Type(2), 100, 30, 5), Move("atk2", Type(2), 100, 30, 100)] self.valid_movelist = MoveList([Move("atk", Type(2), 100, 30, 5), Move("atk2", Type(2), 100, 30, 100)]) pass def test_is_alive(self): # Test regular use of function self.assertTrue(self.valid_pokemon1.is_alive()) dead_pokemon = Pokemon([Type(7),Type(8)], Stats(0, 3, 4, 5, 6), [Move("atk", Type(2), 100, 30, 5)], "teste", 5) self.assertFalse(dead_pokemon.is_alive()) def test_perform_move(self): # Test for a regular damage damage = self.valid_pokemon1.perform_move(self.valid_pokemon1.moves.get_move(0), self.valid_pokemon2) self.assertTrue(damage >= 0) self.assertTrue(type(damage) is int) # Test absurd parameters self.assertRaises(TypeError, self.valid_pokemon1.perform_move, self.valid_pokemon1, object(), self.valid_pokemon2) self.assertRaises(TypeError, self.valid_pokemon1.perform_move, self.valid_pokemon1, self.valid_pokemon1.moves.get_move(0), object()) # Test pp move = self.valid_pokemon1.moves.get_move(1) for i in range(100): old_pp = move.pp self.valid_pokemon1.perform_move(move, self.valid_pokemon2) new_pp = move.pp self.assertEqual(old_pp - 1, new_pp) def test_compare_types_to(self): # Test valid entries self.assertEqual(self.valid_pokemon1.compare_types_to(self.valid_pokemon2), 2) self.assertEqual(self.valid_pokemon1.compare_types_to(self.valid_pokemon1), 1) self.assertEqual(self.valid_pokemon2.compare_types_to(self.valid_pokemon1), 0.5) # Test exceptions self.assertRaises(TypeError, self.valid_pokemon1.compare_types_to, self.valid_pokemon1, object()) def test_receive_damage(self): # Test regular use of the function self.valid_pokemon2.receive_damage(5) self.assertEqual(self.valid_pokemon2.hp, 5) self.valid_pokemon2.receive_damage(0) self.assertEqual(self.valid_pokemon2.hp, 5) # Test absurds self.assertRaises(TypeError, self.valid_pokemon1.receive_damage, object()) self.assertRaises(ValueError, self.valid_pokemon1.receive_damage, -100) def test_best_move(self): # Test regular use of the function #self.assertEqual(self.valid_pokemon1.perform_move(self.valid_movelist.get_move(1), self.valid_pokemon2), self.valid_pokemon1.perform_move(self.valid_pokemon1.best_move(self.valid_pokemon2), self.valid_pokemon2)) pass
from Engine import fight from Pokemon import Pokemon if __name__ == '__main__': #Create Pokemon Charizard = Pokemon('Charizard', 'Fire', ['Flamethrower', 'Fly', 'Blast Burn', 'Fire Punch'], { 'ATTACK': 12, 'DEFENSE': 8 }) Blastoise = Pokemon('Blastoise', 'Water', ['Water Gun', 'Bubblebeam', 'Hydro Pump', 'Surf'], { 'ATTACK': 10, 'DEFENSE': 10 }) Venusaur = Pokemon( 'Venusaur', 'Grass', ['Vine Wip', 'Razor Leaf', 'Earthquake', 'Frenzy Plant'], { 'ATTACK': 8, 'DEFENSE': 12 }) Charmander = Pokemon('Charmander', 'Fire', ['Ember', 'Scratch', 'Tackle', 'Fire Punch'], { 'ATTACK': 4, 'DEFENSE': 2 }) Squirtle = Pokemon('Squirtle', 'Water', ['Bubblebeam', 'Tackle', 'Headbutt', 'Surf'], { 'ATTACK': 3, 'DEFENSE': 3
def test_is_alive(self): # Test regular use of function self.assertTrue(self.valid_pokemon1.is_alive()) dead_pokemon = Pokemon([Type(7),Type(8)], Stats(0, 3, 4, 5, 6), [Move("atk", Type(2), 100, 30, 5)], "teste", 5) self.assertFalse(dead_pokemon.is_alive())
def setUp(self): self.valid_pokemon = Pokemon(\ Type.Normal, Stats(100,100,100,100,100), MoveList(Move("move1",Type.Normal,3,2,1)))