Commit 06c3f96c by BellCodeEditor

auto save

parent 9a581ef4
Showing with 14 additions and 5 deletions
...@@ -3,12 +3,22 @@ class Hero(object): ...@@ -3,12 +3,22 @@ class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.att = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,DiRen): # 攻击
??? DiRen.hp -= self.att
print("%s对%s发起进攻,造成%s点伤害"%(self.name,DiRen.name,self.att))
if(DiRen.hp<=0):
print("%s血量为0,游戏结束"%DiRen.name)
else:
print("%s还剩下%s血量"%(DiRen.name,DiRen.hp))
def ZL(self):
self.hp += 40
if self.hp >= 250:
self.hp = 250
print("%s使用了治疗术,恢复40点血量,%s还剩下%s血量"%(self.name,self.name,self.hp))
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) yase.ZL()
\ 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