Commit 83c27edd by BellCodeEditor

save project

parent dfb5d1b6
Showing with 44 additions and 0 deletions
class Hero:
def __init__(self,name):
self.level=1
self.name =name
self.hp= 250
self.attack= 40 # attack:攻击
self.maxhp=self.hp
def combat(self,enemy):
info1=self.name+'攻击了'+enemy.name+'。'
info2=enemy.name+'受到了'+str(self.attack)+'点攻击。'
enemy.hp-=self.attack
if enemy.hp>0:
info3=enemy.name+'还剩'+str(enemy.hp)+'滴血。'
info=info1+info2+info3
print(info)
else:
info3=enemy+'阵亡了。'
info=info1+info2+info3
print(info)
exit()
def cure(self):
self.hp=self.hp+60
if self.hp>self.maxhp:
self.hp=self.maxhp
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=190
self.attack=70
self.maxhp=self.hp
print('角色'+self.name+'创建成功,英雄类型为:',self.hero_tape)
print('当前等级,血量,攻击力为:',self.level,self.hp,self.att)
player=Player('后羿')
#print(player.attack)
#print(player.hp)
yase = Hero('亚瑟')
houyi = Hero('后羿')
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