def add_pokes(teamSpots, pokeDict): Player1 = [] while True: inputStr = input("Enter a pokemon's name or QUIT to quit: ").lower() if (inputStr == 'quit') or (inputStr == 'q'): return Player1 break else: if inputStr in pokeDict: if teamSpots - 1 > 0: print( "You added %s to your team! You have %d spots remaining on your team." % (inputStr, teamSpots - 1)) teamSpots -= 1 Player1.append(pokemon.Pokemon(pokeDict, inputStr)) else: teamSpots -= 1 Player1.append(pokemon.Pokemon(pokeDict, inputStr)) print("Your team is full, let's take a look: ") for poke in Player1: print([ poke.name, poke.types, poke.ability, poke.stats, poke.moves ]) return Player1 break else: print( "That doesn't seem to be a Pokemon, make sure you spelled it correctly. Or press \'q\' to exit" ) return
def __init__(self): #This typechart will be used to calculate damage when making decisions. #The row represents the attacking type, the column represents the defending type self.typechart = [[1, 1, 1, 1, 1, 0.5, 1, 0, 0.5, 1, 1, 1, 1, 1, 1, 1, 1]] self.typechart.append([2, 1, 0.5, 0.5, 1, 2, 0.5, 0, 2, 1, 1, 1, 1, 0.5, 2, 1, 2]) self.typechart.append([1, 2, 1, 1, 1, 0.5, 2, 1, 0.5, 1, 1, 2, 0.5, 1, 1, 1, 1 ]) self.typechart.append([1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 0, 1, 1, 2, 1, 1, 1, 1, 1]) self.typechart.append([1, 1, 0, 2, 1, 2, 0.5, 1, 2, 2, 1, 0.5, 2, 1, 1, 1, 1]) self.typechart.append([1, 0.5, 2, 1, 0.5, 1, 2, 1, 0.5, 2, 1, 1, 1, 1, 2, 1, 1]) self.typechart.append([1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 2, 1, 2, 1, 1, 2]) self.typechart.append([0, 1, 1, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 1, 2, 1, 1, 0.5]) self.typechart.append([1, 1, 1, 1, 1, 2, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 1, 2, 1, 1]) self.typechart.append([1, 1, 1, 1, 1, 0.5, 2, 1, 2, 0.5, 0.5, 2, 1, 1, 2, 0.5, 1]) self.typechart.append([1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 0.5, 0.5, 1, 1, 1, 0.5, 1]) self.typechart.append([1, 1, 0.5, 0.5, 2, 2, 0.5, 1, 0.5, 0.5, 2, 0.5, 1, 1, 1, 0.5, 1]) self.typechart.append([1, 1, 2, 1, 0, 1, 1, 1, 1, 1, 2, 0.5, 0.5, 1, 1, 0.5, 1]) self.typechart.append([1, 2, 1, 2, 1, 1, 1, 1, 0.5, 1, 1, 1, 1, 0.5, 1, 1, 0]) self.typechart.append([1, 1, 2, 1, 2, 1, 1, 1, 0.5, 0.5, 0.5, 2, 1, 1, 0.5, 2, 1]) self.typechart.append([1, 1, 1, 1, 1, 1, 1, 1, 0.5, 1, 1, 1, 1, 1, 1, 2, 1]) self.typechart.append([1, 0.5, 1, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 1, 2, 1, 1, 0.5]) self.party = [] pokemon1 = pokemon.Pokemon() pokemon2 = pokemon.Pokemon() pokemon3 = pokemon.Pokemon() self.party.append(pokemon1) self.party.append(pokemon2) self.party.append(pokemon3)
def selectEnemies(self): # get number of enemies and number of "smart" enemies to select num_of_enemies = self.num_of_pokemons smart_enemies_num = int(num_of_enemies * self.difficulty) # choose enemies according to a heuristic function to make the battle harder heuristics = [] for p in range(smart_enemies_num): enemy, best_h = pokemon.PokemonList[0], 0 p_min = p - 1 if p > 0 else p p_plus = p + 1 if p < len(self.partners) else p for m in range(len(pokemon.PokemonList)): cur_h = pokemon.heuristicValue(m, self.partners[p], self.partners[p_min:p_plus]) if cur_h > best_h: enemy, best_h = pokemon.PokemonList[m], cur_h heuristics.append(enemy) """print(" ".join(format(k['name']) for k in heuristics))""" # get the other enemies random_enemies = random.choices(pokemon.PokemonList, k=num_of_enemies - smart_enemies_num) # append all chosen enemies to the battle for pkmn in heuristics + random_enemies: name, base_stats, types, p_moves = pkmn self.enemies.append( pokemon.Pokemon(name, base_stats, types, p_moves)) return self.enemies[0]
def process_one(control_info, pokemon_reqs, raw_p): # logger.info(f"processing {pprint.pformat(raw_p)}") # logger.debug(p) try: raw_p['encounter_id'] != None except Exception as e: p = pokemon.Pokemon(raw_p) logger.error(e) raise e p = None for min_req in pokemon_reqs: lvl_req = min_req['lvl'] iv_req = min_req['iv'] distance_req = min_req.get('distance') if min_req.get( 'distance') else int(control_info['distance']) if raw_p['level'] >= lvl_req: iv = (raw_p['individual_attack'] + raw_p['individual_stamina'] + raw_p['individual_defense']) / 0.45 if iv >= iv_req: if p == None: p = pokemon.PoGoAlertPokemon(raw_p) if p.is_in_manhattan: p.distance = distance_between(p.loc, control_info['ref_loc']) if p.is_in_manhattan and p.distance <= distance_req: # logger.debug(f"distance: {distance_req} > {p.distance}") send_groupme(control_info['iSawIt_id'], p) logger.info(f"[{control_info['iSawIt_id']}] - {p}") return
def mostrar_menu(self): while True: pk = pokemon.Pokemon() bpk = bp.BancoPokemon() print( "1-Testar Pokedex\n2-Lista com os id's\n3-Capturar dados\n4-Dados Completos\n5-Sair" ) op = int(input()) if op == 1: if pk.testar_pokedex(): print('Pokedex online') else: print('Pokedex Offline') elif op == 2: print('Abrindo navegador externo...') pk.abrir_site() elif op == 3: id_pk = int(input('Digite o Id do pokemon: ')) id_local = pk.localizacao_pokemon(id_pk) pk.captura_dados_pokemon(id_pk, id_local) elif op == 4: id_pk = int(input('Digite o Id do pokemon: ')) bp.BancoPokemon().consulta_completa(id_pk) elif op == 5: exit() else: print('Op invalida')
def __init__(self, name, pokemon, levels, types, potions, revives): self.name = name self.pokemon_names = pokemon self.pokemon = [] self.potions = potions self.revives = revives self.currently_active = 0 # Create Pokemon instances for each pokemon for i in range(len(pokemon)): self.pokemon.append( pokemod.Pokemon(pokemon[i], levels[i], types[i], False))
def selectPartners(self, chosen): if 3 <= len(chosen) <= 6: self.num_of_pokemons = len(chosen) for pkmn in chosen: name, base_stats, types, p_moves = pkmn partner = pokemon.Pokemon(name, base_stats, types, p_moves) partner.setPlayer() self.partners.append(partner) return self.partners[0] return None
def gen_number(used_numbers, deck): """ Generate a random number between 1-151 and add the respective Pokemon to the deck if it is not already in the game deck. """ number = randint(1, 151) while (number in used_numbers): number = randint(1, 151) poke = pokemon.Pokemon(number) deck.append(poke) used_numbers.append(number) return deck
def __init__(self, game): objects.RenderedNPC.__init__(self) #init NPC renderer self.g = game.g #store parameters self.game = game #load animations self.animator = animation.AnimationGroup( self.g, self, "objects/player/player_animation.xml") self.collidepoint = (16, 23) #set where to check for collisions self.size = (32, 32) #set sprite size self.tile_pos = self.g.save.get_prop("player", "pos", [5, 8]) #load current position self.game.set_obj_pos(self, self.tile_pos) self.pos = [((self.tile_pos[0] - 1) * 16) + 8, (self.tile_pos[1] - 1) * 16] #set position in pixels self.rect = pygame.Rect(self.pos, self.size) #turn it into a rect self.move_direction = (0, 0 ) #we aren't moving in a particular direction self.direction = self.g.save.get_prop("player", "direction", 1) #load direction self.animator.set_animation( "stand_" + get_direction_name(self.direction)) #set proper direction self.animator.update() #let it update self.moving = False #we aren't moving at all self.was_moving = False self.move_frames = 0 #amount of movement frames left self.in_water = False #whether we're currently walking in water self.notify_dlog = dialog.Dialog(self.g, "notify") #initialize a notify dialog self.move_manager = objects.MovementManager( self ) #make a movement manager so we can be controlled in cutscenes self.party = self.g.save.get_prop("player", "pokemon", None) #load pokemon if self.party is None: #if none were loaded self.party = [pokemon.get_data("reuniclus").generate(5) ] #make a new one else: #if they were t = self.party self.party = [] for data in t: #load pokemon data p = pokemon.Pokemon() #make a new pokemon p.load(data) #load its saved data self.party.append(p) #add it to list of pokemon
def get_pokemon(self, request_: Request) -> None: """ Convert JSON to Pokemon object :return: Pokemon """ for json in request_.json: # Create stats object base_list = [] for stat in json["stats"]: name = stat["stat"]["name"] base_stats = stat["base_stat"] url = stat["stat"]["url"] base_list.append(p.BaseStats(name, base_stats, url)) stats = p.Stats(base_list[0], base_list[1], base_list[2], base_list[3], base_list[4], base_list[5]) # Create list of Abilities abilities = [] for i in range(len(json["abilities"])): name = json["abilities"][i]["ability"]["name"] url = json["abilities"][i]["ability"]["url"] abilities.append(p.Ability(name=name, url=url)) # Create list of Moves moves = [] for i in range(len(json["moves"])): name = json["moves"][i]["move"]["name"] level = json["moves"][i]["version_group_details"][0][ "level_learned_at"] move_url = json["moves"][i]["move"]["url"] moves.append(p.Move(name=name, level=level, url=move_url)) # setattr(key, value) # Create Pokemon pokemon = p.Pokemon(json["name"], json["id"], json["height"], json["weight"], stats, json["types"], abilities, moves) request_.results.append(pokemon)
import pokemon as pok # Importamos a pokemon que donde se encuentr la class from utilidades_extra import tirar_dado # JUEGO DE POKEMON tipos = "Planta, Fuego, Agua, Tierra" p1 = pok.Pokemon("Pikachu", 15) # Creamos nuestros pokemon p2 = pok.Pokemon("Bulbasaur", 14) p3 = pok.Pokemon("Charmander", 16) p4 = pok.Pokemon("Onix", 14) # Inicializamos los valores y el turno p1.vida = 100 p2.vida = 100 p3.vida = 100 p4.vida = 100 turno = tirar_dado(2) while True: num1 = input( "Ingresa un numero para elegir tu primer Pokemon\n (1) Pikachu." "\n (2) Bulbasaur.\n (3) Charmander.\n (4) Onix\n >>") num2 = input( "Ingresa otro numero para elegir el Pokemon contrincante\n " "(1) Pikachu.\n (2) Bulbasaur.\n (3) Charmander.\n (4) Onix\n >>") f = (print("Ha Iniciado la batalla")) print("Es el turno #", turno) try: if num1 == '1' and num2 == '2': print(f"{p1.name} se enfrenta a {p2.name}\n") elif num1 == '1' and num2 == '3': print(f"{p1.name} se enfrenta a {p3.name}\n")
MyPokedex.make(regionName) #---------------------------------------------------------------------------------- # Enter a new pokemon into the current pokedex. #---------------------------------------------------------------------------------- elif choice == 3: if MyPokedex == "": print("Open a pokedex first.") else: discoverPokemon = input( 'Enter the name of the pokemon you just discovered and its number, separated by a space: ' ) discoverPokemon = discoverPokemon.split() name = discoverPokemon[0].capitalize() number = discoverPokemon[1] DiscoveredPokemon = pokemon.Pokemon(name, number) ptype = input( 'Enter the type of the pokemon(type "dual" for a dual-type pokemon): ' ).capitalize() if ptype == 'Dual': ptype = MyPokedex.dualType() height = float(input('Enter the height of the pokemon: ')) weight = float(input('Enter the weight of the pokemon: ')) info = input( 'Enter one or two sentences that give some information about the pokemon: ' ).capitalize() health = int(input('Enter the health of the pokemon: ')) attack = int(input('Enter the attack of the pokemon: ')) defense = int(input('Enter the defense of the pokemon: ')) speed = int(input('Enter the speed of the pokemon: ')) DiscoveredPokemon.entry(info, weight, height, ptype)
def make_random_team(num): teamsize = 6 team = [] pokemon_chosen = [] # Weird edge case moves that we didn't have time to implement skipped_moves = [ 'BIDE', 'COUNTER', 'DISABLE', 'DOUBLEEDGE', 'DRAGONRAGE', 'DREAMEATER', 'FOCUSENERGY', 'HAZE', 'HIGHJUMPKICK', 'HYPERBEAM', 'JUMPKICK', 'LIGHTSCREEN', 'MIMIC', 'MINIMIZE', 'MIRRORMOVE', 'MIST', 'PSYWAVE', 'RAGE', 'REFLECT', 'SEISMICTOSS', 'SONICBOOM', 'STRUGGLE', 'SUPERSONIC', 'TELEPORT', 'TRANSFORM', 'SKULLBASH', 'NIGHTSHADE', 'SUBSTITUTE', 'WHIRLWIND', 'ROAR', 'METRONOME', 'SELFDESTRUCT', 'EXPLOSION' ] # Until we have 6 pokemon while len(team) < teamsize: # choose a random pokemon from the pokedex (0-indexed) pokedex_num = fakerandom.fakerandint(0, 150) while pokedex_num in pokemon_chosen: pokedex_num = fakerandom.fakerandint(0, 150) species = pokedex.pokedex_list.keys()[pokedex_num] pokemon_chosen.append(pokedex_num) # skip ditto because we didnt implement transform if species == 'DITTO': continue # set constants that we dont want to randomize level = 100 ivs = [31, 31, 31, 31, 31, 31] evs = [0, 0, 0, 0, 0, 0, 0] # pick 4 attacks attacks = [] attacks_chosen = [] learnset = learnsets.learnset_list[pokedex.pokedex_list.keys() [pokedex_num]] while len(attacks) < 4: attack_num = fakerandom.fakerandint(0, len(learnset) - 1) while (attack_num in attacks_chosen and len(attacks_chosen) < len(learnset)): attack_num = fakerandom.fakerandint(0, len(learnset) - 1) attacks_chosen.append(attack_num) attack = learnset[attack_num] #skip attacks we didnt implement if attack in skipped_moves: continue attacks.append((attack, 3)) # pick gender based on pokemon's gender ratios gender = None ratios = pokedex.pokedex_list[species].gender_ratios counter = 0 gender_num = fakerandom.fakerandom() if gender_num >= counter and gender_num < counter + ratios[0]: gender = 'MALE' counter += ratios[0] if gender_num >= counter and gender_num < counter + ratios[1]: gender = 'FEMALE' team.append( pokemon.Pokemon(species, level, gender, num, ivs, evs, attacks)) return Team(team)
elif gen == 5: return 5 else: return 1 elif ball_name == "Dusk Ball": if location == "Cave" or time == "Night": return 3.5 else: return 1 else: return 1 gen = 4 piplup = pokemon.Pokemon(gen, "TENTACOOL", "Male", 17, "Mild", "Torrent", "None", "None", "None", "None", "None", 25, 31, 31, 31, 30, 31) abra = pokemon.Pokemon(gen, "TENTACRUEL", "Female", 6, "Modest", "Synchronize", "None", "None", "None", "None", "None", 12, 10, 15, 20, 25, 30) print(calc_catchrate("Net Ball", piplup, abra, "Normal", "Thick Grass")) print(calc_catchrate("Net Ball", abra, piplup, "Normal", "Thick Grass")) #print(calc_catchrate("Poké Ball", piplup, abra, "Frozen", "Thick Grass")) #print(calc_catchrate("Great Ball", piplup, abra, "Normal")) #print(calc_catchrate("Great Ball", piplup, abra, "Poisoned")) #print(calc_catchrate("Great Ball", piplup, abra, "Frozen")) #print(calc_catchrate("Ultra Ball", piplup, abra, "Normal")) #print(calc_catchrate("Ultra Ball", piplup, abra, "Poisoned"))
import pokemon # NOTE: ivs are generated as if these pokemon were wild # NOTE: evs are zeroed out # NOTE: damage formula is non-deterministic so your results may vary charmander = pokemon.Pokemon(pokemon.find_species('charmander'), level=3, moves=[ pokemon.find_move(move) for move in ('scratch', 'growl', 'ember', 'leer') ]) squirtle = pokemon.Pokemon(pokemon.find_species('squirtle'), level=3, moves=[ pokemon.find_move(move) for move in ('tackle', 'tail whip', 'bubble', 'water gun') ]) dmg = pokemon.formulas.damage(squirtle, squirtle.moves['bubble'], charmander) print(dmg) # example: prints => Damage(damage=13, luck=0.9900914399158687, critical_hit=False, effectiveness=2)
import pokemon # create many objects of Pokemon charmander = pokemon.Pokemon("Charmander", 20, "Fire", 500, 500, False) ninetales = pokemon.Pokemon("Ninetales", 50, "Fire", 300, 300, False) blastoise = pokemon.Pokemon("Blastoise", 70, "Water", 1000, 1000, False) kyogre = pokemon.Pokemon("Kyogre", 100, "Water", 10000, 10000, False) sceptile = pokemon.Pokemon("Sceptile", 59, "Grass", 900, 900, False) bulbasaur = pokemon.Pokemon("Bulbasaur", 25, "Grass", 400, 400, False) # create objects of Trainer nick = pokemon.Trainer("Nick", [charmander, kyogre, sceptile], { "healing water": 10, "sacred water": 5 }, 1) peter = pokemon.Trainer("Peter", [ninetales, blastoise, bulbasaur], { "healing water": 7, "sacred water": 5 }, 2) # test the method in two Class kyogre.kncok_out() nick.attack_other_trainer(peter)
import MySQLdb as sql import pokemon import pokeDB db = pokeDB.PokeDB() cur, conn = db.create_Table() bulbasaur = pokemon.Pokemon(1, 'Bulbasaur', 'Grass', 'Poison') charmander = pokemon.Pokemon(5, "Charmander", "Fire") charmander.set_ID(4) squirtle = pokemon.Pokemon(7, "Squirtles", "Water", "Ground") squirtle.set_Secondary() db.put(bulbasaur, cur) db.put(charmander, cur) db.put(squirtle, cur) charmander.set_ID(6) charmander.set_Name('Charizard') charmander.set_Secondary('Flying') db.update(charmander, 4, cur) cur.execute('''SELECT * FROM Pokemon''') row = cur.fetchall() print(row)
# - manually create Pokemon and Moves that are not gen1 # first let's make ice_fang since its not a built-in (read: not gen1) move ice_fang = pokemon.move(name='ice fang', type_='ice', category='physical', power=65, accuracy=.65, max_pp=15) # similarily, have to make glaceon since its not gen1 glaceon = pokemon.Pokemon(pokemon.Species(national_pokedex_number=471, name='glaceon', types=['ice'], base_stats=pokemon.Stats(hp=65, attack=60, defense=110, special=130, speed=65)), level=75, moves=[ice_fang]) # hard-code stats as given in the example on bulbapedia glaceon._stats = pokemon.Stats(hp=201, attack=123, defense=181, special=glaceon.stats.special, speed=glaceon.stats.speed) # again, have to manually construct garchomp since its not gen1 garchomp = pokemon.Pokemon(pokemon.Species(national_pokedex_number=445, name='garchomp', types=['dragon', 'ground'],
@property def last_block(self): # Returns the last Block in the chain return self.chain[-1] # Instantiate our Node app = Flask(__name__, template_folder='templates') # Generate a globally unique address for this node node_identifier = str(uuid4()).replace('-', '') # Instantiate the Blockchain blockchain = Blockchain() pok = pokemon.Pokemon() @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'GET': return render_template('./login.html') if request.method == 'POST': values = request.form if not values['Username']: message = "Trainername left blank" return render_template('./login.html', mess=message) if not values['pw']: message = "Password left blank" return render_template('./login.html', mess=message) if values['type'] == 'Log':
def atk_damage_range(filename, gen, name, gender, level, nature, ability, hp, atk, Def, spatk, spdef, spd): output_file = "DamageRange_Atk_{}_{}_{}_{}_{}_{}_{}_{}.csv".format(name, nature, hp, atk, Def, spatk, spdef, spd) with open(filename, "r") as f, open(output_file, "w") as i: f.readline() i.write("BATTLE,DEF_NAME,MOVE_NAME,DEF_STAGE,ATK_STAGE,DAMAGE_RANGE,DEF_HP,MIN_TURNS,MAX_TURNS,CRIT,"\ "HP_BOOST,ITEM,SCREEN,WEATHER,EVS,ATK_STAT,DEF_STAT,TOTAL_EXP,LEVEL,POKERUS\n") last_battle = -1 battle_num = 0 atk_pkmn = pokemon.Pokemon(gen, name, gender, level, nature, ability, "", "", "", "", "", hp, atk, Def, spatk, spdef, spd) for lines in f: info = lines.strip().split(",") battle_num = info[0] battle_type = info[1].upper() num_poke = int(info[2]) trainer = True if battle_type != "WILD" else False n = 0 #Information which changes for each battle if last_battle != battle_num: last_battle = battle_num screens = [""] weathers = list(set([info[3].upper()] + update_weather(atk_pkmn, []))) location = info[4] atk_pkmn.pokerus = bool(info[33]) #Change the user pokemon specie if it has evolved or was switched if atk_pkmn.species.name != info[21].upper(): atk_pkmn.species = speciedex.all.dex[int(gen)][info[21].upper()] atk_pkmn.update_stats() atk_stage, def_stage, spatk_stage, spdef_stage, spd_stage = 0, 0, 0, 0, 0 atk_pkmn.boost = [0, 0, 0, 0, 0, 0] max_atk, min_atk, max_def, min_def = 0, 0, 0, 0 name = [] #Updates user pokémon item, moves, happiness value and rare candy usage atk_pkmn.item = info[22].upper() atk_pkmn.moves = [movedex.all.dex[gen][x.upper()] for x in [info[23], info[24], info[25], info[26]] if x != ""] for x in range(int(info[32])): atk_pkmn.rare_candy() atk_pkmn.happiness = int(info[34]) #Creates defending pokemon def_pkmn = pokemon.Pokemon(gen, info[5], info[6], int(info[7]), info[8], info[9], info[10], info[11].upper(), info[12].upper(), info[13].upper(), info[14].upper(), int(info[15]), int(info[16]), int(info[17]), int(info[18]), int(info[19]), int(info[20])) #Updates weather and screen based on defending moves weathers = update_weather(def_pkmn, weathers) screens = update_screen(def_pkmn, screens) #updates stages atk_stage += int(info[27]) def_stage += int(info[28]) spatk_stage += int(info[29]) spdef_stage += int(info[30]) spd_stage += int(info[30]) #Loop to calculate damage ranges for move in atk_pkmn.moves: ability = atk_pkmn.ability category = move.category hps = [atk_pkmn.stat[0]] hp_boost = False type = move.type.name n += 1 if def_pkmn.ability == "INTIMIDATE" and n == 1: name.append(def_pkmn.species.name) if category == "STATUS": continue elif category == "PHYSICAL": max_atk = 2 if check_mod_atk(atk_pkmn, True) else atk_stage min_atk = min(len(name) * -1, -2 if check_mod_atk(def_pkmn, False) else 0) max_def = 0 min_def = -2 if check_mod_def(atk_pkmn, False) else 0 else: max_atk = spatk_stage min_atk = 0 max_def = 0 min_def = 0 if (ability == "BLAZE" and type == "FIRE") or (ability == "OVERGROW" and type == "GRASS") or (ability == "SWARM" and type == "BUG") or (ability == "TORRENT" and type == "WATER"): boost = hps.append(1) hp_boost = True for crit in (False, True): for hp in hps: atk_pkmn.hp = hp for def_mod in range(min_def, max_def + 1): if category == "PHYSICAL": def_pkmn.boost[2] = def_mod else: def_pkmn.boost[4] = def_mod if crit and def_mod > 0: continue for atk_mod in range(min_atk, max_atk + 1): if category == "PHYSICAL": atk_pkmn.boost[1] = atk_mod else: atk_pkmn.boost[3] = atk_mod if crit and atk_mod < 0: continue for screen in screens: if screen == "LIGHT SCREEN" and (category == "PHYSICAL" or crit or move.name == "BRICK BREAK"): continue elif screen == "REFLECT" and (category == "SPECIAL" or crit or move.name == "BRICK BREAK"): continue for weather in weathers: if weather in ("SUNNY DAY", "RAIN DANCE") and type not in ("WATER", "FIRE"): continue elif weather == "SANDSTORM" and (category == "PHYSICAL" or type != "ROCK"): continue elif weather == "HAIL" and move.name != "SOLARBEAM": continue for damage_range in damage5.damage5(atk_pkmn, def_pkmn, move, battle_type, screen, crit, weather): if damage_range != [0]: dmg = "-".join([str(value) for value in damage_range]) min_turns = ceil(def_pkmn.hp / max(damage_range)) max_turns = ceil(def_pkmn.hp / min(damage_range)) i.write("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}\n"\ .format(battle_num, def_pkmn.species.name, move.name, def_mod, atk_mod, dmg, def_pkmn.hp, min_turns, max_turns, crit, True if hp == 1 else False, atk_pkmn.item, screen, weather, "-".join([str(x) for x in atk_pkmn.ev]), "-".join([str(x) for x in atk_pkmn.stat]), "-".join([str(x) for x in def_pkmn.stat]), atk_pkmn.exp, atk_pkmn.level, atk_pkmn.pokerus)) atk_pkmn.update_exp(formulas.calc_exp(gen, def_pkmn.level, def_pkmn.species.base_exp, trainer, num_poke, atk_pkmn.level, atk_pkmn.item)) atk_pkmn.update_evs(def_pkmn.species.ev_yield) atk_pkmn.update_level()
def command_generatePokemon(self, species, level): return pokemon.Pokemon(species, level)
def atk_damage_range(filename, gen, name, level, nature, ability, hp, atk, Def, spatk, spdef, spd): output_file = "DamageRange_Atk_{}_{}_{}_{}_{}_{}_{}_{}.csv".format(name, nature, hp, atk, Def, spatk, spdef, spd) with open(filename, "r") as f, open(output_file, "w") as i: f.readline() i.write("Battle,Def_Name,Move Used,Def_Modifier,"\ "Atk_Modifier,Damage_Range,HP,Min_Turns,"\ "Max_Turns,Crit,Torrent,Item,Screen,Weather,"\ "EVs,Atk_Stat,Def_Stat,Total_Exp,Level,Pokerus\n") last_battle = "0" atk_pkmn = pokemon.Pokemon(gen, name.upper(), "Male", level, nature, ability, "None", "None", "None", "None", "None", hp, atk, Def, spatk, spdef, spd) for lines in f: info = lines.strip().split(",") #Stores file information into variables battle_num = info[0] battle_type = info[1].split("\\")[0] location = info[3] #Reset the weather, screen and stat modifiers for a new battle if last_battle != battle_num: last_battle = battle_num weathers = [info[2]] screens = ["None"] min_mod_atk = 0 max_mod_atk = int(info[32]) min_mod_spatk = 0 max_mod_spatk = int(info[33]) min_mod_def = 0 max_mod_def = 0 min_mod_spdef = 0 max_mod_spdef = 0 min_def = 0 max_def = 0 max_atk = 0 min_atk = 0 poke_num = 0 trainer = True #Change the pokemon specie if it evolved or was switched if atk_pkmn.species.name != info[26].upper(): if atk_pkmn.species.dex_num + 1 == speciedex.all.dex[gen][info[26].upper()].dex_num: atk_pkmn.species = speciedex.all.dex[int(gen)][info[26].upper()] atk_pkmn.update_stats() else: atk_pkmn = pokemon.Pokemon(gen, info[26].upper(), "Male", 40, "Rash", "Pressure", "None", "None", "None", "None", "None", 19, 24, 29, 26, 22, 27) #Use Rare Candy if info[34] != "0": for x in range(int(info[34])): atk_pkmn.rare_candy() if info[37] == "TRUE": atk_pkmn.pokerus = True else: atk_pkmn.pokerus = False #Stores file information into variables def_specie = info[4].upper() def_gender = info[5] def_level = int(info[6]) def_nature = info[7] def_ability = info[8] def_item = info[9] def_move1 = info[10] def_move2 = info[11] def_move3 = info[12] def_move4 = info[13] def_hp_iv = int(info[14]) def_atk_iv = int(info[15]) def_def_iv = int(info[16]) def_spatk_iv = int(info[17]) def_spdef_iv = int(info[18]) def_spd_iv = int(info[19]) def_hp_ev = int(info[20]) def_atk_ev = int(info[21]) def_def_ev = int(info[22]) def_spatk_ev = int(info[23]) def_spdef_ev = int(info[24]) def_spd_ev = int(info[25]) atk_pkmn.moves = [movedex.all.dex[gen][x] for x in [info[28], info[29], info[30], info[31]] if x != "None"] atk_pkmn.update_item(info[27]) #Creates defending pokemon def_pkmn = pokemon.Pokemon(gen, def_specie, def_gender, def_level, def_nature, def_ability, def_item, def_move1, def_move2, def_move3, def_move4, def_hp_iv, def_atk_iv, def_def_iv, def_spatk_iv, def_spdef_iv, def_spd_iv) #Updates weather and screen based on defending moves weathers = list(set(weathers + update_weather(def_pkmn) + update_weather(atk_pkmn))) screens = list(set(screens + update_screen(def_pkmn))) #Checks if the attacking pokemon has an hp boosting ability for the loop if atk_pkmn.ability in {"Blaze", "Torrent", "Overgrow", "Swarm"}: hp = (atk_pkmn.stat[0], 1) hp_boost = True else: hp = (1,) hp_boost = False #Updates item and stat modifiers variables for the loop if atk_pkmn.item == "None": items = ("None",) else: items = ("None", atk_pkmn.item) if int(info[32]) > max_mod_atk: max_mod_atk += int(info[32]) if int(info[33]) > max_mod_spatk: max_mod_spatk += int(info[33]) if check_mod_def(def_pkmn, True): max_mod_def = 6 else: max_mod_def = 0 if check_mod_def(atk_pkmn, False): min_mod_def = -6 else: min_mod_def = 0 if check_mod_spdef(def_pkmn, True): max_mod_spdef = 6 else: max_mod_spdef = 0 if check_mod_atk(def_pkmn, False) and min_mod_atk != -6: min_mod_atk = -6 if check_mod_spatk(def_pkmn, False) and min_mod_spatk != -6: min_mod_spatk = -6 #Loop to calculate damage ranges for move in atk_pkmn.moves: if move.category == "Status": continue elif move.category == "Special": max_atk = max_mod_spatk min_atk = min_mod_spatk max_def = max_mod_spdef min_def = min_mod_spdef elif move.category == "Physical": max_atk = max_mod_atk min_atk = min_mod_atk max_def = max_mod_def min_def = min_mod_def for crit in (False, True): for hp_value in hp: if hp_boost: atk_pkmn.hp = hp_value torrent = True if atk_pkmn.calc_hp_ratio() <= 33 else False if torrent and atk_pkmn.ability == "Blaze" and move.type.name != "FIRE": continue elif torrent and atk_pkmn.ability == "Torrent" and move.type.name != "WATER": continue elif torrent and atk_pkmn.ability == "Overgrow" and move.type.name != "GRASS": continue elif torrent and atk_pkmn.ability == "Swarm" and move.type.name != "BUG": continue else: torrent = False for item in items: atk_pkmn.item = item if item == "Choice Specs" and move.category != "Special": continue elif item == "Fist Plate" and move.type.name != "FIGHTING": continue for def_mod in range(min_def, max_def + 1): if crit and def_mod > 0: continue for atk_mod in range(min_atk, max_atk + 1): if crit and atk_mod < 0: continue for screen in screens: if screen == "Light Screen" and move.category == "Physical": continue elif screen == "Reflect" and move.category == "Special": continue for weather in weathers: if weather == "Sunny Day" and move.type.name not in {"WATER", "FIRE"} and weather != "Normal" and len(weathers) > 1: continue elif weather == "Rain Dance" and move.type.name not in {"WATER", "FIRE"} and weather != "Normal" and len(weathers) > 1: continue elif weather == "Hail" and move.name != "SolarBeam": continue elif weather == "Sandstorm" and move.category == "Physical" and move.name != "SolarBeam": continue elif weather == "Sandstorm" and "ROCK" not in [x.name for x in def_pkmn.species.types] and weather != "Normal" and len(weathers) > 1: continue for damage_range in formulas.calc_damage(atk_pkmn, def_pkmn, move, atk_mod, def_mod, crit, weather, screen, battle_type, location): if max(damage_range) != 0: dmg = "-".join([str(value) for value in damage_range]) min_turns = ceil(def_pkmn.hp / max(damage_range)) max_turns = ceil(def_pkmn.hp / min(damage_range)) i.write("{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}\n"\ .format(battle_num, def_specie, move.name, def_mod, atk_mod, dmg, def_pkmn.hp, min_turns, max_turns, crit, torrent, item, screen, weather,"-".join([str(x) for x in atk_pkmn.ev]), "-".join([str(x) for x in atk_pkmn.stat]), "-".join([str(x) for x in def_pkmn.stat]), atk_pkmn.exp, atk_pkmn.level, atk_pkmn.pokerus)) if battle_type == "Single": poke_num = 1 trainer = True elif battle_type == "Double": poke_num = int(info[1].split("\\")[1]) trainer = True else: poke_num = 1 trainer = False atk_pkmn.update_exp(formulas.calc_exp(gen, def_level, def_pkmn.species.base_exp, trainer, poke_num)) atk_pkmn.update_evs(def_pkmn.species.ev_yield) atk_pkmn.update_level()
## execute everything import pokemon import pygame import pytmx _INITIAL_BACKGROUD_WIDTH = 300 _INITIAL_BACKGROUD_HEIGHT = 300 if __name__ == '__main__': pygame.init() pygame.display.set_caption('Pokemon') WINDOW = pygame.display.set_mode( (_INITIAL_BACKGROUD_WIDTH, _INITIAL_BACKGROUD_HEIGHT), pygame.RESIZABLE) ## the game pokemon.Pokemon(WINDOW).run()
def add_pokemon(self, names): for name in names: self.poke_names.append(name) self.pokemon.update({name: api.get_pokemon_data(name)}) self.battle_team.append(pokemon.Pokemon(name))
#!/usr/bin/env python3.5 import pokemon import random import os import time # safari style catching pokemon pokeball_count_ = 5 pokemon_roster = { "Bulbasaur": pokemon.Pokemon("Bulbasaur", 50), "Charmander": pokemon.Pokemon("Charmander", 50), "Squirtle": pokemon.Pokemon("Squirtle", 50), "Articuno": pokemon.Pokemon("Articuno", 150), "Zapdos": pokemon.Pokemon("Zapdos", 150), "Moltres": pokemon.Pokemon("Moltres", 150), "Mewtwo": pokemon.Pokemon("Mewtwo", 250) } pokemon_appeared_ = pokemon_roster[random.choice(list(pokemon_roster.keys()))] pokemon_trainer_ = pokemon.Trainer(pokeball_count_) print("Wild {} appeared!".format(pokemon_appeared_.name.upper())) menu_option_ = "" switch_case = { 'c': pokemon_trainer_.attempt_capture, 't': pokemon_trainer_.throw_rock, 'b': pokemon_trainer_.throw_bait
def team(team_base_data): team = [] for poke in team_base_data: team.append(pokemon.Pokemon(poke['name'], poke['level'])) return team
def create_pokemons(self, choosen_pokemons): print(choosen_pokemons) return [pokemon.Pokemon(name=name) for name in choosen_pokemons]
def tick(self): if self.waiting: #if waiting if self.waitingFor is not None: #if we're waiting for an object if not self.waitingFor.busy: #if what we're waiting for is no longer busy self.waiting = False #stop waiting self.waitingFor = None #no longer waiting for anything else: #else self.countdown -= 1 #decrease the countdown if self.countdown <= 0: #if we've finished counting down self.waiting = False #stop waiting while (not self.waiting and self.running ): #while we're not waiting and still have commands to process cmd = self.script.commands[ self.currentCommand] #get the current command if cmd[0] == CMD_LOCK: #if it's LOCK print "LOCK" self.game.player.lock() #lock the player if self.caller.__class__.__name__ == "NPC": #if the script has a caller self.caller.lock() #lock it elif cmd[0] == CMD_UNLOCK: #if it's UNLOCK print "UNLOCK" self.game.player.unlock() #unlock the player if self.caller.__class__.__name__ == "NPC": #if the script has a caller self.caller.unlock() #unlock it elif cmd[0] == CMD_FACEPLAYER: #if it's FACEPLAYER print "FACEPLAYER" difference = self.game.player.position[ 0] - self.caller.position[0], self.game.player.position[ 1] - self.caller.position[ 1] #calculate offset between player and caller if difference == (0, -1): #if player is above caller self.caller.direction = sprite.DIR_UP #face UP elif difference == (0, 1): #if player is below caller self.caller.direction = sprite.DIR_DOWN #face DOWN elif difference == (-1, 0): #if player is to left of caller self.caller.direction = sprite.DIR_LEFT #face LEFT elif difference == (1, 0): #if player is to right of caller self.caller.direction = sprite.DIR_RIGHT #face RIGHT elif cmd[0] == CMD_WAIT: #if it's WAIT print "WAIT" self.waiting = True #we're waiting self.waitingFor = None #not waiting for an object self.countdown = cmd[1] #set countdown as needed elif cmd[0] == CMD_MOVEME: #if it's MOVEME print "MOVEME" self.caller.walkUp(cmd[1], True) #walk, force move self.waiting = True #we're waiting self.waitingFor = self.caller #waiting for caller elif cmd[0] == CMD_DIALOG: #if it's DIALOG print "DIALOG" text = map(self.resolveString, cmd[1]) #resolve the text strings for variables d = dialog.Dialog(text, self.font, self.game.screen, cmd[2]) #create the dialog self.game.foregroundObject = d #set it as the game's active object self.waiting = True #we're waiting self.waitingFor = d #waiting for the dialog elif cmd[0] == CMD_SETVAR: print "SETVAR" if cmd[1][0] == "$": self.variables[cmd[1][1:-1]] = cmd[2] elif cmd[1][0] == "*": self.game.savegame.variables[cmd[1][1:-1]] = cmd[2] elif cmd[0] == CMD_GETVAR: print "GETVAR" self.result = self.variables[cmd[1]] elif cmd[0] == CMD_COMPARE: #if it's COMPARE print "COMPARE" self.result = (self.resolveString( cmd[1]) == self.resolveString(cmd[2]) ) #store whether the two are equal elif cmd[0] == CMD_GOTO: #if it's GOTO print "GOTO" self.currentCommand = cmd[ 1] - 1 #go to the line before the one required, which will then be advanced to the correct line elif cmd[0] == CMD_IFFALSEGOTO: #if it's IFFALSEGOTO print "IFFALSEGOTO" if not self.result: #if comparison result is False self.currentCommand = cmd[ 1] - 1 #goto to the line before the one required, which will then be advanced to the correct line elif cmd[0] == CMD_MOVEPLAYER: #if it's MOVEPLAYER print "MOVEPLAYER" self.game.player.walk(cmd[1], True) #move the player self.waiting = True #we're waiting self.waitingFor = self.game.player #we're waiting for the player elif cmd[0] == CMD_CHOICEDIALOG: #if it's CHOICEDIALOG print "CHOICEDIALOG" text = map(self.resolveString, cmd[1]) #resolve the text for variables d = dialog.ChoiceDialog(text, self.font, self.game.screen, self, cmd[2]) #create the choice dialog self.game.foregroundObject = d #set it as the game's active object self.waiting = True #we're waiting self.waitingFor = d #waiting for the choice dialog elif cmd[0] == CMD_SHOWSPRITE: #if it's SHOWSPRITE print "SHOWSPRITE" if self.caller is not None: #if there's a caller if self.caller.__class__.__name__ == "Tilemap": #if it was a map self.caller.getSpriteById( cmd[1]).visible = True #set the sprite visible elif self.caller.__class__.__name__ == "NPC": #if it was an NPC self.caller.map.getSpriteById( cmd[1]).visible = True #set the sprite visible else: #else self.game.player.map.getSpriteById( cmd[1]).visible = True #set the sprite visible elif cmd[0] == CMD_HIDESPRITE: #if it's HIDESPRITE print "HIDESPRITE" if self.caller is not None: #if there's a caller if self.caller.__class__.__name__ == "Tilemap": #if it was a map self.caller.getSpriteById( cmd[1]).visible = False #set the sprite invisible elif self.caller.__class__.__name__ == "NPC": #if it was an NPC self.caller.map.getSpriteById( cmd[1]).visible = False #set the sprite invisible else: #else self.game.player.map.getSpriteById( cmd[1]).visible = False #set the sprite invisible elif cmd[0] == CMD_WARP: print "WARP" if False: p = self.game.player del (p.map.sprites["PLAYER"]) p.map = tilemap.Tilemap(cmd[1], self) p.map.loadConnections() p.position = cmd[2] p.destination = cmd[2] p.level = cmd[3] p.map.sprites["PLAYER"] = p sound.playMusic(p.map.music) else: p = self.game.player mMap = tilemap.Tilemap(cmd[1], self) p.transferTo(mMap, cmd[2]) p.destination = p.getPositionInFront() p.level = cmd[3] elif cmd[0] == CMD_FADEOUTANDIN: print "FADEOUTANDIN" self.game.foregroundObject = foreground_object.FadeOutAndIn( self.game.screen, cmd[1]) elif cmd[0] == CMD_GIVEPOKEMON: print "GIVEPOKEMON" poke = pokemon.Pokemon(cmd[1], cmd[2]) self.game.player.party.add(poke) elif cmd[0] == CMD_SURF: print "SURF" self.game.player.surf() self.currentCommand += 1 #advance to next command if self.currentCommand >= len( self.script.commands ): #if we've reached the end of the script if len(self.queue) == 0: self.running = False #no longer running else: print "Script from queue" s, caller = self.queue.pop() self.running = True #running a script self.script = s #store the script self.caller = caller #store the caller of the script self.currentCommand = 0 #reset command counter to start self.waiting = False #not yet waiting self.waitingFor = None #not waiting for anything break #stop processing