Commit 802f19e4 by BellCodeEditor

save project

parent cb85750b
Showing with 72 additions and 17 deletions
......@@ -5,13 +5,65 @@ class Hero:
self.hp=hp
self.attack=attack
yase=Hero(200,"亚瑟",40)
def urguage():
yase.level=yase.level+1
yase.hp=yase.hp+1
yase.attack=yase.attack+1
urguage()
print(yase.hp)
def combat(self,enemy)
enemy.hp-=self.attack
info1=self.name+"发起攻击"+enemy.name
info2=eneym.name+"造成"+str(self.attack)
if enemy.hp>0:
......@@ -45,14 +97,16 @@ print(yase.hp)
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
yase=Hero("亚瑟",200,40)
houyi=Hero("后羿",400,20)
print(yase.hp)
print(houyi.name)
def combat(self,enemy):
enemy.hp-=self.attack
info1=self.name+"发起攻击"+enemy.name
info2=eneym.name+"造成"+str(self.attack)
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)
info=info1+info2+info3
print(info)
else:
info3=enemy.name+"阵亡"
info=info1+info2+info3
print(info)
\ 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