Commit b6a433de by BellCodeEditor

save project

parent 379e9f74
Showing with 22 additions and 23 deletions
class Hero: # 英雄
def __init__(self, name): # 实例属性
self.name = name
# 英雄角色
class Hero():
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.max_hp = self.hp
self.name = name
def combat(self, enemy): # 攻击功能
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
def combat(A,B): # 攻击
B.hp=B.hp-A.attack
print(A.name+"对"+B.name+"发起进攻,造成"+str(A.attack)+"伤害,")
if B.hp>0:
print(B.name+"还剩下"+str(B.hp)+"点血")
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
print(B.name+"被"+A.name+"击败")
exit()
class Player(): # 玩家英雄
def __init__(self,name):
???
yase = Hero("垭瑟")
houyi= Hero("后羿")
class.player(Hero):
def __init__(self, name):
super().__init__(level,name)
self.hp = 100
self.attack = 400
player = Player("后羿")
print("玩家的血量值为:",player.hp)
computer = Hero("亚瑟")
print("玩家的血量为:",player.hp)
print("玩家的等级为:",player.level)
print("玩家的攻击力为:",player.attack)
print("玩家的名称为:",player.name)
\ 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