Commit dca641d7 by BellCodeEditor

save project

parent ccb66f5e
Showing with 10 additions and 3 deletions
import random
class Hero(object):
def __init__(self, name):
self.name = name
......@@ -8,7 +9,7 @@ class Hero(object):
def cure(self): # 治疗
self.hp+=60
if self.hp>self.max_hp
if self.hp>self.max_hp:
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
......@@ -39,7 +40,7 @@ houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print("-"*30)
print(" 战斗开始")
while True:
while True:
print("-"*30)
choice=input("请选择释放英雄技能(1攻击/2治疗):")
......@@ -54,7 +55,13 @@ print(" 战斗开始")
print("请重新输入1或2")
continue
num=randow.randint(1,3)
if num=="1"
if num=="1":
yase.cure()
else:
yase.combat(houyi)
def cure(self):
blood=random.randint(30,50)
self.hp=self.hp+blood
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",blood,",目前的血量为:",self.hp)
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