Commit e52a6835 by BellCodeEditor

save project

parent 098d939c
Showing with 15 additions and 4 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 999
self.hp = 250 self.hp = 25000
self.attack = 40 self.attack = 20000
self.name = name self.name = name
def combat(self,d): # 攻击 def combat(self,d): # 攻击
...@@ -12,7 +12,17 @@ class Hero(object): ...@@ -12,7 +12,17 @@ class Hero(object):
print(d.name,'被',self.name,'减少',self.attack,'血','还剩',d.hp) print(d.name,'被',self.name,'减少',self.attack,'血','还剩',d.hp)
else: else:
print(d.name,'死亡,游戏结束了') print(d.name,'死亡,游戏结束了')
def combat(self,d):
d.attack=100
d.hp=200000
d.name=d
d.level= 999
def combat(self,d):
self.hp -= d.attack
if self.hp>0:
print(self.name,'被',d.name,'减少',d.attack,'血','还剩',self.hp)
else:
print(self.name,'死亡,游戏结束了')
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) yase.combat(houyi)
\ 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