Commit b949dcfc by BellCodeEditor

auto save

parent f47689a4
Showing with 2000 additions and 0 deletions
class Hero:
def __init__(self,hp,level,name,attack):
self.hp=hp
self.level=level
self.name=name
self.attack=attack
print(self.name+"的血量为"+str(self.hp)+",等级为"+str(self.level)
+",攻击力为"+str(self.attack))
# 升级
def upgrant(self):
self.level+=1
self.hp+=5
# 攻击
def combat(self,enemy):
enemy.hp-=self.attack
info="*"*55+"\n"+self.name+"对"+enemy.name+"发起攻击,"+"造成"+str(self.attack)+"伤害,"+enemy.name+"还剩下"+str(enemy.hp)+"血量\n"+"*"*55
print(info)
yase=Hero(30,1,"亚瑟",10)
houyi=Hero(50,5,"后裔",5)
yase.upgrant()
#发起攻击
yase.combat(houyi)
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