Commit 64d869b3 by BellCodeEditor

save project

parent 9a581ef4
Showing with 23 additions and 9 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self,name,hp,g):
self.level = 1 self.level = 1
self.hp = 250 self.hp = hp
self.attack = 40 self.attack = g
self.name = name self.name = name
# 垭瑟 对 后羿 发起攻击 造成 20 点伤害 后羿 还剩下 200 血量
def combat(self,en): # 攻击
en.hp=en.hp-self.hp
no1=self.name+"对"+en.name+"发起攻击"
no2="造成"+str(self.attack)+"点伤害"
if en.hp>0:
no3=en.name+"还剩下"+str(en.hp)+"血量"
no=no1+no2+no3
print(no)
else:
no3=en.name+"阵亡,游戏结束"
no=no1+no2+no3
print(no)
exit()
def combat(): # 攻击
???
yase = Hero("垭瑟") yase = Hero("垭瑟",500,20)
houyi= Hero("后羿") houyi= Hero("后羿",700,40)
yase.combat(houyi) for i in range(6):
\ No newline at end of file yase.combat(houyi)
houyi.combat(yase)
\ 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