正在加载图片...
class Pokemon: basic_attack ='tackle' damage =40 def __init__(self,name,trainer): self.name,self.trainer name,trainer self.level,self.hp 1,50 self.paralyzed False def speak(self): print(self.name +!' def attack(self,other): if not self.paralyzed: self.speak() print(self.name,'used',self.basic_attack,!') other.receive_damage(self.damage) def receive_damage(self,damage): self.hp max(0,self.hp -damage) if self.hp ==0: print(self.name,fainted!')class Pokemon: basic_attack = 'tackle' damage = 40 def __init__(self, name, trainer): self.name, self.trainer = name, trainer self.level, self.hp = 1, 50 self.paralyzed = False def speak(self): print(self.name + '!') def attack(self, other): if not self.paralyzed: self.speak() print(self.name, 'used', self.basic_attack, '!') other.receive_damage(self.damage) def receive_damage(self, damage): self.hp = max(0, self.hp - damage) if self.hp == 0: print(self.name, 'fainted!')
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有