Commit 26c191f8 by BellCodeEditor

save project

parent 71ad00ac
Showing with 28 additions and 4 deletions
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
\ No newline at end of file
class Hero():
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
\ No newline at end of file
...@@ -5,6 +5,7 @@ class Hero(object): ...@@ -5,6 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(self,a): # 攻击 def combat(self,a): # 攻击
a.hp = a.hp-self.attack a.hp = a.hp-self.attack
...@@ -16,7 +17,17 @@ class Hero(object): ...@@ -16,7 +17,17 @@ class Hero(object):
info2 = '对'+a.name+'造成'+str(self.attack)+'点伤害' info2 = '对'+a.name+'造成'+str(self.attack)+'点伤害'
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
class Player(Hero):
yase = Hero("垭瑟") def __init__(self, name,hp,attack,level,type):
super().__init__(name)
self.hp = hp
self.attack = attack
self.type = type
self.level = level
print('英雄创建成功','姓名:',self.name,' ','血量:',self.hp,' ','攻击:',self.attack,' ','等级:',self.level,' ','职业:',type)
tt = Hero("tt")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) wjh = Player('王锦辉',333,333,333,'刺客')
\ No newline at end of file wjh.combat(tt)
wjh.combat(tt)
wjh.combat(tt)
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