Commit 7401c108 by BellCodeEditor

save project

parent 8438c271
Showing with 26 additions and 14 deletions
class hero: class hero(object):
def __init__(self,name,hp,attack): def __init__(self,name):
self.level=1 self.level=1
self.hp=name self.hp=3500
self.attack=attack self.attack=388
self.name=name
def upgrade(): def combat(self,enemy):
yase.level=yase.level+1 enemy.hp -= self.attack
yase.hp=yase.hp+50 info1=self.name+'对'+enemy.name+'发起伤害,'
yase.attack=yase.attack+4 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) class player(help):
print("垭瑟的初始血量值为:"yase.hp) def_init_(self,Name,help_type):
upgrade() self.hp=200
upgrade() self.attack=50
print("升级2次后,垭瑟的血量值为:"yase.hp) self.help_type=help_type
\ No newline at end of file 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