Commit 7401c108 by BellCodeEditor

save project

parent 8438c271
Showing with 26 additions and 14 deletions
class hero:
def __init__(self,name,hp,attack):
class hero(object):
def __init__(self,name):
self.level=1
self.hp=name
self.attack=attack
self.hp=3500
self.attack=388
self.name=name
def upgrade():
yase.level=yase.level+1
yase.hp=yase.hp+50
yase.attack=yase.attack+4
def combat(self,enemy):
enemy.hp -= self.attack
info1=self.name+'对'+enemy.name+'发起伤害,'
info2='造成'+str(self.attack)+'真实伤害,'
if enemy.hp<0:
info3=enemy.name+'阵亡'
else:
info3=enemy.name+'还剩下'+str(enemy.hp)+'点生命值'
print(info1+info2+info3)
yase=Hero("垭瑟",300,20)
print("垭瑟的初始血量值为:"yase.hp)
upgrade()
upgrade()
print("升级2次后,垭瑟的血量值为:"yase.hp)
\ No newline at end of file
class player(help):
def_init_(self,Name,help_type):
self.hp=200
self.attack=50
self.help_type=help_type
print("角色"+self.name+"创建成功,英雄类型为:",self.hero_type)
print("当前等级血量攻击力分别为"self.level,self.hp,self.attack)
yase=Hero("垭瑟")
houyi=Hero("后羿")
yase.combat(houyi)
print("玩家的血量值为"player.hp)
print("玩家的血量值为"player.attack)
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