# Array used to store the ID, name, and EVs of each pokemon. pokemonData = [] for row in rows: # This will store all of the scraped data into a Pokemon object. # See ./Pokemon.py for class definition. pokemon = Pokemon() rowData = row.find_all("td") # Ensures that the rowData is actually a Pokemon row. if (len(rowData) > 0): # Assign stats to object. pokemon.value = rowData[POKEMON_ID_INDEX].b.string pokemon.hitPoints = int(rowData[HP_INDEX].string) pokemon.attack = int(rowData[ATTACK_INDEX].string) pokemon.defense = int(rowData[DEFENSE_INDEX].string) pokemon.specialAttack = int(rowData[SPECIAL_ATTACK_INDEX].string) pokemon.specialDefense = int(rowData[SPECIAL_DEFENSE_INDEX].string) pokemon.speed = int(rowData[SPEED_INDEX].string) # Some pokemon have an additional name (such as Mega Charizard). This checks # for that as it is a seperate HTML element. if (rowData[POKEMON_NAME_INDEX].small != None): pokemon.name = f"{rowData[POKEMON_NAME_INDEX].a.string} {rowData[POKEMON_NAME_INDEX].small.string}" else: pokemon.name = rowData[POKEMON_NAME_INDEX].a.string pokemonData.append(pokemon) # TODO: Look into why this is happening. For some reason the first pokemon in
Move('comet-punch', 'normal', 18, 85, 2), Move('pay-day', 'normal', 40, 100, 2) ] p2 = Pokemon('pidgeot', 'normal', 'flying', m_L, 83, 80, 75, 70, 70) m_L2 = [ Move('slam', 'normal', 80, 75, 2), Move('thunder-punch', 'electric', 75, 100, 2), Move('thunderbolt', 'electric', 90, 100, 3), Move('thunder', 'electric', 110, 70, 3) ] p1 = Pokemon('pikachu', 'electric', '', m_L2, 35, 55, 40, 50, 50) print(p1) print(p2) print("Attack #1") print("{} hp before:{}".format(p2.get_name(), p2.get_hp())) p1.attack(Move('thunderbolt', 'electric', 90, 100, 3), p2) print("{} hp after:{}".format(p2.get_name(), p2.get_hp())) assert p2.get_hp() == 0 print('-' * 20) m_L3 = [ Move('bubble', 'water', 40, 100, 3), Move('rock-throw', 'rock', 50, 90, 2), Move('bone-club', 'ground', 65, 85, 2), Move('dig', 'ground', 80, 100, 2) ] m_L4 = [ Move('wrap', 'normal', 15, 90, 2), Move('horn-attack', 'normal', 65, 100, 2), Move('self-destruct', 'normal', 200, 100, 2), Move('egg-bomb', 'normal', 100, 75, 2) ]
from pokemon import Pokemon from dummy import Dummy bulb = Pokemon('Bulbasaur', 'Grass', 10, 10, 3, 2) doug = Dummy('Doug', 69) bulb.speak() print(doug.health) bulb.attack(doug) print(doug.health)