Commit 69f2c0be by BellCodeEditor

save project

parent 76909f14
Showing with 21 additions and 10 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self,name,hp,attack,profession):
self.level = 1 self.level=1
self.hp = 250 self.name=name
self.attack = 40 self.hp=hp
self.name = name self.attack=attack
self.profession=profession
def combat(): # 攻击 def combat(self,enemy): # 攻击
??? info1 = self.name+"对"+enemy.name+"发起攻击"
info2 = "造成"+str(self.attack)+"点伤害"
yase = Hero("垭瑟") enemy.hp = enemy.hp-self.attack
houyi= Hero("后羿") if enemy.hp>0:
info3=enemy.name+"剩余血量为"+str(enemy.hp)
info=info1+info2+info3
print(info)
exit()
yase=Hero("亚瑟",300,20,"战士")
houyi=Hero("后羿",240,23,"射手")
libai=Hero("李白",250,50,"刺客")
zhugeliang=Hero("诸葛亮",210,70,"法师")
yao=Hero("瑶",270,15,"辅助")
yase.combat(houyi) 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