Commit b88e1cf5 by BellCodeEditor

save project

parent 55c8804b
Showing with 15 additions and 5 deletions
...@@ -5,6 +5,7 @@ class Hero(object): ...@@ -5,6 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
self.max_hp = self.hp
print("congratulations create " + self.name) print("congratulations create " + self.name)
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
enemy.hp-=self.attack enemy.hp-=self.attack
...@@ -15,11 +16,21 @@ class Hero(object): ...@@ -15,11 +16,21 @@ class Hero(object):
else: else:
print(enemy.name+" is kill,game is stop ") print(enemy.name+" is kill,game is stop ")
exit() exit()
def cure(self):
self.hp+=60
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+" cure 60 blood volume ,"+" at present rest "+str(self.hp))
class player(Hero): class player(Hero):
def __init__(self,name): def __init__(self,name):
super().__init__(name) super().__init__(name)
self.attack = 1000 self.attack = 1000
self.hp = 2 self.hp = 11111
p1 = player("A") self.max_hp = self.hp
print(p1.attack) p1 = player("A")
print(p1.hp) p2 = Hero("B")
\ No newline at end of file for j in range(int(input("range == "))):
p2.combat(p1)
p1.cure()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment