Commit e0c06c07 by BellCodeEditor

save project

parent bbdc5757
Showing with 20 additions and 14 deletions
class Hero:
def __init__(self,name,hp,attack):
def __init__(self,name):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
self.hp=250
self.attack=40
def ut(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
yase = Hero("yase",300,20)
houyi = Hero("houyi",240,23)
yase.ut()
print(yase.hp,houyi.hp)
\ No newline at end of file
def combat(self,enermy):
enermy.hp-=self.attack
infor1 = self.name + "对" + enermy.name + "发起攻击"
infor2 = "造成" + str(self.attack) + "点伤害"
if enermy.hp>0:
infor3 = enermy.name + "还剩下" + str(enermy.hp) + "点血量"
infor = infor1 + infor2 + infor3
print(infor)
else:
infor3 = enermy.name + "阵亡,游戏结束"
infor = infor1 + infor2 + infor3
print(infor)
exit()
yase=Hero("亚瑟")
houyi=Hero("后羿")
yase.combat(houyi)
\ 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