Commit fc170d33 by BellCodeEditor

save project

parent 57ff3276
Showing with 8 additions and 7 deletions
......@@ -13,15 +13,15 @@ class Hero(object):
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
info1 = self.name+"攻击"+enemy.name#+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info3 = enemy.name+"死亡,\nGAME OVER"
info = info1+info2+info3
print(info)
exit()
......@@ -39,20 +39,20 @@ class Player(Hero):
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print('*'*30)
print(" 战斗开始")
print(" START!!!")
i=0
import random
while True:
print('*'*30)
i=i+1
choice=input('Start(1=attact,2=cure):')
choice=input('Start(1=compat,2=cure):')
if choice=='1' or choice=='2' or choice=='q':
if choice=='1':
houyi.combat(yase)
if choice=='2':
houyi.cure()
if choice=='q':
print('Game Over')
print('GAME OVER')
break
else:
print("Error,please try it again")
......@@ -60,7 +60,7 @@ while True:
print('PLEASE READ CAREFULLY')
continue
num=random.randint(1,4)
if num=1:
if num==1 :
yase.cure()
else:
yase.combat(houyi)
\ 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