Commit 58e50121 by BellCodeEditor

save project

parent 28fc7338
Showing with 24 additions and 2 deletions
import random
class Hero(object):
def __init__(self, name):
self.name = name
......@@ -35,6 +36,12 @@ class Player(Hero):
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self): # 治疗
hu=random.randint(20,60)
self.hp=self.hp+hu
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name+"使用了治疗,血量增加:",hu,",目前的血量为:",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
......@@ -42,4 +49,19 @@ print("_"*30)
print(" 战斗开始")
while True:
print("_"*30)
input("请选择英雄技能2(1攻击/2治疗)")
\ No newline at end of file
z=input("请选择英雄技能(1攻击/2治疗)")
if z=="p":
print("游戏结束")
break
elif z=="1":
houyi.combat(yase)
elif z=="2":
houyi.cure()
else:
print("请输入1或2")
continue
h=random.randint(1,3)
if h==1:
yase.combat(houyi)
else:
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