Last active
May 26, 2024 17:31
-
-
Save anonymousAwesome/a62e99425c0ba10a39681006f7ca6b5a to your computer and use it in GitHub Desktop.
Python script for a simplified Pokemon game, but with characters from popular media instead of Pokemon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
known bugs: | |
sometimes the gym will not give a badge and automatically move the player | |
to the next town. | |
sometimes the gym will move the player twice at once. | |
sometimes the gym leader will be defeated after a single battle. I think | |
this happens after the player attempts to capture a seventh pokemon, but | |
I can't figure out why that would affect it. | |
''' | |
global_pokemon_dict={ | |
"Spongebob Squarepants": ["Bubble Blowing", "Jellyfishing", "Absorbency", "Karaté"], | |
"Master Chief": ["Super Soldier Strength", "Enhanced Reflexes", "Mjolnir Armor", "Expert Marksman"], | |
"Sonic the Hedgehog": ["Super Speed", "Spin Attack", "Homing Attack", "Chaos Control"], | |
"Dr. Perry Cox": ["Medical Expertise", "Sarcasm", "Mentorship", "High Pain Tolerance"], | |
"Harry Potter": ["Expelliarmus", "Invisibility Cloak", "Patronus Charm", "Parseltongue"], | |
"Sherlock Holmes": ["Deductive Reasoning", "Forensic Science", "Disguise", "Martial Arts"], | |
"Mario": ["Super Jump", "Fireball Throw", "Power-Ups", "Super Strength"], | |
"Homer Simpson": ["Indestructibility", "Endless Appetite", "D'oh!", "Mediocre Guitar Skills"], | |
"Batman": ["Martial Arts Mastery", "Stealth", "Gadgetry", "Detective Skills"], | |
"Hermione Granger": ["Brilliant Mind", "Advanced Spellcasting", "Time Turner", "Polyjuice Potion"], | |
"Link": ["Master Swordsmanship", "Archery", "Magical Instruments", "Triforce of Courage"], | |
"Katniss Everdeen": ["Archery", "Survival Skills", "Hunting", "Leadership"], | |
"Elsa": ["Ice Manipulation", "Cryokinesis", "Snow Creation", "Magical Constructs"], | |
"Optimus Prime": ["Transforming", "Leadership", "Energon Axe", "Blaster Cannon"], | |
"Iron Man": ["Powered Armor Suit", "Genius-Level Intellect", "Advanced Weaponry", "Flight"], | |
"Darth Vader": ["Force Choke", "Lightsaber Mastery", "Telekinesis", "Dark Side Mastery"], | |
"Spider-Man": ["Wall-Crawling", "Web-Slinging", "Spider-Sense", "Super Strength"], | |
"Mickey Mouse": ["Sorcery", "Bravery", "Leadership", "Charm"], | |
"Neo": ["Bullet Dodging", "Superhuman Strength", "Reality Manipulation", "Martial Arts"], | |
"Jack Sparrow": ["Swordsmanship", "Cunning", "Marksmanship", "Navigation"], | |
"Ash Ketchum": ["Pokemon Training", "Battle Strategy", "Friendship Bonding", "Catching Pokemon"], | |
"Yoda": ["Force Mastery", "Lightsaber Combat", "Wisdom", "Telekinesis"], | |
"Zoidberg": ["Medical Knowledge", "Ink Squirting", "Regeneration", "Crustacean Physiology"], | |
"Princess Leia": ["Leadership", "Blaster Proficiency", "Diplomacy", "Rebellion Strategist"], | |
"Hermes Conrad": ["Bureaucratic Expertise", "Limbo Skills", "Speed", "Mathematical Genius"], | |
"Po the panda": ["Kung Fu", "Wuxi Finger Hold", "Hero's Chi", "Inner Peace"], | |
"Aang": ["Airbending", "Waterbending", "Earthbending", "Firebending"], | |
"Katara": ["Waterbending", "Healing", "Icebending", "Bloodbending"], | |
"Woody the cowboy": ["Leadership", "Lasso Skills", "Stealth", "Resourcefulness"], | |
"Buzz Lightyear": ["Flight", "Laser Beam", "Martial Arts", "Shielding"], | |
"Bella Swan": ["Mental Shield", "Heightened Senses", "Physical Endurance", "Self-Control"], | |
"Edward Cullen": ["Telepathy", "Super Speed", "Super Strength", "Immortality"], | |
"Robin": ["Martial Arts", "Detective Skills", "Gadgetry", "Acrobatics"], | |
"Starfire": ["Starbolts", "Flight", "Super Strength", "Energy Absorption"], | |
"Eric Cartman": ["Manipulation", "Deception", "Persistence", "Singing"], | |
"Tweek": ["High Alertness", "Paranoia-Fueled Strength", "Nervous Energy", "Caffeine Resistance"], | |
"Invader Zim": ["Alien Technology", "Disguise", "Irken Strength", "Manipulation"], | |
"Dib": ["Paranormal Investigation", "Gadget Creation", "Determination", "Combat Skills"], | |
"Gaz": ["Gaming Prowess", "Intimidation", "Sarcasm", "Intellect"], | |
"Arnold Shortman": ["Optimism", "Problem-Solving", "Football Head Strength", "Empathy"], | |
"Helga Pataki": ["Poetry Writing", "Wrestling", "Leadership", "Secret Admiration"], | |
"The Doctor": ["Time Travel", "Regeneration", "Genius-Level Intellect", "Sonic Screwdriver"], | |
"Turanga Leela": ["Martial Arts", "Pilot Skills", "Leadership", "Super Strength"], | |
"Philip J. Fry": ["Time Travel", "Luck", "Unique Brain Wave", "Endurance"], | |
"Bender Bending Rodriguez": ["Bending", "Alcohol-Fueled Power", "Insult Comedy", "Robotic Strength"], | |
"Sandy Cheeks": ["Karate", "Scientific Expertise", "Inventing", "Underwater Survival"], | |
"Patrick Star": ["Super Strength", "Durability", "Stupidity-Induced Luck", "Rock Hiding"], | |
"John Dorian": ["Medical Skills", "Daydreaming", "Empathy", "Humor"], | |
"Turk": ["Surgical Skills", "Dancing", "Athleticism", "Loyalty"], | |
"Ron Weasley": ["Wizardry", "Strategic Thinking", "Chess Mastery", "Bravery"], | |
"Bowser": ["Fire Breath", "Super Strength", "Shell Defense", "Dark Magic"], | |
"Princess Peach": ["Healing", "Floatation", "Magic", "Diplomacy"], | |
"Marge Simpson": ["Household Management", "Strength", "Resilience", "Cooking"], | |
"Bart Simpson": ["Pranking", "Skateboarding", "Slingshot Accuracy", "Imagination"], | |
"Lisa Simpson": ["Intellect", "Saxophone Playing", "Environmental Activism", "Empathy"], | |
"Princess Zelda": ["Magic", "Wisdom", "Archery", "Shapeshifting"], | |
"Luke Skywalker": ["The Force", "Lightsaber Combat", "Piloting", "Jedi Mind Trick"] | |
} | |
global_gym_list=[ | |
"Ash", "Bed", "Bismuth", "Blanket", "Brick", "Bridge", "Bubble", "Building", | |
"Candy", "Car", "Cavern", "Chasm", "Circuitry", "Coldness", "Copper", "Cotton Candy", | |
"Crystal", "Desert", "Dodo", "Dream", "Dreamstuff", "Echo", "Emerald", "Fairy Dust", | |
"Fern", "Fire", "Flame", "Flower", "Foam", "Fog", "Foodstuff", "Frost", "Funny Hat", | |
"Gelatin", "Gem", "Geode", "Geyser", "Gilding", "Glass", "Glitter", "Glow", "Gold", | |
"Goo", "Grape", "Heat", "Helmet", "Honey", "Honeysuckle", "Hoofbeast", "Ice", "Ink", | |
"Island", "Jelly", "Jungle", "Junk", "Kangaroo", "Labyrinth", "Lake", "Laurel", | |
"Light", "Locker", "Marshmallow", "Mask", "Metalwork", "Mist", "Neon", "Night", | |
"Nightmare", "Noise", "Onyx", "Orange", "Package", "Pagoda", "Paint", "Parking Lot", | |
"Pillar", "Pirate Ship", "Pond", "Prism", "Prison", "Pulse", "Quartz", "Rainbow", | |
"Reflection", "Ruby", "Rust", "Shade", "Shadow", "Shopping Center", "Shrubbery", | |
"Slime", "Spark", "Sparkle", "Specter", "Sprocket", "Statue", "Stream", "Sunflower", | |
"Syrup", "Tapestry", "Tapioca", "Tapir", "Tower", "Tree", "Vapor", "Void", "Walrus", | |
"Waterfall", "Whimsy", "Yarn" | |
] | |
""" | |
To-do: | |
fix gyms, implement badges | |
add "congratulations!" text and end the game when all badges obtained | |
""" | |
import random | |
class Pokemon: | |
def __init__(self,name,attacks): | |
self.name=name | |
self.attacks=attacks | |
self.alive=True | |
def KOed(self): | |
self.alive=False | |
def healed(self): | |
self.alive=True | |
class Game: | |
def __init__(self): | |
self.player_pokemon = [] | |
self.badges = [] | |
self.most_recent_route = 1 | |
self.most_recent_city = 0 | |
self.cities = global_gym_list | |
random.shuffle(self.cities) | |
self.current_location = self.cities[0] | |
self.location_type="city" | |
self.untouched_pokemon_dict=global_pokemon_dict | |
# self.untouched_pokemon_dict = { | |
# "Bulbasaur": ["Tackle", "Growl", "Vine Whip", "Leech Seed"], | |
# "Charmander": ["Scratch", "Growl", "Ember", "Smokescreen"], | |
# "Squirtle": ["Tackle", "Tail Whip", "Water Gun", "Withdraw"] | |
# "test1":["a","b","c","d"], | |
# "test2":["e","f","g","h"] | |
#} | |
self.shuffled_pokemon_list=random.sample(list(self.untouched_pokemon_dict),len(self.untouched_pokemon_dict)) | |
self.starting_pokemon=[] | |
for i in range(3): | |
self.starting_pokemon.append(self.shuffled_pokemon_list.pop()) | |
self.next_location="Route 1" | |
self.next_location_type="route" | |
self.in_trainer_battle=False | |
self.gym_battle=False | |
def pop_pokemon(self): | |
if not self.shuffled_pokemon_list: | |
self.shuffled_pokemon_list=random.sample(list(self.untouched_pokemon_dict),len(self.untouched_pokemon_dict)) | |
return(self.shuffled_pokemon_list.pop()) | |
def choose_starting_pokemon(self): | |
print("Choose your starting Pokemon:") | |
for i, pokemon in enumerate(self.starting_pokemon, start=1): | |
print(f"{i}. {pokemon}") | |
choice = int(input("Enter the number of your choice: ")) - 1 | |
self.starting_pokemon = self.starting_pokemon[choice] | |
self.player_pokemon.append(Pokemon(self.starting_pokemon,self.untouched_pokemon_dict[self.starting_pokemon])) | |
print(f"You chose {self.starting_pokemon}!") | |
def main(self): | |
self.choose_starting_pokemon() | |
while True: | |
self.gym_battle=False | |
self.in_trainer_battle=False | |
for pokemon in self.player_pokemon: | |
pokemon.healed() | |
if self.location_type=="city": | |
print(f"\nYou are in {self.current_location} City. What do you want to do?") | |
print("1. Next Location") | |
print("2. Challenge Gym") | |
print("4. Check Pokemon") | |
print("5. List Badges") | |
print("7. Exit Game") | |
choice = input("Enter the number of your choice: ") | |
if choice == "1": | |
self.explore_next_location() | |
elif choice == "2": | |
self.challenge_gym() | |
elif choice == "4": | |
self.check_pokemon() | |
elif choice == "5": | |
self.list_badges() | |
elif choice == "6": | |
self.current_location = cities[self.most_recent_city] | |
print(f"Returning to {self.current_location}") | |
elif choice == "7": | |
print("Thank you for playing!") | |
break | |
else: | |
print(f"\nYou are in {self.current_location} City. What do you want to do?") | |
print("1. Next Location") | |
print("4. Check Pokemon") | |
print("5. List Badges") | |
print("6. Return to Last City") | |
print("7. Exit Game") | |
choice = input("Enter the number of your choice: ") | |
if choice == "1": | |
self.explore_next_location() | |
elif choice == "4": | |
self.check_pokemon() | |
elif choice == "5": | |
self.list_badges() | |
elif choice == "6": | |
self.current_location = cities[self.most_recent_city] | |
print(f"Returning to {self.current_location}") | |
elif choice == "7": | |
print("Thank you for playing!") | |
break | |
def fight_pokemon(self, pokemon_name): | |
temp_pokemon=Pokemon(pokemon_name,self.untouched_pokemon_dict[pokemon_name]) | |
while self.list_alive_pokemon(): | |
print("Choose a Pokemon to send out:") | |
for i, pkmn in enumerate(self.list_alive_pokemon(), start=1): | |
print(f"{i}. {pkmn.name}") | |
choice = int(input("Enter the number of your choice: ")) - 1 | |
player_choice = self.list_alive_pokemon()[choice] | |
print(f"\nYou sent out {player_choice.name}!") | |
print("Choose an attack:") | |
for i, move in enumerate(player_choice.attacks, start=1): | |
print(f"{i}. {move}") | |
move_choice = int(input("Enter the number of your choice: ")) - 1 | |
if random.random() < 0.6: | |
print(f"\nThe attack {player_choice.attacks[move_choice]} was successful!") | |
print(f"You defeated the {pokemon_name}!") | |
break | |
else: | |
print(f"\nThe attack {player_choice.attacks[move_choice]} missed!") | |
print(f"The attacking {pokemon_name} used {random.choice(temp_pokemon.attacks)}!") | |
print(f"Your {player_choice.name} was knocked out!") | |
player_choice.KOed() | |
self.in_trainer_battle=False | |
if self.list_alive_pokemon(): | |
if not self.in_trainer_battle: | |
if not self.gym_battle: | |
self.travel_to_new_city() | |
if not self.list_alive_pokemon(): | |
print("You have no Pokemon left! Returning to the most recent city.") | |
self.current_location = self.cities[self.most_recent_city] | |
def catch_pokemon(self, wild_pokemon): | |
if len(self.player_pokemon) < 6: | |
self.player_pokemon.append(wild_pokemon) | |
print(f"You threw a pokeball! One... two... three... Congratulations! You caught a {wild_pokemon.name}!") | |
else: | |
print("You can't carry any more Pokemon!") | |
self.travel_to_new_city() | |
def list_alive_pokemon(self): | |
templist=[] | |
for pokemon in self.player_pokemon: | |
if pokemon.alive: | |
templist.append(pokemon) | |
return templist | |
def explore_next_location(self): | |
if self.location_type=="city": | |
self.explore_route() | |
if self.location_type=="route": | |
self.travel_to_new_city() | |
def explore_route(self): | |
print(f"\nYou are now on Route {self.most_recent_route}") | |
if random.random() < 0.5: | |
self.encounter_pokemon() | |
else: | |
self.encounter_trainer() | |
def travel_to_new_city(self): | |
self.most_recent_route += 1 | |
self.most_recent_city += 1 | |
if self.most_recent_city >= len(self.cities): | |
print("You have reached the final city.") | |
return | |
self.current_location = self.cities[self.most_recent_city] | |
print(f"You traveled to {self.current_location} City.") | |
def encounter_pokemon(self): | |
wild_pokemon = self.pop_pokemon() | |
temp_pokemon=Pokemon(wild_pokemon,self.untouched_pokemon_dict[wild_pokemon]) | |
print(f"A wild {wild_pokemon} appeared!") | |
action = input("Do you want to (1) Fight, or (2) Catch? ") | |
if action == "1": | |
self.fight_pokemon(wild_pokemon) | |
elif action == "2": | |
self.catch_pokemon(temp_pokemon) | |
def encounter_trainer(self): | |
self.in_trainer_battle=True | |
pokemon_quantity=random.randint(1, min(6, len(self.player_pokemon))) | |
trainer_name=self.pop_pokemon() | |
trainer_pokemon_list=[] | |
for i in range(pokemon_quantity): | |
trainer_pokemon_list.append(self.pop_pokemon()) | |
print(f"\n{trainer_name} challenges you with {pokemon_quantity} Pokemon!") | |
for _ in range(pokemon_quantity): | |
if self.in_trainer_battle: | |
if self.list_alive_pokemon(): | |
wild_pokemon = trainer_pokemon_list.pop() | |
print(f"Trainer {trainer_name} sent out {wild_pokemon}!") | |
self.fight_pokemon(wild_pokemon) | |
self.in_trainer_battle=False | |
if self.list_alive_pokemon(): | |
if not self.gym_battle: | |
self.travel_to_new_city() | |
if self.list_alive_pokemon(): | |
return(True) | |
else: | |
return(False) | |
def challenge_gym(self): | |
if self.current_location + " Badge" in self.badges: | |
print("You already have that badge!") | |
return() | |
print("Challenging the gym leader!") | |
self.gym_battle=True | |
if self.encounter_trainer(): | |
print(f"Congratulations! You earned the {self.current_location} Badge!") | |
self.badges.append(self.current_location + " Badge") | |
if len(self.badges)==6: | |
print(""" | |
---------------------------------- | |
CONGRATULATIONS! | |
You have collected all 6 badges! | |
You are a true Pokemon master! | |
----------------------------------""") | |
exit() | |
def check_pokemon(self): | |
print("Your Pokemon:") | |
for pkmn in self.player_pokemon: | |
print(f"{pkmn.name} - Attacks: {', '.join(pkmn.attacks)}") | |
def list_badges(self): | |
print("Your badges:") | |
for badge in self.badges: | |
print(badge) | |
if __name__ == "__main__": | |
game = Game() | |
game.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment