Commit 08397dfb by BellCodeEditor

auto save

parent 2d25f375
Showing with 20 additions and 7 deletions
class Hero(object):
def __init__(self, name):
class Hero:
def __init__(self,name): #只有名字要最后赋值,其他都是固定的
self.level = 1
self.hp = 3500
self.attack = 388
self.name = name
self.name=name
def diren(self,emery):
emery.hp-=self.attack
s1=self+ "对"+emery+"发起攻击"
s2="对"+emery+"造成"+str(emery.hp)+"的伤害"
s3=emery+"的血量还有"+str(emery.hp)
s1=self.name+ "对"+emery.name+"发起攻击,"
s2="对"+emery.name+"造成"+str(emery.attack)+"的伤害,"
if emery.hp>0:
s3=emery.name+"的血量还有"+str(emery.hp)
s=s1+s2+s3
print(s)
else:
s4=emery.name+"的血量为0"
ss=s1+s2+s4
print(ss)
exit()
yase=Hero("亚瑟")
houyi=Hero("猴一")
houyi.diren(yase) #调用一次,攻击一次
houyi.diren(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