Commit 1c81a873 by BellCodeEditor

auto save

parent 447c23f1
Showing with 15 additions and 14 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name,attack,hp):
self.level = 1 self.level = 1
self.hp = 250 self.hp = hp
self.attack = 40 self.attack = attack
self.name = name self.name = name
def combat(): # 攻击 def combat(self,enemy):
oo1=self.name+"对"+self.enemy+"发起进攻" enemy.hp-=self.attack # 攻击
oo1=self.name+"对"+enemy.name+"发起进攻"
oo2="造成"+str(self.attack)+"点伤害" oo2="造成"+str(self.attack)+"点伤害"
oo3=self.enemy+"还剩下"+str(self.hp)+"血量" oo3=enemy.name+"还剩下"+str(enemy.hp)+"血量"
oo=(oo1+oo2+oo3) oo=(oo1+oo2+oo3)
yase = Hero("垭瑟") if self.hp>0:
houyi= Hero("后羿") print(oo)
yase.combat("后羿") else:
print(oo1+oo2+self.enemy+"阵亡,"+"游戏结束")
if self.hp>0: yase = Hero("垭瑟",40,300)
print(oo) houyi= Hero("后羿",50,260)
else: yase.combat(houyi)
print(oo1+oo2+self.enemy+"阵亡,"+"游戏结束") \ No newline at end of file
\ 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