Commit b9ccbcb5 by BellCodeEditor

save project

parent 69c31b6e
Showing with 23 additions and 8 deletions
......@@ -4,12 +4,27 @@ class Hero:
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+10
self.attack=self.attack+5
yase=Hero('垭瑟',300,20)
yase.upgrade()
# def upgrade(self):
# self.level=self.level+1
# self.hp=self.hp+10
# self.attack=self.attack+5
# yase=Hero('垭瑟',300,20)
# yase.upgrade()
# houyi=Hero('后羿',250,23)
print(yase.level)
# print(yase.level)
def combat(self,enemy):
enemy.hp-=self.attack
ifo1=self.name+'对'+enemy.name+'发起进攻造成',self.attack,'点伤害'
if enemy.hp>0:
ifo3=enemy.name+'还剩',enemy.hp,'血量'
ifo=ifo1+ifo3
print(ifo)
else:
ifo4=enemy.name+'阵亡,游戏结束'
ifo=ifo1+ifo4
pritn(ifo)
exit()
yase=Hero('垭瑟',300,20)
houyi=Hero('后羿',250,23)
Hero.combat(yase,houyi)
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