Пример #1
0
def getPokemonData(pokemon_id):
 truncateTables()
 for n in range(1,pokemon_id+1):
  p1=pokebase.pokemon(n)
  pokemon=(p1.id,p1.name,p1.weight)
  conn=getConn()
  lstRowid=pokemon_insert(conn,pokemon)
 
  for i in range(0,len(p1.moves)):
   try:
    move=p1.moves[i].move.name
    accuracy=pokebase.move(move).accuracy
    if (accuracy==None):
     accuracy=0
    type=pokebase.move(move).type.name
    print("pokemon name:"+p1.name)
    print("pokemon id:"+str(p1.id))
    print("move name :"+move)
    print("move id:"+str(p1.moves[i].move.id))
    print ("type="+type)
    pokemon_move=(move,p1.id,p1.moves[i].move.id,accuracy,pokebase.move(move).type.id)
    conn=getConn()
    lstRowid=pokemonMove_insert(conn,pokemon_move)
   except:
    continue 
  
 
  
  for i in range(0,len(p1.types)):
   print("pokemon type:"+p1.types[i].type.name)
   pokemon_type=(p1.types[i].type.name,p1.id,p1.types[i].type.id)
   conn=getConn()
   lstRowid=pokemonType_insert(conn,pokemon_type)
   print("pokemon weight:"+str(p1.weight))
Пример #2
0
 def __init__(self, name):
     self.name = name.replace('-', ' ').lower().capitalize()
     self.move: list
     self.move = []
     try:
         with open('assets/Pokemon/JSON/move/' + str(self.name) + '.json', mode='rb') as f:
             try:
                 self.move = json.load(f)
             except Exception as e:
                 print(e)
             pass
     except IOError:
         move = pb.move(self.name.replace(' ', '-').lower()).data()
         with open('assets/Pokemon/JSON/move/' + str(self.name) + '.json', 'a') as f:
             f.write('[')
             json.dump(move, f)
             f.write(']')
         with open('assets/Pokemon/JSON/move/' + str(self.name) + '.json', mode='rb') as f:
             try:
                 self.move = json.load(f)
             except Exception as e:
                 print(e)
             pass
     self.type = self.move[0]['type']['name'].capitalize()
     self.max_pp = self.move[0]['pp']
     self.current_pp = self.max_pp
     self.power = self.move[0]['power']
     self.category = self.move[0]['meta']['category']['name']
     self.move_class = self.move[0]['damage_class']['name']
Пример #3
0
def get_move_info(name):
	if not name:
		return None
	move = pb.move(name.lower())
	stat_dict = {
		"power": move.power,
		"accuracy": move.accuracy,
		"pp": move.pp,
		"max_pp": int(move.pp * 8.0 / 5.0),
		"priority": move.priority,
		"dmg_type": str(move.damage_class.name),
		"stat_changes": move.stat_changes,
		"type": str(move.type.name),
		"meta": move.meta
		#{
		# 	"ailment": move.meta['ailment']['name'],
		# 	"ailment_chance": move.meta['ailment_chance'],
		# 	#min/max hits is none of only hits once
		# 	"min_hits": move.meta['min_hits'],
		# 	"max_hits": move.meta['max_hits'],
		# 	#min/max turns effect lasts is null if one turn
		# 	"min_turns": move.meta['min_turns'],
		# 	"max_turns": move.meta['max_turns'],
		# 	#% of hp drain(positive) or recoil(negative)
		# 	"drain": move.meta['drain'],
		# 	#% of healing gained by % of max hp
		# 	"healing": move.meta['healing'],
		# 	"crit_rate": move.meta['crit_rate'],
		# 	"flinch_chance": move.meta['flinch_chance'],
		# 	"stat_chance": move.meta['stat_chance']
		# }
	}
	return stat_dict
Пример #4
0
    def getMoveData(self):

        """ Convert the string input to move data using the pokebase api """

        for i in range(len(self.moves)):
            name = self.moves[i].replace(" ", "-")
            self.moveData[i] = pb.move(name)
            self.pp[i] = self.moveData[i].pp
 def __init__(self, moveName):
     cleanName = moveName.lower().replace(" ", "-")
     if cleanName == "":
         self.name = ""
         self.type = "normal"
         self.power = 0
         self.accuracy = 0
     else:
         moveData = None
         try:
             moveData = pb.move(cleanName)
         except:
             moveData = pb.move("struggle")
         self.name = moveData.names[2].name.strip()
         self.type = moveData.type.name
         self.power = moveData.power
         self.accuracy = moveData.accuracy
Пример #6
0
async def getMove(move):
    move = GG.cleanWordSpace(move)
    mv = pb.move(move)
    em = discord.Embed()

    em.set_author(name=GG.cleanWordDash(mv.name))
    em.description = GG.getEffectText(mv.effect_entries).replace(
        "$effect_chance", str(mv.effect_chance))
    color = GG.getColorOfType(mv.type.name)
    em.colour = int("0x" + color, 0)

    em.add_field(name="Type", value=GG.cleanWordDash(mv.type.name))
    em.add_field(name="Move Class",
                 value=GG.cleanWordDash(mv.damage_class.name))
    em.add_field(name="Power", value=str(mv.power))
    if mv.accuracy is None:
        em.add_field(name="Accuracy", value=str(mv.accuracy))
    else:
        em.add_field(name="Accuracy", value=str(mv.accuracy) + "%")
    em.add_field(name="PP", value=str(mv.pp))
    if mv.priority > 1:
        em.add_field(name=f"Priority", value=f"+{mv.priority}")
    elif mv.priority < 0:
        em.add_field(name=f"Priority", value=f"{mv.priority}")
    else:
        em.add_field(name="Priority", value="Normal")

    if mv.meta.crit_rate > 0:
        em.add_field(name="Crit Rate", value=f"{mv.meta.crit_rate}%")
    if mv.meta.drain > 0:
        em.add_field(name="Drain", value=f"{mv.meta.drain}%")
    if mv.meta.flinch_chance > 0:
        em.add_field(name="Flinch Chance", value=f"{mv.meta.flinch_chance}%")
    if mv.meta.healing > 0:
        em.add_field(name="Healing", value=f"{mv.meta.healing}%")
    if mv.meta.max_hits is not None:
        em.add_field(name="Number of Hits",
                     value=f"{mv.meta.min_hits}-{mv.meta.max_hits}")
    if mv.meta.max_turns is not None:
        em.add_field(name="Number of Turns",
                     value=f"{mv.meta.min_turns}-{mv.meta.max_turns}")

    if GG.cleanWordDash(mv.meta.ailment.name) != "None":
        em.add_field(name="Ailment",
                     value=GG.cleanWordDash(mv.meta.ailment.name))
        if mv.damage_class.name == "status":
            em.add_field(name="Ailment Chance", value=f"100%")
        else:
            em.add_field(name="Ailment Chance",
                         value=f"{str(mv.meta.ailment_chance)}%")

    target = pb.move_target(mv.target.name)
    em.add_field(name="Targets",
                 value=GG.getDescriptionText(target.descriptions),
                 inline=False)

    return em
 def pokemonMovePower(move, pokemonAtk, pokemonDef):
     if (move == None):
         return 0
     elif (pb.move(move).damage_class.id == pb.move_damage_class(1).id):
         return 0
     else:
         # Set the base power
         moveBasePower = pb.move(move).power
         # If the move has variable power its base power is None
         if (moveBasePower == None):
             return 0
         #Get Move Type
         moveType = pb.move(move).type
         # Apply STAB
         pokemonAtkTypes = pb.pokemon(pokemonAtk.formID).types
         for j in range(0, len(pokemonAtkTypes)):
             if (moveType.id == pokemonAtkTypes[j].type.id):
                 moveBasePower *= 1.5
         # Check for Weakness/Resistance against each type
         pokemonDefTypes = pb.pokemon(pokemonDef.formID).types
         for j in range(0, len(pokemonDefTypes)):
             #Check Move effectivness against the opponent type
             #No Effect
             noDamageTo = moveType.damage_relations.no_damage_to
             for k in range(0, len(noDamageTo)):
                 if (noDamageTo[k]['name'] == pokemonDefTypes[j].type.name):
                     moveBasePower *= 0
             #Half Damage
             halfDamageTo = moveType.damage_relations.half_damage_to
             for k in range(0, len(halfDamageTo)):
                 if (halfDamageTo[k]['name'] == pokemonDefTypes[j].type.name
                     ):
                     moveBasePower *= 0.5
             #Double Damage
             doubleDamageTo = moveType.damage_relations.double_damage_to
             for k in range(0, len(doubleDamageTo)):
                 if (doubleDamageTo[k]['name'] ==
                         pokemonDefTypes[j].type.name):
                     moveBasePower *= 2
         #Return the final base power
         return moveBasePower
Пример #8
0
async def getTM(id):
    em = discord.Embed()
    if isinstance(id,int):
        id = int(id)
    else:
        em.description = "Please use the TM ID, and not the move name."
        return em

    if id < 10:
        em.set_author(name=f"TM0{id}")
    else:
        em.set_author(name=f"TM{id}")

    if id == 1:
        StartID = id
        EndID = StartID + (APICallsPerTMTO50)
    elif id in range(2,50):
        StartID = ((id - 1) * APICallsPerTMTO50) + 1
        EndID = StartID + (APICallsPerTMTO50)
    elif id in range(51, 92):
        StartID = APICallsPerTMTO50TOTAL + (((id - 51) * APICallsPerTMTO92)) + 1
        EndID = StartID + (APICallsPerTMTO92)
    elif id in range(93, 95):
        StartID = APICallsPerTMTO92TOTAL + (((id - 93) * APICallsPerTMTO95)) + 1
        EndID = StartID + (APICallsPerTMTO95)
    elif id in range(95, 100):
        StartID = APICallsPerTMTO95TOTAL + (((id - 95) * APICallsPerTMTO100)) + 1
        EndID = StartID + (APICallsPerTMTO100)
    else:
        em.description("This TM doesn't exist.")
        return em

    COLORS = []
    COLOROUTPUT = ''
    for x in range(StartID, EndID, 1):
        TM = pb.machine(x)
        em.add_field(name=f"{GG.cleanWordDash(TM.move.name)}", value=f"{GG.getGame(TM.version_group.name)}")

        move = pb.move(TM.move.name)
        if GG.getColorOfType(move.type.name) not in COLORS:
            COLORS.append(GG.getColorOfType(move.type.name))
    i = 0
    for x in range(i, len(COLORS), 2):
        i = x + 1
        if i != len(COLORS):
            COLORS.append(color_mixer(COLORS[x], COLORS[(i)]))
            COLOROUTPUT = color_mixer(COLORS[x], COLORS[(i)])
    COLOROUTPUT = COLOROUTPUT.replace("#", "")
    if COLOROUTPUT == "":
        COLOROUTPUT = COLORS[0]
    em.colour = int("0x" + COLOROUTPUT, 0)

    return em
 def showdownFormat(self):
     s = str(pb.pokemon(self.formID)) + " "
     s += self.genderDictionary[self.gender]
     if (self.itemID != None):
         s += "@ " + pb.item(self.itemID).name
     s += "\n"
     s += "Ability: " + self.getAbility().name + "\n"
     s += "Level: " + str(self.level) + "\n"
     if (self.shiny == True):
         s += "Shiny: Yes\n"
     s += "Happiness: " + str(self.happiness) + "\n"
     s += "EVs: "
     s += str(self.evHP) + " HP / "
     s += str(self.evAtk) + " Atk / "
     s += str(self.evDef) + " Def / "
     s += str(self.evSpA) + " SpA / "
     s += str(self.evSpD) + " SpD / "
     s += str(self.evSpe) + " Spe\n"
     s += pb.nature(self.natureID).name.title() + " Nature\n"
     #Title to make nature capitalised so showdown accepts it
     s += "IVs: "
     s += str(self.ivHP) + " HP / "
     s += str(self.ivAtk) + " Atk / "
     s += str(self.ivDef) + " Def / "
     s += str(self.ivSpA) + " SpA / "
     s += str(self.ivSpD) + " SpD / "
     s += str(self.ivSpe) + " Spe\n"
     #MOVES
     if (self.move1 != None):
         s += "- " + pb.move(self.move1).name + "\n"
     if (self.move2 != None):
         s += "- " + pb.move(self.move2).name + "\n"
     if (self.move3 != None):
         s += "- " + pb.move(self.move3).name + "\n"
     if (self.move4 != None):
         s += "- " + pb.move(self.move4).name + "\n"
     return s
Пример #10
0
def pick_moves(moveset, party_pkmn):
    final_moveset = []
    base_exp = party_pkmn.base_experience
    if len(moveset) < 4:
        for m in moveset:
            final_moveset.append(pb.move(m))
        return final_moveset
    else:
        exclusion_list = []
        if base_exp < 100:
            for i in range(4):
                final_moveset.append(pb.move(moveset[i]))
            return final_moveset
        elif 200 > base_exp >= 100:
            for i in range(4):
                rand_choice = random.choice(moveset)
                exclusion_list.append(rand_choice)
                final_moveset.append(pb.move(rand_choice))
                moveset = [i for i in moveset if i not in exclusion_list]
            return final_moveset
        elif base_exp >= 200:
            for i in reversed(range(1, 5)):
                final_moveset.append(pb.move(moveset[-i]))
            return final_moveset
Пример #11
0
    def search(cls, id_or_name):
        move = pb.move(id_or_name)
        damage_class = DamageClass[move.damage_class.name]
        type_ = Type.search(move.type.name)
        generation = Generation[move.generation.name.replace('-', '_')]

        data = {}
        for field in Move.FIELDS:
            if field in move.__dict__:
                if field == 'effect_entries':
                    data[field] = [e.effect for e in move.__dict__[field]]
                else:
                    data[field] = move.__dict__[field]
            elif 'meta' in move.__dict__ and field in move.meta.__dict__:
                data[field] = move.meta.__dict__[field]
        return cls(move.id, move.name, damage_class, type_, generation, **data)
Пример #12
0
def getMoveDeets(move):

    

    stats = {
        'Atk' : 0,
        'Def' : 0,
        'SpA' : 0,
        'SpD' : 0,
        'Spe' : 0
    }
    move = move.lower().replace(' ','-')
    if 'hidden-power' in move:
        move = 'hidden-power'
    # print('\nMOVEDEX REQUEST:' + move)
    move = pb.move(move)

    accuracy = move.accuracy
    if accuracy == None:
        accuracy = 100
    
    power = move.power
    if power == None:
        power = 0
    
    pp = move.pp
    
    stat_changes = move.stat_changes

    if len(stat_changes) > 0:
        for change in stat_changes:
            # print(stat_lookup['attack'])
            stats[stat_lookup[str(change.stat)]] = change.change
    # print(stat_changes)

    move_type = str(move.type)
    
    return accuracy,power,pp,move_type,stats['Atk'],stats['Def'],stats['SpA'],stats['SpD'],stats['Spe']
Пример #13
0
    async def teambuild(self, ctx):
        message1 = await ctx.message.channel.send(embed=discord.Embed(
            description=ctx.message.author.mention +
            ' Which format would you like to team build for? National Dex or VGC? You have one minute to reply before you are timed out.'
        ))

        def formatcheck(msg):
            return msg.channel.id == ctx.message.channel.id and msg.author.id == ctx.message.author.id and (
                str.lower(msg.content) == 'national dex'
                or str.lower(msg.content) == 'vgc')

        def pokepastecheck(msg):
            return msg.channel.id == ctx.message.channel.id and msg.author.id == ctx.message.author.id and "https://pokepast.es/" in str.lower(
                msg.content)

        try:
            format = await self.client.wait_for('message',
                                                timeout=60.0,
                                                check=formatcheck)

            if str.lower(
                    format.content) == 'national dex':  # Nat Dex Team Build
                await format.delete()
                await message1.edit(embed=discord.Embed(
                    description=ctx.message.author.mention +
                    ' You have chosen **National Dex**. Please provide me with a **legal pokepaste link** to a **legal** team. You have one minute. \n **Warning:** Do not nickname any of your Pokemon.'
                ))

            else:  # VGC Team Build
                await format.delete()
                await message1.edit(embed=discord.Embed(
                    description=ctx.message.author.mention +
                    ' You have chosen **VGC**. Please provide me with a **pokepaste link** to a **legal** team. You have one minute. \n **Warning:** Do not nickname any of your Pokemon.'
                ))
                try:
                    pokepaste = await self.client.wait_for(
                        'message', timeout=60.0, check=pokepastecheck)
                    await message1.edit(embed=discord.Embed(
                        description=
                        '<a:8299_Loading:724051710468817048> Give me a moment while I analyze your team.'
                    ))
                    pokepastecontent = pokepaste.content
                    await pokepaste.delete()
                    chrome_options = webdriver.ChromeOptions()
                    chrome_options.add_argument('--headless')
                    chrome_options.add_argument('--no-sandbox')
                    chrome_options.add_argument('--disable-dev-shm-usage')

                    driver = webdriver.Chrome(chrome_options=chrome_options)

                    driver.get(str(pokepastecontent))
                    count = 0
                    set = []
                    items = []
                    abilities = []
                    moves = []
                    evs = []
                    nature = []
                    suggestions = []
                    mons = driver.find_elements_by_tag_name("article")
                    while count < len(mons):
                        mon = mons[count].text
                        mon = mon.split()
                        set.append(mon[0])
                        if len(mon[mon.index('@') +
                                   1:mon.index('Ability:')]) == 2:
                            items.append(' '.join(
                                mon[mon.index('@') + 1:mon.index('Ability:')]))
                        else:
                            items.append(
                                str(mon[mon.index('@') +
                                        1:mon.index('Ability:')]).strip(
                                            "['']"))

                        if len(mon[mon.index('Ability:') +
                                   1:mon.index('EVs:')]) == 2:
                            abilities.append(' '.join(
                                mon[mon.index('Ability:') +
                                    1:mon.index('EVs:')]))
                        else:
                            abilities.append(
                                str(mon[mon.index('Ability:') +
                                        1:mon.index('EVs:')]).strip("['']"))
                        evs.append(' '.join(mon[mon.index('EVs:') +
                                                1:mon.index('Nature') - 1]))
                        nature.append(mon[mon.index('Nature') - 1])

                        moves.append(
                            (' '.join(mon[mon.index('-') + 1:len(mon) +
                                          1])).replace(' - ',
                                                       ', ').split(', '))
                        count += 1

                    # Type checking
                    types = []
                    for i in set:
                        for a in pb.pokemon(str.lower(i)).types:
                            types.append(a.type.name)

                    weakness = {
                        'normal': 0,
                        'fighting': 0,
                        'flying': 0,
                        'poison': 0,
                        'ground': 0,
                        'rock': 0,
                        'bug': 0,
                        'ghost': 0,
                        'steel': 0,
                        'fire': 0,
                        'water': 0,
                        'grass': 0,
                        'electric': 0,
                        'psychic': 0,
                        'ice': 0,
                        'dragon': 0,
                        'dark': 0,
                        'fairy': 0
                    }

                    # See which types are most weak to
                    weaknessTypes = []

                    for i in types:
                        weaknessCheck(weakness, i)
                    for type, value in weakness.items():
                        if value <= -4:
                            suggestions.append('You are ' + str(abs(value)) +
                                               'x weak to ' + type)
                            weaknessTypes.append(type)

                    # See which moves counter the weak types
                    counterMoves = []
                    specialMoves = []
                    physicalMoves = []

                    if len(weaknessTypes) > 0:
                        for i in range(len(moves)):
                            for a in range(len(moves[i])):
                                move = pb.move(
                                    str.lower(moves[i][a]).replace(' ', '-'))
                                for b in weaknessTypes:
                                    if move.power:
                                        for c in move.type.damage_relations.double_damage_to:
                                            if c['name'] == b:
                                                counterMoves.append(
                                                    moves[i][a])
                                        if move.damage_class.name == 'special':
                                            specialMoves.append(moves[i][a])
                                        else:
                                            physicalMoves.append(moves[i][a])

                    suggestions.append(
                        'Moves you have that counter this type are: **' +
                        '**, **'.join(counterMoves))
                    if len(counterMoves) < len(weaknessTypes) * 2:
                        suggestions.append(
                            'I would recommend having more moves that counter the type(s).'
                        )
                    if abs(len(specialMoves) - len(physicalMoves)) > 4:
                        if len(specialMoves) > len(physicalMoves):
                            suggestions.append(
                                'You have ' + str(len(specialMoves)) +
                                ' special moves and ' +
                                str(len(physicalMoves)) +
                                ' physical moves. You should replace ' +
                                str((len(specialMoves) - len(physicalMoves)) /
                                    2) +
                                ' of your special moves with physical moves for balance.'
                            )
                        else:
                            suggestions.append(
                                'You have ' + str(len(specialMoves)) +
                                ' special moves and ' +
                                str(len(physicalMoves)) +
                                ' physical moves. You should replace ' +
                                str((len(physicalMoves) - len(specialMoves)) /
                                    2) +
                                ' of your physical moves with special moves for balance.'
                            )

                    if 'Trick Room' in moves:
                        if moves.count('Trick Room') > 1:
                            suggestions.append(
                                'Only one TR setter is required.')
                        if 'Dusclops' not in set:
                            suggestions.append(
                                'Dusclops is a way better alternative as a TR setter.'
                            )

                    if 'Drought' in abilities:
                        if 'Venusaur' not in set:
                            suggestions.append(
                                'Venusaur is a very strong Pokemon for a sun team.'
                            )

                    if len(suggestions) > 0:
                        await message1.edit(embed=discord.Embed(
                            description='\n'.join(suggestions)))
                    else:
                        await message1.edit(embed=discord.Embed(
                            description=
                            'I saw no changes. Your team is very balanced!'))

                except asyncio.TimeoutError:
                    await message1.edit(embed=discord.Embed(
                        description=ctx.message.author.mention +
                        ' You have been timed out.'))

        except asyncio.TimeoutError:
            await message1.edit(
                embed=discord.Embed(description=ctx.message.author.mention +
                                    ' You have been timed out.'))
Пример #14
0
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()
Пример #15
0
    def _evolution_details_str(self, evolution_details):
        """

        :param evolution_details: Usually a dict
        :return: A string representing events needed to happen to evolve based on evolution_details
        """
        # Use this to test: https://pokemondb.net/pokebase/168028/what-pokemon-have-a-unique-evolution-method
        # ==== variables ====
        trigger = evolution_trigger(evolution_details["trigger"]["name"])
        trigger_name = self._get_name_from_lang(trigger.names)
        if trigger_name:
            trigger_name = " " + self.translate("evolve.details.trigger",
                                                {"name": trigger_name})

        held_item = evolution_details["held_item"]
        held_item_display = ""
        if held_item:
            item_name = held_item["name"]
            item_display_name = self._get_name_from_lang(item(item_name).names)
            held_item_display = " " + self.translate(
                "evolve.details.holding.item", {"item": item_display_name})

        min_level = evolution_details["min_level"]  # None or min level
        min_level_display = ""
        if min_level:
            min_level_display = " " + self.translate("evolve.details.at.level",
                                                     {"level": min_level})

        min_happiness = evolution_details[
            "min_happiness"]  # None or min happiness
        min_happiness_display = ""
        if min_happiness:
            min_happiness_display = " " + self.translate(
                "evolve.details.with.happiness", {"happiness": min_happiness})

        min_beauty = evolution_details["min_beauty"]
        min_beauty_display = ""
        if min_beauty:
            min_beauty_display = " " + self.translate(
                "evolve.details.with.beauty", {"beauty": min_beauty})

        min_affection = evolution_details["min_affection"]
        min_affection_display = ""
        if min_affection:
            min_affection_display = " " + self.translate(
                "evolve.details.with.affection", {"affection": min_affection})

        time_of_day = evolution_details[
            "time_of_day"]  # None or "day" or "night"
        time_display = ""
        if time_of_day:
            time_display = " " + self.translate("evolve.details.time.of.day",
                                                {"time": time_of_day})

        gender = evolution_details["gender"]  # None, 1=female, 2=male
        gender_display = ""
        if gender:
            if gender == 1:
                gender_display = " " + self.translate(
                    "evolve.details.if.female")
            else:
                gender_display = " " + self.translate("evolve.details.if.male")

        party_type_dict = evolution_details["party_type"]
        party_type_display = ""  # must have this type of pokemon in their party
        if party_type_dict:
            party_type = type_(party_type_dict["name"])
            party_type_display = " " + self.translate(
                "evolve.details.with.pokemon.party.type",
                {"type": self._get_name_from_lang(party_type.names)})

        location_dict = evolution_details["location"]
        location_display = ""
        if location_dict:
            game_location = location(location_dict["name"])
            location_display = " " + self.translate(
                "evolve.details.location",
                {"location": self._get_name_from_lang(game_location.names)})

        needs_rain_display = ""
        if evolution_details["needs_overworld_rain"]:
            needs_rain_display = " " + self.translate(
                "evolve.details.with.rain")

        turn_upside_down_display = ""
        if evolution_details["turn_upside_down"]:
            turn_upside_down_display = " " + self.translate(
                "evolve.details.turn.upside.down")

        known_move = evolution_details["known_move"]
        known_move_display = ""
        if known_move:
            known_move_display = " " + self.translate(
                "evolve.details.knowing.move", {
                    "move":
                    self._get_name_from_lang(move(known_move["name"]).names)
                })

        known_move_type = evolution_details["known_move_type"]
        known_move_type_display = ""
        if known_move_type:
            known_move_type_display = " " + self.translate(
                "evolve.details.knowing.move.type", {
                    "type":
                    self._get_name_from_lang(
                        type_(known_move_type["name"]).names)
                })

        relative_stats = evolution_details["relative_physical_stats"]
        relative_stats_display = ""
        if relative_stats is not None:
            if relative_stats == -1:
                relative_stats_display = " " + self.translate(
                    "evolve.details.stats.attack.less.than.defense")
            elif relative_stats == 0:
                relative_stats_display = " " + self.translate(
                    "evolve.details.stats.attack.equals.defense")
            else:
                assert relative_stats == 1
                relative_stats_display = " " + self.translate(
                    "evolve.details.stats.attack.greater.than.defense")

        party_species = evolution_details["party_species"]
        party_species_display = ""
        if party_species:
            species_name = self._species_name(
                pokemon_species(party_species["name"]))
            party_species_display = " " + self.translate(
                "evolve.details.with.pokemon.party", {"pokemon": species_name})

        # ==== different triggers ====
        if trigger.name == "shed":
            return trigger_name
        elif trigger.name == "use-item":
            used_item = item(evolution_details["item"]["name"])
            return trigger_name + " " + self._get_name_from_lang(
                used_item.names)
        elif trigger.name == "trade":
            trade_species_dict = evolution_details["trade_species"]
            trade_species_display = ""
            if trade_species_dict:
                trade_species = pokemon_species(trade_species_dict["name"])
                trade_species_display = " " + self.translate(
                    "evolve.details.trade.species",
                    {"species": self._get_name_from_lang(trade_species.names)})
            return trigger_name + held_item_display + trade_species_display

        if trigger.name != "level-up":
            LOG.error(
                "This is bad! trigger.name should be level-up but it's: {}".
                format(trigger.name))

        # === level up trigger below ===
        level_up_display = trigger_name
        if min_level_display:
            level_up_display = min_level_display

        return (level_up_display + held_item_display + known_move_display +
                known_move_type_display + min_happiness_display +
                min_beauty_display + min_affection_display + time_display +
                location_display + needs_rain_display + gender_display +
                relative_stats_display + party_type_display +
                party_species_display + turn_upside_down_display)
Пример #16
0
 def __init__(self, name, max_pp=None, cur_pp=None):
     self.name = name
     self.db_move = pokedb.move(name)
     self.max_pp = self.db_move.pp if max_pp is None else max_pp
     self.cur_pp = self.max_pp if cur_pp is None else cur_pp
    def pokemonVPokemon(pokemon1, pokemon2):
        # Returns 1 if pokemon1 wins, 0 if they lose

        #Check if either pokemon are none
        if (pokemon1 == None):
            return 0
        if (pokemon2 == None):
            return 1

        pokemon1Moves = [
            pokemon1.move1, pokemon1.move2, pokemon1.move3, pokemon1.move4
        ]
        pokemon2Moves = [
            pokemon2.move1, pokemon2.move2, pokemon2.move3, pokemon2.move4
        ]
        pokemon1MovePower = [0, 0, 0, 0]
        pokemon2MovePower = [0, 0, 0, 0]
        # Get the base power for each move including STAB and Type Advantage
        for i in range(0, len(pokemon1Moves)):
            if (pokemon1Moves[i] != None):
                pokemon1MovePower[i] = problemHelper.pokemonMovePower(
                    pokemon1Moves[i], pokemon1, pokemon2)
            else:
                pokemon1MovePower[i] = 0
        for i in range(0, len(pokemon2Moves)):
            if (pokemon2Moves[i] != None):
                pokemon2MovePower[i] = problemHelper.pokemonMovePower(
                    pokemon2Moves[i], pokemon2, pokemon1)
            else:
                pokemon2MovePower[i] = 0
        # Get the Stats for each pokemon
        pokemon1Stats = problemHelper.pokemonStats(pokemon1)
        pokemon2Stats = problemHelper.pokemonStats(pokemon2)
        # Calculate the damage each move will do
        pokemon1MoveDamage = [0, 0, 0, 0]
        pokemon2MoveDamage = [0, 0, 0, 0]
        for i in range(0, len(pokemon1Moves)):
            if (pokemon1Moves[i] != None):
                # Get the type of the move
                damageClass = pb.move(pokemon1Moves[i]).damage_class.id
                # If Physical attack
                if (damageClass == pb.move_damage_class("physical").id):
                    pokemon1MoveDamage[i] = problemHelper.damageDealt(
                        pokemon1.level, pokemon1MovePower[i], pokemon1Stats[1],
                        pokemon2Stats[2], 1)
                # If Special attack
                elif (damageClass == pb.move_damage_class("special").id):
                    pokemon1MoveDamage[i] = problemHelper.damageDealt(
                        pokemon1.level, pokemon1MovePower[i], pokemon1Stats[3],
                        pokemon2Stats[4], 1)
                # If Status Move
                elif (damageClass == pb.move_damage_class("status").id):
                    pokemon1MoveDamage[i] = 0
            else:
                pokemon1MoveDamage[i] = 0
        for i in range(0, len(pokemon2Moves)):
            if (pokemon2Moves[i] != None):
                # Get the type of the move
                damageClass = pb.move(pokemon2Moves[i]).damage_class.id
                # If Physical attack
                if (damageClass == pb.move_damage_class("physical").id):
                    pokemon2MoveDamage[i] = problemHelper.damageDealt(
                        pokemon2.level, pokemon2MovePower[i], pokemon2Stats[1],
                        pokemon1Stats[2], 1)
                # If Special attack
                elif (damageClass == pb.move_damage_class("special").id):
                    pokemon2MoveDamage[i] = problemHelper.damageDealt(
                        pokemon2.level, pokemon2MovePower[i], pokemon2Stats[3],
                        pokemon1Stats[4], 1)
                # If Status Move
                elif (damageClass == pb.move_damage_class("status").id):
                    pokemon2MoveDamage[i] = 0
            else:
                pokemon2MoveDamage[i] = 0

        #If Pokemon 1 does more damage return true
        if (max(pokemon1MoveDamage) >= max(pokemon2MoveDamage)):
            print("Win,  ", end='', flush=True)
            return 1
        else:
            print("Loss, ", end='', flush=True)
            return 0