Commit b12ceaa5 by BellCodeEditor

auto save

parent e2845e28
Showing with 6 additions and 5 deletions
...@@ -9,7 +9,7 @@ class Hero(object): ...@@ -9,7 +9,7 @@ class Hero(object):
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
i1=print(self.name+'对'+enemy.name+'发起攻击') i1=print(self.name+'对'+enemy.name+'发起攻击')
i2=print('造成'+str(self.attack)) i2=print('造成'+str(self.attack))
enemy.hp-=attack enemy.hp-=self.attack
if enemy.hp>0: if enemy.hp>0:
i3=print(enemy.name+'的血量还剩'+str(enemy.hp)) i3=print(enemy.name+'的血量还剩'+str(enemy.hp))
print(i1+i2+i3) print(i1+i2+i3)
...@@ -17,17 +17,17 @@ class Hero(object): ...@@ -17,17 +17,17 @@ class Hero(object):
i3=enemy.name+'已经阵亡,游戏结束!' i3=enemy.name+'已经阵亡,游戏结束!'
self.hp-=self.attack self.hp-=self.attack
class Player(Hero): class Player(Hero):
def__init__(self,name): def __init__(self,name):
self.level = 1 super().__init__(name)
self.hp = 200 self.hp = 200
self.attack = 50 self.attack = 50
self.name = name
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Player("后羿")
yase.combat(houyi) yase.combat(houyi)
print(houyi.hp) print(houyi.hp)
\ 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