Commit 69d866ce by BellCodeEditor

auto save

parent 63f5acad
Showing with 69 additions and 9 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name):
self.level = 1 self.level = 1
self.name = name self.name =name
self.hp = hp self.hp =2500
self.attack = attack self.attack = 50
#def upgrade():
# yase.level = yase.level+1
# yase.hp = yase.hp+50
# yase.attack = yase.attack+4
#upgrade()
#print(yase.hp)
def combat(self,enemy):
enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+"发起攻击,"
info2="造成"+str(self.attack)+"点伤害,"
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()
class Plarer(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=200
self.attack=50
self.hero_type=hero_type
print("角色"+houyi.name+"创建成功,英雄类型为:",houyi.hero_type)
print("当前等级,血量,攻击力分别为:",houyi.level,houyi.hp,houyi.attack)
houyi=Plarer("后羿","射手")
yase=Hero("亚瑟")
yase = Hero("海绵宝宝",250,99)
houyi = Hero("杰哥",1,300)
print("海绵宝宝滴血量为:",yase.hp)
print("杰哥滴血量为:",houyi.hp)
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level = 1
self.name =name
self.hp =2500
self.attack = 50
#def upgrade():
# yase.level = yase.level+1
# yase.hp = yase.hp+50
# yase.attack = yase.attack+4
#upgrade()
#print(yase.hp)
def combat(self,enemy):
enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+"发起攻击,"
info2="造成"+str(self.attack)+"点伤害,"
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()
class Plarer(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=200
self.attack=50
self.hero_type=hero_type
print("角色"+houyi.name+"创建成功,英雄类型为:",houyi.hero_type)
print("当前等级,血量,攻击力分别为:",houyi.level,houyi.hp,houyi.attack)
houyi=Plarer("后羿","射手")
yase=Hero("亚瑟")
\ 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