Commit cfa5a7e3 by BellCodeEditor

auto save

parent 9a581ef4
Showing with 22 additions and 6 deletions
......@@ -6,9 +6,26 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+'发起进攻'
info2='造成了'+str(self.attack)+'点伤害'
if enemy.hp>0:
info3=enemy.name+'剩余血量为'+str(enemy.hp)
info=info1+info3+info3
print(info)
else:
info3=enemy.name+'已经阵亡'
info=info1+info3+info3
print(info)
exit()
class Player(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=200
self.attack=50
self.hero_type=hero_type
print('创建了一个新的英雄,英雄类型为:'+hero_type)
print('英雄'+self.name+"等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
i=Player('后裔','射手')
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