Commit 6177298b by BellCodeEditor

save project

parent 9a581ef4
Showing with 29 additions and 8 deletions
......@@ -2,13 +2,35 @@
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.hp = 250000
self.attack = 40000
self.name = name
self.max_hp=self.hp
def combat(): # 攻击
???
def combat(self,enemy):
info1=self.name+'给了'+enemy.name+'一巴掌,'
info2='给'+enemy.name+'造成'+str(self.attack)+'点血流失,'
enemy.hp-=self.attack
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
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 Player(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=300000
self.attack=20000
self.hero_type=hero_type
print('角色'+self.name+'创建成功,属性为:',self.hero_type)
print('当前属性为:等级'+str(self.level)+'血量'+str(self.hp)+'攻击'+str(self.attack))
houyi=Player('后羿','射手')
yase=Hero('垭瑟')
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