Commit bbf4fac0 by BellCodeEditor

save project

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