Commit 51ab0ec1 by BellCodeEditor

save project

parent 9a581ef4
Showing with 21 additions and 9 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
def __init__(self,a,s,d ):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
self.hp = a
self.act = s
self.name = d
def combat(): # 攻击
???
def combat(self,o):
o.hp -=self.act
info1 = self.name + "对" + o.name + "发起进攻"
info2 = "造成" + str(self.act) + "点伤害"
info3 = o.name + "还剩" + str(o.hp) + "点血"
info = info1 + info2 + info3
if o.hp > 0:
print(info)
else:
print(o.name + "G了")
yase = Hero(200,80,"垭瑟")
houyi= Hero(300,70,"后羿")
yase.combat(houyi)
houyi.combat(yase)
yase = Hero("垭瑟")
houyi= Hero("后羿")
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