importrandomclassPokemon:"""Blueprint for turn based Pokemon battle"""def__init__(self,attack_choice):self.__attack_choice=attack_choicedefattack(self):ifself.__attack_choice==1:attack_points=random.randint(18,25)returnattack_pointselifself.__attack_choice==2:attack_points=random.randint(10,35)returnattack_pointselse:print("That is not a selection. You lost your turn!")defheal(self):heal_points=random.randint(18,25)returnheal_points###########################################################################
user_health=100mew_health=100battle_continue=Truewhilebattle_continue==True:print("\nATTACK CHOICES\n1. Close range attack\n2. Far range attack\n3. Heal")attack_choice=eval(input("\nSelect an attack: "))# Mew selects an attack, but focuses on attacking if health is full.
ifmew_health==100:mew_choice=random.randint(1,2)else:mew_choice=random.randint(1,3)mew=Pokemon(mew_choice)user_pokemon=Pokemon(attack_choice)# Attacks by user and Mew are done simultaneously.
ifattack_choice==1orattack_choice==2:damage_to_mew=user_pokemon.attack()heal_self=0print("You dealt",damage_to_mew,"damage.")ifmew_choice==1ormew_choice==2:damage_to_user=mew.attack()heal_mew=0print("Mew dealt",damage_to_user,"damage.")ifattack_choice==3:heal_self=user_pokemon.heal()damage_to_mew=0print("You healed",heal_self,"health points.")ifmew_choice==3:heal_mew=mew.heal()damage_to_user=0print("Mew healed",heal_mew,"health points.")user_health=user_health-damage_to_user+heal_selfmew_health=mew_health-damage_to_mew+heal_mew# Pokemon health points are limited by a min of 0 and a max of 100.
ifuser_health>100:user_health=100elifuser_health<=0:user_health=0battle_continue=Falseifmew_health>100:mew_health=100elifmew_health<=0:mew_health=0battle_continue=Falseprint("Your current health is",user_health)print("Mew's current health is",mew_health)print("Your final health is",user_health)print("Mew's final health is",mew_health)ifuser_health<mew_health:print("\nYou lost! Better luck next time!")else:print("\nYou won against Mew!")
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.