Commit 2617966b by BellCodeEditor

save project

parent 9a581ef4
Showing with 21 additions and 9 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 90
self.hp = 250 self.hp = 32800
self.attack = 40 self.atk = 1875
self.name = name self.name = name
def combat(): # 攻击 def combat(self,enemy): # 攻击
???
info1 = self.name+"hit"+enemy.name
info2 = ","+str(self.atk)
enemy.hp -= self.atk
if enemy.hp > 0:
info3 = "/"+str(enemy.hp)
info=info1+info2+info3
print(info)
else:
info3 = enemy.name+"died"
info=info1+info2+info3
print(info)
exit()
yase = Hero("垭瑟") a= Hero("hutao")
houyi= Hero("后羿") b= Hero("darkdarkdeepya")
yase.combat(houyi) a.combat(b)
\ No newline at end of file \ 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