Commit 6e8d76f7 by BellCodeEditor

save project

parent 7bd75261
Showing with 19 additions and 13 deletions
......@@ -5,16 +5,21 @@ class hero:
self.hp=hp
self.attack=attack
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+9999
self.attack=self.attack+9999
houyi=hero("后羿",240,23)
houyi.upgrade()
print(houyi.level)
print(houyi.hp)
print(houyi.attack)
# def upgrade(self):
# self.level=self.level+1
# self.hp=self.hp+9999
# self.attack=self.attack+9999
def combat(self,enemy):
enemy.hp-=self.attack
ifor1=self.name+"对"+enemy.name+"发动了攻击,"
ifor2="造成了"+str(self.attack)+"点伤害,"
if enemy.hp>0:
ifor3=enemy.name+"还剩下"+str(enemy.hp)+"点血"
print(ifor1+ifor2+ifor3)
else:
ifor3=enemy.name+"已阵亡,游戏结束"
print(ifor1+ifor2+ifor3)
exit()
yase=hero("垭瑟",250,40)
houyi=hero("后羿",240,45)
hero.combat(yase,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