Commit ad680642 by BellCodeEditor

save project

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