Commit 8daa4c3e by BellCodeEditor

save project

parent 0d877884
Showing with 9 additions and 32 deletions
import random
class Hero:
class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
......@@ -8,12 +7,12 @@ class Hero:
self.max_hp = self.hp
def cure(self): # 治疗
c=random.randint(30,60)
self.hp+=c
self.hp+=60
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",c ,",目前的血量为:",self.hp)
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
......@@ -40,29 +39,7 @@ class Player(Hero):
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print("-"*50,'\n',' 战斗开始!','\n','-'*50)
while True:
a=input("请选择要使用的技能,1攻击/2治疗 按Q退出游戏~")
if a=="Q":
exit()
elif a=='1':
houyi.combat(yase)
elif a=='2':
houyi.cure()
else:
print("请重新输入!")
continue
b=random.randint(1,2)
if b==1:
yase.combat(houyi)
if b==2:
yase.cure()
#print("$"*50)
#
# yase.combat(houyi)
# houyi.cure()
# yase.cure()
\ No newline at end of file
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