Commit e3b907cf by BellCodeEditor

save project

parent d1b1c6eb
Showing with 10 additions and 27 deletions
class Hero: nema="刘强"
def __init__(self,name): power=66
self.level = 1 hero=['赵一',30,'丁二'37,'孙五',52,'王猛',89,'周亮',98]
self.hp = 240 for i in range(len(hero)):
self.attack = 40 if i%2==1 and hero[i]>=power:
self.name = name hero.insert(i-1,nema)
def combat(self, enemy): hero.insert(i,power)
info1 = self.name+"对"+enemy.name+"发起进攻," break
info2 = "造成"+str(self.attack)+"点伤害," print(hero)
enemy.hp -= self.attack \ No newline at end of file
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1=info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name,hero_type):
self(Player,self).__init__(name)
self.hp = 200
self.attack = 50
self.hero_type = hero_type
print("角色"+self.name+"创造成功,英雄类型为:",self.hero_type)
print("当前等级血量、攻击力为:",self.level,self.hp,self.attack)
houyi = Player("后一","射手")
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