Commit e7131ba8 by BellCodeEditor

save project

parent 003f95d3
Showing with 7 additions and 0 deletions
...@@ -25,6 +25,10 @@ class Hero(object): ...@@ -25,6 +25,10 @@ class Hero(object):
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
exit() exit()
def cheat(self):
self.max_hp=500
self.hp=self.max_hp
print(self.name+"使用了秘密武器,血量上限提升至"+self.max_hp+"并回满血量")
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
...@@ -36,6 +40,7 @@ class Player(Hero): ...@@ -36,6 +40,7 @@ class Player(Hero):
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type) print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack) print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
import random import random
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
...@@ -51,6 +56,8 @@ while True: ...@@ -51,6 +56,8 @@ while True:
elif choice=="q": elif choice=="q":
print("退出游戏") print("退出游戏")
exit() exit()
elif choice=="I want to cheat":
houyi.cheat()
else: else:
print("请重新输入") print("请重新输入")
continue continue
......
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