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

bellcode / lesson15_1

  • 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
Switch branch/tag
  • lesson15_1
  • diy1.py
Find file
BlameHistoryPermalink
  • BellCodeEditor's avatar
    save project · 756da92a
    BellCodeEditor committed a year ago
    756da92a
diy1.py 682 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 英雄角色类
class Hero(object):   
    def __init__(self, name):
        self.level = 9999999999999999999999
        self.hp = 999998888777665
        self.attack = 999888777666555
        self.name = name
        
    def combat(self,enemy):    # 攻击
        enemy.hp -= self.attack
        info1 = self.name + '对' + enemy.name + '发起攻击,'
        info2 = '造成' + str(self.attack) + '真实伤害,'
        if enemy.hp < 0:
            info3 = enemy.name + '阵亡'
        else:
            info3 = enemy.name + '还剩下' + str(enemy.hp) + '点生命值'
        print(info1 + info2 + info3)


lubu = Hero("吕布")
houyi= Hero("后羿")
lubu.combat(houyi)