Commit 4a99c5f3 by BellCodeEditor

auto save

parent e9c6a3ba
Showing with 25 additions and 10 deletions
import random
class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.attack = 40
self.hp = 1000
self.attack = random.randint(1,1000)
self.max_hp = self.hp
def cure(self): # 治疗
self.hp=self.hp+88.8
self.hp=self.hp+random.randint(1,1000)
if self.max_hp>self.max_hp:
self.hp=self.max_hp
......@@ -30,8 +31,8 @@ class Hero(object):
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.attack = 50
self.hp = 10000
self.attack = random.randint(1,1000)
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
......@@ -39,7 +40,22 @@ class Player(Hero):
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
houyi.combat(yase)
yase.combat(houyi)
houyi.cure()
yase.cure()
\ No newline at end of file
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)")
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