Commit a1a1a342 by BellCodeEditor

save project

parent ad5dee88
Showing with 26 additions and 11 deletions
import random
class Hero: class Hero:
def __init__(self, name,herotype): def __init__(self, name,herotype):
self.name = name self.name = name
...@@ -28,20 +30,32 @@ class Hero: ...@@ -28,20 +30,32 @@ class Hero:
print(info) print(info)
exit() exit()
class Player(Hero): class Player(Hero):
def __init__() def __init__(self,name,herotype):
super().__init__(name,herotype)
self.hp = 200
self.attack = 80
self.max_hp = self.hp
print("英雄:"+self.name+"创建成功,"+"\n英雄类型:"+self.herotype+"\n攻击力:"+str(self.attack))
yase = Hero("亚瑟","坦克") yase = Hero("亚瑟","坦克")
houyi = Hero("后羿","射手") houyi = Player("后羿","射手")
print("-"*30) print("-"*30)
print(" 战斗开始") print(" 战斗开始")
print("-"*30) print("-"*30)
while True: while True:
satute = int(input("请选择英雄技能(1攻击/2治疗):")) satute = input("请选择英雄技能(1攻击/2治疗):")
if satute == 1: if satute == "q":
print("用户选择退出")
if satute == 2: break
elif satute == "1":
houyi.combat(yase)
elif satute == "2":
houyi.cure()
else:
print("请输入正确指令")
continue
computer = random.randint(1,3)
if computer == 1 or 2:
yase.combat(houyi)
elif computer == 3:
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