Commit d36497e2 by BellCodeEditor

save project

parent 20aa9324
Showing with 8 additions and 0 deletions
......@@ -4,6 +4,7 @@ class Hero:
self.hp=250
self.attack=30
self.name=name
self.maxhp=self.hp
def combat(self,enemy):
enemy.hp-=self.attack
info1=self.name+'对'+enemy.name+'发起攻击,'
......@@ -16,6 +17,11 @@ class Hero:
info3=enemy.name+'阵亡,游戏结束'
info=info1+info2+info3
print(info)
def cure(self):
self.hp+=60
if self.hp>self.maxhp:
self.hp=self.maxhp
print(self.name+'使用了治疗,血量增加:',60,',目前的血量为:',self.hp)
class Player(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
......@@ -27,5 +33,6 @@ class Player(Hero):
yase=Hero('亚瑟')
houyi=Player('后羿','射手')
yase.combat(houyi)
houyi.cure()
print(houyi.hp)
print(yase.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