Commit f75b33b2 by BellCodeEditor

save project

parent 6f0a747b
Showing with 22 additions and 15 deletions
......@@ -4,19 +4,26 @@ class Hero:
self.hp=hp
self.attck=attck
self.level=1
def upgrade(self):
self.level+=1
self.hp+=50
self.attck+=90
a=Hero("a",25000,950)
a.upgrade()
print(a.level)
print(a.hp)
print(a.attck)
b=Hero('b',40000,1000)
b.upgrade()
print(a.level)
print(a.hp)
print(a.attck)
\ No newline at end of file
def combat(self,enemy):
enemy.hp-=self.attck
info1=self.name+'对'+enemy.name+'进行攻击'
info2='造成了'+str(self.attck)+'点伤害'
if enemy.hp>0:
info3=enemy.name+'还剩'+str(enemy.hp)+'点血'
info=info1+info2+info3
print(info)
else:
info3=enemy.name+'卒,结束'
info=info1+info2+info3
print(info)
exit()
# def upgrade(self):
# self.level+=1
# self.hp+=50
# self.attck+=90
a = Hero('后羿',200,24)
b = Hero('亚瑟',240,20)
a.combat(b)
\ 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