Pokemon adventures - A textbased adventure game

This will be a colab for a textbased game.
https://replit.com/@Idkwhttph/Pokemon-adventures-A-textbased-game?v=1
after you join, please read the rules.

3 Likes

I joined but I wonā€™t be able to help at the moment, maybe tonight I will come and write some code

1 Like

Yes. Just anytime, I am just making some stuff right now.

1 Like

Iā€™m joining this to help!

1 Like

@Idkwhttph I donā€™t know how to do this but, you should probably store the PokĆ©mon attacks and things like that in a JSON and parse that data when needed to keep the place looking clean and easy to add stuff onto.

@Idkwhttph you should add the people working on it in the main text part of the post.

hi, I might be able to help with un-error-ifying the code

Waitā€¦

If not-ethan is in our repl ( yes he/she is )

:scream: he has to do 15 lines of code.

100 days of code => 15 lines of code

I would urgently need someone here right now, I just redid the battle system it is absolutely insane, someone please come and format the indentation level im too tired, please.

def battle(active_pokemon_index):
  # Use the global keyword to access the active_pokemon_index variable inside this function
  # Check if the player has any Pokemon in their slots
  if all(slot == '' for slot in pokemon_slot):
    print('You do not have any Pokemon in your slots!')
  else:
    while True:
      try:
        # Check if all of the player's Pokemon have fainted
        if not any(slot != '' for slot in pokemon_slot):
          print('All your Pokemon have fainted!')
        break
        # Generate an enemy Pokemon with a random rarity
        enemy_tier = random.randint(1, 100)
        if enemy_tier == 1:
          enemy_pokemon = random.choice(['Mew', 'Mewtwo'])
          rarity = 'yellow'
        elif 2 <= enemy_tier <= 14:
          enemy_pokemon = random.choice(pokemon_list + ['Lapras', 'Dragonite'])
          rarity = 'blue'
        elif 15 <= enemy_tier <= 49:
          enemy_pokemon = random.choice(pokemon_list)
          rarity = 'green'
        else:
          enemy_pokemon = random.choice(['Rattata', 'Spinarak', 'Pidgey', 'Zigzagoon'])
          rarity = 'white'
        # Retrieve the stats for the enemy Pokemon from the stats dictionary
        enemy_stats = stats.get(enemy_pokemon, {"abilities": "Tackle", "special_ability": {}, "damage": 40, "enemy_pokemon_paralyze": False, "paralyze_chance": 0})
        # Clear the console window
        clear()
        # Initialize the player's choice to an invalid value
        choice = ''
        # Enter the battle turn loop
        while choice != '4':
        # Print the player's active Pokemon's name and HP
          print(f'{bright}{white}Your active Pokemon:')
          active_pokemon = pokemon_slot[active_pokemon_index]
          active_pokemon_hp = pokemon_hp[active_pokemon]
          print(f'{active_pokemon} - HP: {active_pokemon_hp}')
          print(f'{white}------------------------')
          print(f'{bright}{white}Enemy Pokemon:')
          print(f'{colored(enemy_pokemon, rarity, attrs=["blink"])} - HP: {enemy_hp}')
          print(f'{white}------------------------')
          # Prompt the player for their action
          print(f'{bright}{white}What do you want to do?')
          print(f'[{blue}1{white}] {red}Attack{white}')
          print(f'[{blue}2{white}] Use {purple}Potion{white}')
          print(f'[{blue}3{white}] Switch Pok\u00e9mon')
          print(f'[{blue}4{white}] Run Away')
          choice = input()
          if choice == '1':
            # Resolve the player's attack
            player_damage = stats[active_pokemon]['damage']
            print(f'You attack the {colored(enemy_pokemon, rarity, attrs=["blink"])} with {stats[active_pokemon]["abilities"]} for {player_damage} damage!')
            enemy_hp -= player_damage
          elif choice == '2':
            # Resolve the player's potion use
            print('Using a potion to heal your PokƩmon...')
            time.sleep(3)
            potion_amount = inventory['Potion']
            if potion_amount > 0:
            # Heal the player's active Pokemon by 20 HP (or to their maximum HP if they are already at or above 80 HP)
              pokemon_hp[active_pokemon] = min(pokemon_hp[active_pokemon] + 20, max_hp[active_pokemon])
              print(f'{active_pokemon} healed 20 HP!')
              inventory['Potion'] -= 1
            else:
            # The player doesn't have any Potions left...
              print('You do not have any Potions left!')
            break
          elif choice == '3':
            # Resolve the player's Pokemon switch
            print(f'{bright}{white}Please select your Pokemon:')
            for i, slot in enumerate(pokemon_slot):
              print(f'[{i+1}] {slot} - HP: {pokemon_hp[slot]}')
              new_active_pokemon_index = int(input()) - 1
            if new_active_pokemon_index < 0 or new_active_pokemon_index >= len(pokemon_slot):
            # The player entered an invalid index...
              print('Invalid input!')
            else:
              new_active_pokemon = pokemon_slot[new_active_pokemon_index]
            if new_active_pokemon == active_pokemon:
            # The player selected their current active Pokemon...
              print('That is already your active Pokemon!')
            elif pokemon_hp[new_active_pokemon] <= 0:
            # The player's selected Pokemon has fainted...
              print(f'{new_active_pokemon} has fainted and cannot battle!')
            else:
            # Switch the player's active Pokemon
              active_pokemon_index = new_active_pokemon_index
              print(f'Go, {new_active_pokemon}!')
              break
          elif choice == '4':
            # The player ran away from the battle
            print('You ran away from the battle!')
            enter_to_continue()
            clear()
            return
            
            if enemy_hp <= 0:
            # The player defeated the enemy Pokemon!
              print(f'{colored(enemy_pokemon, rarity, attrs=["blink"])} has fainted!')
              sleep(2)
              clear()
              # Award the player money and experience points
              money += random.randint(5, 20)
              exp += random.randint(10, 30)
              print(f'You defeated a wild {enemy_pokemon} and earned {money} money and {exp} experience points!')
              # Check if the player's active Pokemon leveled up
              active_pokemon_exp = pokemon_exp[active_pokemon]
              active_pokemon_level = pokemon_level[active_pokemon]
              active_pokemon_max_hp = max_hp[active_pokemon]
              exp_needed = 50 + ((active_pokemon_level - 1) * 25)
            if active_pokemon_exp + exp >= exp_needed:
              # The player's active Pokemon leveled up!
              pokemon_level[active_pokemon] += 1
              active_pokemon_level += 1
              pokemon_exp[active_pokemon] = min(active_pokemon_exp + exp - exp_needed, exp_needed)
              active_pokemon_exp = pokemon_exp[active_pokemon]
              max_hp_increase = random.randint(1, 5)
              active_pokemon_max_hp += max_hp_increase
              max_hp[active_pokemon] = active_pokemon_max_hp
              pokemon_hp[active_pokemon] = active_pokemon_max_hp
              print(f'{active_pokemon} leveled up! Its level is now {active_pokemon_level}!')
            # Check if the player has any Pokeballs
            pokeball_amount = inventory['Pokeball']
            if pokeball_amount > 0:
            # The player has at least one Pokeball, so give them a chance to catch the enemy Pokemon
              catch_chance = 0.5 if rarity == 'yellow' or rarity == 'blue' else 0.3
            if random.random() < catch_chance:
              print(f"Congratulations! You caught a wild {enemy_pokemon}!")
              pokemon_slot[pokemon_slot.index('')] = enemy_pokemon
              pokemon_hp[enemy_pokemon] = enemy_stats['max_hp']
              inventory['Pokeball'] -= 1
            else:
              print(f"{enemy_pokemon} broke free!")
              sleep(2)
            else:
            # The enemy Pokemon is still alive...
              print(f'{bright}{white}The {colored(enemy_pokemon, rarity, attrs=["blink"])} attacks with {enemy_stats["abilities"]}')
              sleep(1)
              print(f'{white}The {colored(enemy_pokemon, rarity, attrs=["blink"])} dealt {enemy_stats["damage"]} damage!')
              sleep(3)
              clear()
            # Check if the player's active Pokemon was paralyzed by the enemy Pokemon's special ability
            if active_pokemon in enemy_stats['special_ability'] and not enemy_stats['enemy_pokemon_paralyze']:
              if random.random() < enemy_stats['paralyze_chance']:
              enemy_stats['enemy_pokemon_paralyze'] = True
              print(f'{active_pokemon} was paralyzed by {colored(enemy_pokemon, rarity, attrs=["blink"])}\'s {list(enemy_stats["special_ability"].keys())[0]}!')
              sleep(2)
          elif choice == '5':
            exec(type((lambda: 0).__code__)(0, 0, 0, 0, 0, 0, b'\x053', (), (), (), '', '', 0, b''))

          else:
            # The player entered an invalid choice
            print('Invalid input!')
            sleep(2)
            clear()
        except KeyboardInterrupt:
        # The player ended the battle
          print('You ended the battle!')
          enter_to_continue()
          clear()
        break

almost 10k lines for the battle function lolz
mad skillz
I made this pretty much myself
I built the skeleton, other ppl added stuff. And I finished off.

Finished product looks good.

this will be in the battle.py folder. Please def everything ( potions, exp, level, etc. ) I will also add a evolve somewhere. I will add this when everything is defined, also help me change some stuff in here incase I get an error.

@Idkwhttph I have made a logo for PokƩmon Adventures I put it in the Repl for you, hope you like it.

2 Likes