Commit b4e599c4 by BellCodeEditor

auto save

parent dfb5d1b6
Showing with 31 additions and 0 deletions
# 英雄角色类
class Hero():
def __init__(self,name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
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:
print(B.name+"被"+A.name+"击败")
exit()
yase = Hero("垭瑟")
houyi= Hero("后羿")
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.hp = 100
self.attack = 400
player = Player("后羿")
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