Commit ad680642 by BellCodeEditor

save project

parent 4a99c5f3
Showing with 10 additions and 25 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 1000 self.hp = 250
self.attack = random.randint(1,1000) self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp=self.hp+random.randint(1,1000) self.hp=self.hp+88.8
if self.max_hp>self.max_hp: if self.max_hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
...@@ -31,8 +30,8 @@ class Hero(object): ...@@ -31,8 +30,8 @@ class Hero(object):
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
self.hp = 10000 self.hp = 200
self.attack = random.randint(1,1000) self.attack = 50
self.max_hp = self.hp self.max_hp = self.hp
self.hero_type = hero_type self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type) print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
...@@ -40,22 +39,7 @@ class Player(Hero): ...@@ -40,22 +39,7 @@ class Player(Hero):
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
print("-"*50) houyi.combat(yase)
print(" 战斗开始") yase.combat(houyi)
houyi.cure()
while True: yase.cure()
print("-"*50) \ No newline at end of file
choice=input("请选择(1攻击/2治疗/3逃跑):")
if choice =="3":
print("玩家帅气的离去了")
exit()
elif choice=="1":
houyi
elif choice=="2":
else:
print("请输入(1/2/3)")
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