Commit 7abaca4c by BellCodeEditor

save project

parent 9a581ef4
Showing with 15 additions and 7 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
class Hero:
def __init__(self, name, attack):
self.level = 1
self.hp = 250
self.attack = 40
self.attack = attack
self.name = name
def combat(): # 攻击
???
def combat(self,ennemy):
print(self.name +'对'+ennemy.name+'造成'+str(self.attack)+'伤害')
if ennemy.hp > 0:
print(self.name +'造成'+str(self.attack)+'伤害')
print(ennemy.name + '还剩'+str(ennemy.hp))
else:
print(ennemy.name+'战败')
print(self.name+'获胜')
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase = Hero("垭瑟",40)
houyi= Hero("后羿",50)
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