Commit b1415d9e by BellCodeEditor

auto save

parent dffb9f8f
Showing with 34 additions and 12 deletions
class Hero:
def __init__(self,name,level,hp,attack):
def __init__(self,name):-
self.name=name
self.level=level
self.hp=hp
self.attack=attack
def ungrade(self):
self.level+=1
self.hp+=50
self.attack+=40
yase=Hero('亚瑟',1,300,240)
yase.ungrade()
print(yase.hp)
\ No newline at end of file
self.level=1
self.hp=300
self.attack=40
#def ungrade(self):
#self.level+=1
#self.hp+=50
#self.attack+=40
def combot(self,enemy) :
enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+"发起进攻"
info2="造成"+str(self.attack)+"的伤害"
if enemy.hp>0:
info3="剩下的血量为"+str(enemy.hp)
info=info1+info2+info3
print(info)
else:
info3=self.name+"已经阵亡"
info=info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name,hero_type):
super(Player,self).__init__(name)
self.hp=260
self.attack=50
self.hero_type=hero_type
print("角色为"+self.name+"已成功")
print("角色"+self.name+"的等级,血量,攻击力"+str(self.level)+str(self.hp)+str(self.attack))
houyi=Player("后羿","射手")
# yase.ungrade()
# print(yase.hp)
\ 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