Commit b697fe2a by BellCodeEditor

save project

parent 2fd062ee
Showing with 16 additions and 3 deletions
......@@ -2,12 +2,25 @@
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.hp = 10
self.attack = 40
self.name = name
def combat(): # 攻击
self.name =name
def combat(self,enemy): # 攻击
enemy.hp=enemy.hp-self.attack
info1 =self.name+"对"+enemy.name+"攻击"
#受到了多少伤害
info2 ="所带来的伤害"+str(self.attack)+""
#剩余多少血量
if enemy.hp>0:
info3 ="剩余"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3="已阵亡"
info = info1+info2+info3
print(info)
yase = Hero("垭瑟")
houyi= Hero("后羿")
......
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