马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 飞天大猫 于 2020-2-23 21:28 编辑 player = input("请输入玩家名字,按回车后开始游戏 \n")
print("欢迎" +"【" + player + "】" +"进入冒险!")
def restart():
restart = input("是否重新开始游戏 \n 1.重新开始 \n 2.退出游戏")
while restart:
if int(restart) == 1:
print("【" + player + "】,请拿好你的剑,重装出击!!!")
game_start()
elif int(restart) == 2:
break
else:
print("输入有误,请重新输入")
def game_start():
import time,random
player_life = random.randint(350,450)
player_attack = random.randint(15,30)
enemy_life = random.randint(100,150)
enemy_attack = random.randint(10,20)
count = 1
print("【" + player + "】" + " 血量:" + str(player_life) + ";攻击:" + str(player_attack))
time.sleep(1.5)
time.sleep(1)
print("敌军即将到达战场")
time.sleep(1.5)
print("【敌军】" + " 血量:" + str(enemy_life) + ";攻击:" + str(enemy_attack))
time.sleep(1)
print("即将进入战斗")
time.sleep(1)
while player_life:
if player_life <= 0:
break
if player_life > 0 and enemy_life > 0:
player_life = player_life - enemy_attack
enemy_life = enemy_life - player_attack
print("→→→你和敌军拼杀!!!→→→")
print("【" + player + "】" + "剩余血量" + str(player_life) + " ‖ 【敌军】剩余血量" + str(enemy_life))
time.sleep(1.5)
elif player_life > 0 and enemy_life <= 0:
print("敌军已被你击败,等待新一波敌军进入战场!")
count += 1
print("击杀1批敌军,属性可提升 \n1.增加血量 \n2.增加攻击")
while True:
tips = input("请选择")
if int(tips) == 1:
player_life = player_life + random.randint(20,41)
print("【" + player + "】" + "血量↑:" + str(player_life) + ";攻击:" + str(player_attack))
enemy_life = random.randint(100,150)
enemy_attack = random.randint(10,20)
print("【敌军】" + "血量:" + str(enemy_life) + ";攻击:" + str(enemy_attack))
time.sleep(1)
break
elif int(tips) == 2:
player_attack = player_attack + random.randint(3,9)
print("【" + player + "】" + "血量:"+ str(player_life) + ";攻击↑:" + str(player_attack))
enemy_life = random.randint(100,150)
enemy_attack = random.randint(10,20)
print("【敌军】" + "血量:" + str(enemy_life) +";攻击:" + str(enemy_attack))
time.sleep(1)
break
else:
print("输入有误,请重新输入")
if player_life <= 0 and enemy_life <= 0:
print("你与最后一个敌军同归于尽了!共打败了%d 个敌军!" % count)
time.sleep(1.5)
if count <= 5:
time.sleep(1)
print("“真的勇士敢于直面惨淡的人生,敢于正视淋漓的鲜血。”")
elif count >= 10:
time.sleep(1)
print("“泽国江山入战图,生民何计乐樵苏。\n 凭君莫话封侯事,一将功成万骨枯。\n 传闻一战百神愁,两岸强兵过未休。 \n 谁道沧江总无事,近来长共血争流。”")
else:
time.sleep(1)
print("“剑阁峥嵘而崔嵬,一夫当关,万夫莫开。”")
restart()
else:
count -= 1
print("你已经尽力了!共打败了%d 个敌军!" % count)
time.sleep(1.5)
if count <= 5:
time.sleep(1)
print("“真的勇士敢于直面惨淡的人生,敢于正视淋漓的鲜血。”")
elif count >= 10:
time.sleep(1)
print("“泽国江山入战图,生民何计乐樵苏。\n 凭君莫话封侯事,一将功成万骨枯。\n 传闻一战百神愁,两岸强兵过未休。 \n 谁道沧江总无事,近来长共血争流。”")
else:
time.sleep(1)
print("“剑阁峥嵘而崔嵬,一夫当关,万夫莫开。”")
restart()
game_start()
我把编码改了,加了重新开始的选项
还是那句话:谁能给我改个exe封装啊~~~~~~~~~~~~~ |