Commit 99cac010 by BellCodeEditor

auto save

parent fa91dcc7
Showing with 20 additions and 18 deletions
class hero:
def __init__(self,name,level,hp,attack):
self.level=level
self.hp=hp
self.attack=attack
def __init__(self,name):
self.level=1
self.hp=250
self.attack=40
self.name=name
LuBan=hero('鲁班',1,2500,230)
HouYi=hero('后羿',1,3000,180)
def combat(self):
print(LuBan.name)
print(LuBan.level)
print(LuBan.hp)
print(LuBan.attack)
print(LuBan.name)
print(LuBan.level)
print(LuBan.hp)
print(LuBan.attack)
def combat(self,a):
a.hp-=self.attack
x0=a.name+'已阵亡,Game over'
x1=self.name+'使用了攻击技能,'
x2='使'+a.name+'受到了'+str(self.attack)+'点伤害,'
x3=a.name+'的血量还剩'+str(a.hp)+'点'
if a.hp>0:
y1=x1+x2+x3
print(y1)
else:
y2=x1+x2+x3
print(y2)
LuBan=hero('鲁班')
HouYi=hero('后羿')
HouYi.combat(LuBan)
\ 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