Commit 55c8804b by BellCodeEditor

save project

parent 8128320c
Showing with 25 additions and 2 deletions
...@@ -5,7 +5,7 @@ class Hero(object): ...@@ -5,7 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
print("congratulations create " + self.name)
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
enemy.hp-=self.attack enemy.hp-=self.attack
t1=self.name+" combat "+enemy.name+" hurt "+str(self.attack)+" blood volume, " t1=self.name+" combat "+enemy.name+" hurt "+str(self.attack)+" blood volume, "
......
...@@ -4,7 +4,7 @@ class Hero(object): ...@@ -4,7 +4,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
print("congratulations create " + self.name)
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
enemy.hp-=self.attack enemy.hp-=self.attack
t1=self.name+" combat "+enemy.name+" hurt "+str(self.attack)+" blood volume, " t1=self.name+" combat "+enemy.name+" hurt "+str(self.attack)+" blood volume, "
......
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
print("congratulations create " + self.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