Commit e7ad154a by BellCodeEditor

save project

parent 69b55c19
Showing with 19 additions and 0 deletions
...@@ -12,6 +12,7 @@ class Hero(object): ...@@ -12,6 +12,7 @@ class Hero(object):
def upgrate(self): def upgrate(self):
self.gp -= self.max_gp self.gp -= self.max_gp
self.level += 1
self.max_gp = self.level*100 self.max_gp = self.level*100
self.attack *= 1.2 self.attack *= 1.2
self.max_hp *= 1.2 self.max_hp *= 1.2
...@@ -57,6 +58,24 @@ class Player(Hero): ...@@ -57,6 +58,24 @@ class Player(Hero):
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type) print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack) print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
self.gp += 20
print('经验:'+str(self.gp),'/',str(self.max_gp))
if self.gp >= self.max_gp:
self.upgrate()
self.hp = self.max_hp
def cure(self): # 治疗 def cure(self): # 治疗
z = random.randint(35,60) z = random.randint(35,60)
if self.hp + z > self.max_hp: if self.hp + z > self.max_hp:
......
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