Commit bbf4fac0 by BellCodeEditor

save project

parent 2c3eaa58
Showing with 13 additions and 3 deletions
......@@ -6,9 +6,9 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(self,enemy1,enemy2): # 攻击
def combat(self,enemy): # 攻击
enemy.hp -= self.attack
info1 = self.name +'对'+enemy1.name+'`'+enemy2.name+'发起攻击'
info1 = self.name +'对'+enemy.name+'发起攻击'
info2 = '造成' + str(self.attack)+'点伤害,'
if enemy.hp > 0:
info3 = '还剩下'+str(self.hp)+'点血量,可以战斗到底!!'
......@@ -19,6 +19,15 @@ class Hero(object):
info = info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp = 200
self.attack = 40
self.hero_type= hero_type
print(self.name,'1',self.hero_type)
print('1',self.level ,self.hp ,self.attack)
yase = Hero("垭瑟")
houyi= Hero("后羿")
houyi= Player("后羿")
yase.combat(houyi)
houyi.combat(yase)
\ 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