Commit 1b96c7d6 by BellCodeEditor

save project

parent 65f59d4f
Showing with 32 additions and 7 deletions
......@@ -15,9 +15,11 @@ class Hero(object):
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
class player(Hero):
def __init__(self,name):
super().__init__(name)
self.attack = 1000
self.hp = 2
p1 = player("A")
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