Commit b7238cd0 by BellCodeEditor

auto save

parent 9a581ef4
Showing with 31 additions and 12 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
class Hero():
def __init__(self,name,hp,level,attack):
self.level = level
self.hp = hp
self.attack = attack
self.name = name
def combat(): # 攻击
???
def upgrade(self):
self.level=self.level+28
self.hp=self.hp+5000
self.attack=self.attack+100
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
def combat(self,enermy):
enermy.hp -= self.attack
if enermy.hp > 0:
info1 = self.name+"揍了"+enermy.name+"亿拳\n"
info2 = enermy.name+"血量降低了"+str(self.attack)+"\n"
info3 = enermy.name+"还剩"+str(enermy.hp)+"点的血量\n"
print(info1+info2+info3)
else:
info1 = self.name+"揍了"+enermy.name+"亿拳\n"
info2 = enermy.name+"血量降低了"+str(self.attack)+"\n"
info3 = enermy.name+"还剩"+str(enermy.hp)+"点的血量\n"
print(info1+info2+info3)
print(enermy.name+"屎了")
apiao = Hero("阿飘",1000,2,500)
abiao = Hero("阿膘",900,1.5,450)
amiao = Hero("阿喵",1200,3.5,600)
apiao.combat(amiao)
apiao.combat(amiao)
apiao.combat(amiao)
\ 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