Commit d17efe3f by BellCodeEditor

save project

parent df53ee8b
Showing with 18 additions and 3 deletions
......@@ -9,6 +9,9 @@ class Hero:
def gongji(self,e):
e.hp -= self.att
if self.hp <= 0:
print(e.name + "死了!")
exit
print(self.name + "攻击" + e.name
+ "造成" + str(self.att) + "点伤害,"
+ e.name + "剩" + str(e.hp) + "点血。")
......@@ -32,5 +35,17 @@ class Player(Hero):
p1 = Player(500,90,"张飞")
p2 = Player(300,60,"岩石")
p1.gongji(p2)
p2.cure()
\ No newline at end of file
while p1.hp > 0 and p2.hp > 0:
d = int(input())
if(d == 1):
p1.gongji(p2)
elif(2 == d):
p1.cure()
print("--------------------------------------")
d = int(input())
if(d == 1):
p2.gongji(p1)
elif(2 == d):
p2.cure()
print("--------------------------------------")
\ No newline at end of file
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