Commit e0c06c07 by BellCodeEditor

save project

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