async def getAbility(ability): abi = "" if isinstance(ability, str): abi = pb.ability(GG.cleanWordSpace(ability)) if isinstance(ability, int): abi = pb.ability(ability) em = discord.Embed() em.set_author(name=GG.getNames(abi.names)) em.description = GG.getFlavorText(abi.flavor_text_entries) for x in abi.effect_entries: shortEffect = x.short_effect longEffect = x.effect if shortEffect == longEffect: em.add_field(name="Effect", value=shortEffect) else: em.add_field(name="Short Effect", value=shortEffect) em.add_field(name="Long Effect", value=longEffect) POKEMON = "" for x in abi.pokemon: if x.is_hidden: POKEMON += (f"{x.pokemon.name.capitalize()} (★)\n") else: POKEMON += (f"{x.pokemon.name.capitalize()}\n") POKEMON += "\n(★) Indicates a Pokémon's Hidden Ability" em.add_field(name="Pokémon that have this ability", value=POKEMON) return em
def _extract_ability(self, message): name = _extract_name(message, self.ability_names) if not name: return None try: return ability(name) except ValueError: LOG.error("Couldn't find ability with name: '" + str(name)) raise
def _do_action(self, phrase, data): data_type = data[0] # a string data_name = data[1] # The resource or None if data_type == "pokemon": mon = self._check_pokemon( pokemon(data_name) if data_name else None) if not mon: return if self.voc_match(phrase, "Evolve"): if self.voc_match(phrase, "Final"): self.do_pokemon_evolve_final(mon) elif self.voc_match(phrase, "First"): self.do_pokemon_evolve_first(mon) elif self.voc_match(phrase, "From"): self.do_pokemon_evolve_previous(mon) else: self.do_pokemon_evolve_into(mon) elif self.voc_match(phrase, "Ability"): self.do_pokemon_abilities(mon) elif self.voc_match(phrase, "Introduced"): self.do_pokemon_version_introduced(mon) elif self.voc_match(phrase, "Effective") and self.voc_match( phrase, "Against"): self.do_type_effectiveness(mon, phrase) elif self.voc_match(phrase, "Weight"): self.do_pokemon_weight(mon, phrase) elif self.voc_match(phrase, "Height"): self.do_pokemon_height(mon, phrase) elif self.voc_match(phrase, "Type"): self.do_pokemon_type(mon) elif self.voc_match(phrase, "Form"): self.do_pokemon_form(mon) elif self.voc_match(phrase, "ID"): self.speak_dialog("pokemon.id.is", { "pokemon": self._pokemon_name(mon), "id": str(mon.species.id) }) elif self.voc_match(phrase, "Number"): self.speak_dialog( "pokemon.number.is", { "pokemon": self._pokemon_name(mon), "number": str(mon.species.id) }) elif self.voc_match(phrase, "Speed"): self.do_pokemon_base(mon, "speed") elif self.voc_match(phrase, "HP"): self.do_pokemon_base(mon, "hp") elif self.voc_match(phrase, "Color"): self.do_pokemon_color(mon) elif self.voc_match(phrase, "Shape"): self.do_pokemon_shape(mon) elif self.voc_match(phrase, "Habitat"): self.do_pokemon_habitat(mon) elif self.voc_match(phrase, "Happiness"): self.do_pokemon_base_happiness(mon) elif self.voc_match(phrase, "Experience"): self.do_pokemon_base_experience(mon) elif self.voc_match(phrase, "Egg"): self.do_pokemon_egg_groups(mon) elif self.voc_match(phrase, "CaptureRate"): self.do_pokemon_capture_rate(mon) else: attack = self.voc_match(phrase, "Attack") defense = self.voc_match(phrase, "Defense") special = self.voc_match(phrase, "Special") if attack or defense or special: if special: if defense: self.do_pokemon_base(mon, "special-defense") else: self.do_pokemon_base(mon, "special-attack") else: if attack: self.do_pokemon_base(mon, "attack") else: assert defense self.do_pokemon_base(mon, "defense") else: self.speak_dialog("cannot.answer.about.pokemon") elif data_type == "ability": if data_name: abil = ability(data_name) if self.voc_match(phrase, "AbilityFlavorText"): self.do_ability_flavor_text(abil, phrase) elif self.voc_match(phrase, "Introduced"): self.do_ability_generation_introduced(abil) elif self.voc_match(phrase, "AbilityEffectEntry"): self.do_ability_effect_entry(abil, short=False) else: self.do_ability_effect_entry(abil, short=True) else: self.speak_dialog("cannot.answer.about.ability")
async def get_poke_data(self, ctx, poke_ser, load_msg): pr = ProgressBar(8) pv = PokemonValues() print('pokemon_id: ' + str(poke_ser)) pic_list = [ 'https://thumbs.gfycat.com/FairSinfulCottontail-small.gif', 'https://media.giphy.com/media/3M8bGcZOexuvneoJZl/giphy.gif', 'https://cdn.dribbble.com/users/621155/screenshots/2835329/coorzzz.gif', 'https://a.top4top.io/p_1990j031.gif', 'https://i.pinimg.com/originals/72/00/28/720028e1fce6412e77667993ead54ede.gif', 'https://i.pinimg.com/originals/51/72/56/517256bf41fd027b5eec4a38c5110420.gif', 'https://media2.giphy.com/media/uXnif9JVu6VnW/source.gif' ] tmp = await ctx.send(load_msg) load_pic = discord.Embed(title='', description='', color=random.randint(0, 0xffffff)) load_pic.set_image(url=random.choice(pic_list)) load_pic_msg = await ctx.send(embed=load_pic) try: await self.send_progress(tmp, load_msg, pr) sp_data = pb.pokemon_species(poke_ser) await self.send_progress(tmp, load_msg, pr) p_data = pb.pokemon(poke_ser) await self.send_progress(tmp, load_msg, pr) pv.weight = float(p_data.weight) / 10 pv.height = float(p_data.height) / 10 pv.id = sp_data.id pv.name_en = sp_data.name pv.set_gender(sp_data.gender_rate) evo_chain_id = int(sp_data.evolution_chain.url.split('/')[6]) type_names = [] for t in p_data.types: type_names.append(t.type.name) pv.set_type(type_names) await self.send_progress(tmp, load_msg, pr) for s in p_data.stats: pv.seed_dict[s.stat.name] = s.base_stat await self.send_progress(tmp, load_msg, pr) for data in sp_data.flavor_text_entries: if data.language.name.find('ja') != -1: pv.flavor = data.flavor_text break await self.send_progress(tmp, load_msg, pr) for data in sp_data.names: if data.language.name.find('ja') != -1: pv.name = data.name break await self.send_progress(tmp, load_msg, pr) for data in sp_data.genera: if data.language.name.find('ja') != -1: pv.genus = data.genus break await self.send_progress(tmp, load_msg, pr) try: evo = pb.evolution_chain(evo_chain_id) min_lv = evo.chain.evolves_to[0]['evolution_details'][0][ 'min_level'] #print(min_lv) pv.set_level(min_lv) except: #traceback.print_exc() pv.set_level(30) abi_id = random.choice(p_data.abilities).ability.url.split('/')[6] for data in pb.ability(abi_id).names: if data.language.name.find('ja') != -1: pv.ability_name = data.name break pv.calc() await self.send_progress(tmp, load_msg, pr) except ValueError: await ctx.send(ctx.author.mention + ' **ポケモンは見つからなかったぞ!**') self.quiz_flag = False pv = None except: await ctx.send(ctx.author.mention + ' エラーだぞ...: ' + str(traceback.print_exc())) self.quiz_flag = False pv = None await tmp.delete() await load_pic_msg.delete() return pv
def get_ability_info(name): ability = pb.ability(name.lower())
def fightScene(poke1, num): spin_spin() #define variable flags to track character entrance and key presses slideEnemy = True slidePlayer = True poke2 = None keyDown = False poke1hp = 100 poke2hp = 100 enemy_damaged = 0 player_damaged = 0 #track successful attacks after 3 success then special ability becomes available playerAttackSuccess = 0 enemyAttackSuccess = 0 #white screen to open the scene pygame.draw.rect(SCREEN, white, [0, 0, screenWidth, screenHeight]) #roll for who attacks first contestantTurn = random.randrange(1, 3) clock.tick(15) #create fighting loop while True: #enemy entrance left to right if slideEnemy: clock.tick(60) #encounter loop music pygame.mixer.music.load('PokemonTrainerBattle.wav') pygame.mixer.music.play(-1) for x in range(screenWidth - 125): SCREEN.blit(poke1, (x, 100)) time.sleep(.003) pygame.draw.rect(SCREEN, white, [x - 25, 100, 20, 200]) pygame.display.update() SCREEN.fill(white) SCREEN.blit(poke1, (x, 100)) #SCREEN.fill(white) #give user a chance to select their available pokemon while (not keyDown): clock.tick(15) #wipe any previous messages in center of screen pygame.draw.rect(SCREEN, white, [0, screenHeight / 2 - 50, screenWidth, 65]) message_display( 'Select Your Pokemon[1- ' + str(len(pokemon_Id)) + ']', screenWidth / 2, screenHeight / 2, 25) for event in pygame.event.get(): #check for keys pressed down if event.type == pygame.KEYDOWN: if event.type == pygame.QUIT: pygame.quit() quit() #check for the number key pressed and if there are enough pokemon in the players pokedex elif event.key == pygame.K_1: playerSelection = 0 elif event.key == pygame.K_2 and len(pokemon_Id) > 1: playerSelection = 1 elif event.key == pygame.K_3 and len(pokemon_Id) > 2: playerSelection = 2 elif event.key == pygame.K_4 and len(pokemon_Id) > 3: playerSelection = 3 elif event.key == pygame.K_5 and len(pokemon_Id) > 4: playerSelection = 4 elif event.key == pygame.K_6 and len(pokemon_Id) > 5: playerSelection = 5 else: #wipe previous messages, then print new message pygame.draw.rect( SCREEN, white, [0, screenHeight / 2 - 50, screenWidth, 65]) message_display('Invalid selection', screenWidth / 2, screenHeight / 2, 25) playerSelection = 0 continue #user has made their selection keyDown = True slideEnemy = False #player pokemon has not yet been selected if (poke2 == None): poke2, pokename2 = _createPokemon_(pokemon_Id[playerSelection]) pokename = str(pokename2) #enter player pokemon (right to left) if slidePlayer: clock.tick(60) for x in range(screenWidth - 200): SCREEN.blit(flipImage(poke2), ((screenWidth - x) - 100, 375)) time.sleep(.003) pygame.draw.rect( SCREEN, white, [(screenWidth + 100) - x, 375, screenWidth, 200]) pygame.display.update() #fill screen and draw new image at final position SCREEN.fill(white) SCREEN.blit(flipImage(poke2), (screenWidth - x - 100, 375)) slidePlayer = False #draw the contestants final positions within the fight scene SCREEN.blit(poke1, (x, 100)) SCREEN.blit(flipImage(poke2), (screenWidth - x - 100, 375)) #get enemy pokemon name enemyName = str(pb.pokemon(num)) print(enemyName) #draw stat boxes, names message_display(enemyName, 150, 75, 25) message_display(pokename, screenWidth - 125, screenHeight - 145, 25) #attack game mechanics while (battleWinner(pokename, enemyName, poke1hp, poke2hp, enemy_damaged, player_damaged)): #reset damage taken damageTakenEnemy = 0 damageTakenplayer = 0 clock.tick(15) print(poke1hp) print(poke2hp) #healthbar full (enemy) pygame.draw.rect(SCREEN, green, (100, 90, 100, 10)) #indicate damage to enemy pygame.draw.rect(SCREEN, white, [100, 90, enemy_damaged, 10]) #healthbar full (player) pygame.draw.rect( SCREEN, green, (3 * screenWidth / 4 - 25, 3 * screenHeight / 4 - 10, 100, 10)) #indicate damage to player pygame.draw.rect(SCREEN, white, [ 3 * screenWidth / 4 - 25, 3 * screenHeight / 4 - 10, player_damaged, 10 ]) ############### #player if contestantTurn == 1: #check key event for end scene (debug) for event in pygame.event.get(): #check for keys pressed down if event.type == pygame.KEYDOWN: #exit scene (debug) if event.type == pygame.QUIT: pygame.quit() sys.exit() #player move if event.key == pygame.K_1: message_display( str(pokename) + ' used ' + str(pb.move(pokemon_Id[playerSelection])), screenWidth / 2, screenHeight / 2, 25) time.sleep(1) pygame.draw.rect( SCREEN, white, [0, screenHeight / 2 - 50, screenWidth, 100]) enemy_damaged += 10 damageTakenEnemy = 10 playerAttackSuccess += 1 contestantTurn = 2 #special ability if event.key == pygame.K_2: if playerAttackSuccess == 3: message_display( str(pb.ability( pokemon_Id[playerSelection])), screenWidth / 2, screenHeight / 2, 25) time.sleep(1) pygame.draw.rect(SCREEN, white, [ 0, screenHeight / 2 - 50, screenWidth, 100 ]) enemy_damaged += 20 damageTakenEnemy = 20 contestantTurn = 2 #reset attack success playerAttackSuccess = 0 else: message_display('cannot use special', screenWidth / 2, screenHeight / 2, 25) time.sleep(1) pygame.draw.rect(SCREEN, white, [ 0, screenHeight / 2 - 50, screenWidth, 100 ]) continue #shake enemy player simulate an attack shift = 0 for x in range(100): clock.tick(30) if shift == 0: pygame.draw.rect( SCREEN, white, [screenWidth - 200, 100, 150, 100]) SCREEN.blit(poke1, (screenWidth - 200 - 5, 100)) time.sleep(.003) shift = 5 pygame.display.update() else: pygame.draw.rect( SCREEN, white, [screenWidth - 200 + shift, 100, 150, 100]) SCREEN.blit(poke1, (screenWidth - 200 + shift, 100)) time.sleep(.003) shift = 0 pygame.display.update() pygame.draw.rect( SCREEN, white, [screenWidth - 200 - 5, 100, 120, 100]) pygame.display.update() SCREEN.blit(poke1, (screenWidth - 200, 100)) poke1hp -= damageTakenEnemy #computer AI else: events() if enemyAttackSuccess == 3: message_display(str(pb.ability(num)), screenWidth / 2, screenHeight / 2, 25) time.sleep(1) pygame.draw.rect( SCREEN, white, [0, screenHeight / 2 - 50, screenWidth, 100]) player_damaged += 20 damageTakenplayer = 20 contestantTurn = 1 enemyAttackSuccess = 0 else: message_display(str(pb.move(num)), screenWidth / 2, screenHeight / 2, 25) time.sleep(1) pygame.draw.rect( SCREEN, white, [0, screenHeight / 2 - 50, screenWidth, 100]) player_damaged += 10 damageTakenplayer = 10 contestantTurn = 1 enemyAttackSuccess += 1 #shake enemy player simulate an attack shift = 0 for x in range(100): clock.tick(30) if shift == 0: pygame.draw.rect(SCREEN, white, [ screenWidth - (screenWidth - 100) - 5, 375, 150, 100 ]) SCREEN.blit(flipImage(poke2), (screenWidth - (screenWidth - 100) - 5, 375)) time.sleep(.003) shift = 5 pygame.display.update() else: pygame.draw.rect(SCREEN, white, [ screenWidth - (screenWidth - 100) + shift, 375, 150, 100 ]) SCREEN.blit(flipImage(poke2), (screenWidth - (screenWidth - 100) + shift, 375)) time.sleep(.003) shift = 0 pygame.display.update() poke2hp -= damageTakenplayer pygame.draw.rect( SCREEN, white, [screenWidth - (screenWidth - 100), 375, 150, 100]) pygame.display.update() SCREEN.blit(flipImage(poke2), (screenWidth - (screenWidth - 100), 375)) #healthbar when hit pygame.display.update() #check key event for end scene (debug) #for event in pygame.event.get(): #check for keys pressed down #if event.type == pygame.KEYDOWN: #exit scene (debug) #if event.key == pygame.K_LEFT: #pygame.mixer.music.stop() #return #need healthbar, attack messaging, attack animations here, could write in while loop until a player dies or is captured pygame.display.update()