Commit dbbce67a by BellCodeEditor

save project

parent 5f221c87
Showing with 24 additions and 10 deletions
class Hero:
def __init__(self,name,hp,attsck):
self.leven = 1
#英雄角色类
class Hero(object):
def __init__(self,name):
self.leven = 1
self.hp = 250
self.attsck = 40
self.name = name
self.hp = hp
self.attsck = attsck
yase = Hero("垭瑟",300,20)
houyi = Hero("后裔",240,22)
print("垭瑟的生命值:",yase.hp)
print("后裔的生命值:",houyi.hp)
\ No newline at end of file
def combat(self,enemy):
info1=self.name+"对"+enemy.name+"发起攻击,"
info2="造成"+str(self.attsck)+"点伤害,"
enemy.hp=enemy.hp-self.attsck
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)+"血量"
info=info1+info2+info3
print(info)
else :
info3=enemy.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
exit()
yase = Hero("垭瑟")
houyi = Hero("后裔")
yase.combat(houyi)
\ 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