Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / lesson16_4

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit e7ad154a authored 4 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 69b55c19
Hide whitespace changes
Inline Side-by-side
Showing with 19 additions and 0 deletions
  • diy1.py
diy1.py
View file @ e7ad154a
......@@ -12,6 +12,7 @@ class Hero(object):
def upgrate(self):
self.gp -= self.max_gp
self.level += 1
self.max_gp = self.level*100
self.attack *= 1.2
self.max_hp *= 1.2
......@@ -57,6 +58,24 @@ class Player(Hero):
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
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): # 治疗
z = random.randint(35,60)
if self.hp + z > self.max_hp:
......
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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