Commit a981df24 by BellCodeEditor

auto save

parent d4435586
Showing with 30 additions and 10 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name,hp, attack):
self.level = 1 self.hp = hp
self.hp = 250 self.attack = attack
self.attack = 40
self.name = name self.name = name
def combat(self,df): # 攻击 def combat(self,df): # 攻击
df.hp-=self.attack df.hp-=self.attack
a=self.name+'攻击'+df.name a=seif.name+"对"+df.name+"发起攻击"
b=df.name+'受到了'+str(self.attack)+'伤害' b="造成了"+str(self.attack)+"点伤害"
if df.hp>0: if df.hp>0 :
c=df.name+'还剩'+str(df.hp)+'滴血' c=df.name+"还剩下"+str(df.hp)+"滴血"
print(a+b+c) print(a+b+c)
else: else:
c=df.name+'已阵亡' c=df.name+"已玩完"
print(a+b+c) print(a+b+c)
exit() exit()
def comat(self,df): # 攻击
df.hp-=self.attack
a=seif.name+"对"+df.name+"发起攻击"
b="造成了"+str(self.attack)+"点伤害"
if df.hp>0 :
c=df.name+"还剩下"+str(df.hp)+"滴血"
print(a+b+c)
else:
c=df.name+"已玩完"
print(a+b+c)
exit()
ys=Hero("雅说",240,230)
hi=Hero("后一",260,210)
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