Commit 1b96c7d6 by BellCodeEditor

save project

parent 65f59d4f
Showing with 32 additions and 7 deletions
...@@ -15,9 +15,11 @@ class Hero(object): ...@@ -15,9 +15,11 @@ class Hero(object):
else: else:
print(enemy.name+" is kill,game is stop ") print(enemy.name+" is kill,game is stop ")
exit() exit()
class player(Hero):
yase = Hero("A") def __init__(self,name):
houyi= Hero("B") super().__init__(name)
for i in range(int(input("range = "))): self.attack = 1000
yase.combat(houyi) self.hp = 2
houyi.combat(yase) p1 = player("A")
\ No newline at end of file print(p1.attack)
print(p1.hp)
\ No newline at end of file
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(self,enemy): # 攻击
enemy.hp-=self.attack
t1=self.name+" combat "+enemy.name+" hurt "+str(self.attack)+" blood volume, "
W1=enemy.name+" rest "+str(enemy.hp)+" blood volume "
if enemy.hp>0 :
print(t1+W1)
else:
print(enemy.name+" is kill,game is stop ")
exit()
yase = Hero("A")
houyi= Hero("B")
for i in range(int(input("range = "))):
yase.combat(houyi)
houyi.combat(yase)
\ 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