-
-
Save codecademydev/b0ed37d1708204f4453385614f6ce8dc to your computer and use it in GitHub Desktop.
Codecademy export
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
class Pokemon: | |
def __init__(self,name,level,Type,max_lv,current_lv,knocked_out): | |
self.name = name | |
self.level = level | |
self.Type = Type | |
self.max_lv = max_lv | |
self.current_lv = current_lv | |
self.knocked_out = knocked_out | |
#lose health | |
def lose_health(self, damage): | |
self.current_lv = self.current_lv - damage | |
if self.current_lv >0: | |
print("Your pokemon "+str(self.name)+ " had lost " + str(damage) + " and remian " + str(self.current_lv)) | |
else: | |
self.ko() | |
#ko | |
def ko(self): | |
self.current_lv = 0 | |
print ("Your pokemon "+ str(self.name)+ " had been knocked out.") | |
#revive | |
def revive(self,gain): | |
if self.current_lv == 0 and self.current_lv <= self.max_lv: | |
self.current_lv = self.current_lv+gain | |
print ("Your pokemon had been revived, and current lv is " +str(self.current_lv)) | |
#attack | |
def attack(self,pokemon_being_attack,damage): | |
if self.Type == pokemon_being_attack.Type: | |
return pokemon_being_attack.lose_health(damage) | |
else: | |
if self.Type =="fire" and pokemon_being_attack.Type == "water": | |
damage = damage/2 | |
return pokemon_being_attack.lose_health(damage) | |
elif self.Type =="fire" and pokemon_being_attack.Type == "grass": | |
damage = damage*2 | |
return pokemon_being_attack.lose_health(damage) | |
elif self.Type =="water" and pokemon_being_attack.Type == "fire": | |
damage = damage*2 | |
return pokemon_being_attack.lose_health(damage) | |
elif self.Type =="water" and pokemon_being_attack.Type == "grass": | |
damage = damage/2 | |
return pokemon_being_attack.lose_health(damage) | |
elif self.Type == "grass" and pokemon_being_attack.Type == "fire": | |
damage = damage/2 | |
return pokemon_being_attack.lose_health(damage) | |
else: | |
damage = damage*2 | |
return pokemon_being_attack.lose_health(damage) | |
class Trainer: | |
def __init__(self,name,heal_potion,pokemon_list,current_use): | |
self.name = name | |
self.heal_potion = heal_potion | |
self.pokemon_list = pokemon_list | |
self.current_use = current_use | |
def use_potion(self,gain): | |
current_use.current_lv = current_use.current_lv + gain | |
print (" Your current" + str(current_use) +" has been healed to " +str(current_use.current_lv)) | |
def attack_t(self,trainer_being_attacked,damage): | |
return self.attack(trainer_being_attacked.current_use,damage) | |
def switch(self,choosed_poke): | |
if choosed_poke in self.pokemon_list: | |
self.current_use = choosed_poke | |
print ("Your had switch to " + str(self.current_use)) | |
AAA = Pokemon('AAA',59,"fire",59,59,"no") | |
BBB = Pokemon('BBB',69,"water",69,69,"no") | |
CCC = Pokemon('CCC',69,"grass",69,69,"no") | |
AAA.attack(BBB,20) | |
BBB.attack(AAA,30) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment