Commit 1c81a873 by BellCodeEditor

auto save

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