Commit be14e44d by BellCodeEditor

auto save

parent 9a581ef4
Showing with 22 additions and 8 deletions
...@@ -4,11 +4,25 @@ class Hero(object): ...@@ -4,11 +4,25 @@ class Hero(object):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击
???
yase = Hero("垭瑟") def combat(self,enemy): # 攻击
houyi= Hero("后羿") enemy.hp -= self.attack
yase.combat(houyi) info1=self.name+"对"+enemy.name+"发起进攻,"
\ No newline at end of file info2="造成"+str(self.attack)+"点伤害,"
if enemy.hp>0:
info3=enemy.name+"还剩"+str(enemy.hp)+"点血量"
print(info1+info2+info3)
else:
info3=enemy.name+"阵亡,游戏结束"
print(info1+info2+info3)
exit()
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp=200
self.attack=50
houyi= Player("后羿")
print("你的狗命是:",houyi.hp)
print("你的手无腹肌之力是:",houyi.attack)
\ 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