python简单的青蛙旅行小游戏

青蛙旅行小游戏

'''
    青蛙旅行
'''

import os,time,sys,random
frog_bag =[['Foods',1],['Water',1],['Medicine',1],['Games',1]]
frog_refrigerator = [['Foods',1],['Water',1],['Medicine',1],['Games',1]]
player_bag = [10, [['Foods',2],['Water',2],['Medicine',2],['Games',2]]]
clove_count = 0
frog_life = 3
frog_name = []
#进入游戏

while True:
    os.system('cls')
    print("")
    print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
    print("")
    print("       Welcome to the frog trip!")
    print("")
    print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
    print("")

    while 1:
        #判断是否注册
        if  not frog_name:
            print("Please give your little frog a name!")
            frog_name1=input("Plseas:")
            print("Your frog's name is:",frog_name1)
            print("Agree or not?")
            frog_name_choice = input("Please(Y/N):")
            #确认昵称
            if frog_name_choice == 'Y':
                print("Registered successfully!")
                frog_name.append(frog_name1)
                print("Your frog's name is:",frog_name[0])
                input("About to return to the superior menu...")
                os.system('cls')
                break
            else:
                print("Please input again!")
                continue
        else:
            break
    break

#游戏选择功能界面
while True:
    os.system('cls')
    print("")
    print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
    print("")
    print("       Welcome to the frog trip!")
    print("")
    print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
    print("")
    print("           HOME PAGE")
    print("     1.Open the bag ")
    print("     2.Open the refrigerator")
    print("     3.Collect the clove  ")
    print("     4.Open the shop ")
    print("     5.Enter the cabin ")
    print("     6.Log out  ")
    print("  ")
    print("Please select ")
    player_choice = input("Please:")

    #功能选择
    #打开背包
    if player_choice == '1':
        while 1:
            os.system('cls')
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("       Welcome to the frog's bag!")
            print("")
            print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
            print("")
            print("Stock:",frog_bag)
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("     1.Increase the items  ")
            print("     2.Return to previous menu")
            print("")
            print("Please select ")
            player_choice = input("Please:")

            #添加物品
            if player_choice == '1':
                while 1:
                    os.system('cls')
                    #青蛙背包
                    print("")
                    print("                Frog_bag")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    print(frog_bag)
                    print("")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    #玩家背包
                    print("                Player_bag")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    print(player_bag)
                    print("")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    #展示食物选择
                    print("  List of optional items")
                    print("     1.Foods ")
                    print("     2.Tirsty")
                    print("     3.Medicine ")
                    print("     4.Games")
                    print("     5.Return to previous menu")
                    print("")
                    player_choice = input("Please enter the items to be added:")

                    #选择添加的食物
                    if player_choice == '1':
                        if player_bag[1][int(player_choice)-1][1] <= 0:
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_bag[int(player_choice)-1][1] +=1
                        
                    elif player_choice == '2':
                        if player_bag[1][int(player_choice)-1][1] <= 0:
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_bag[int(player_choice)-1][1] +=1

                    elif player_choice == '3':
                        if player_bag[1][int(player_choice)-1][1] <= 0:
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_bag[int(player_choice)-1][1] +=1

                    elif player_choice == '4':
                        if player_bag[1][int(player_choice)-1][1] <= 0:
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_bag[int(player_choice)-1][1] +=1
                            
                    elif player_choice == '5':
                        input("About to return to the superior menu...")
                        break

                    else:
                        print("Please enter the correct number!")
                        time.sleep(2)
                        continue

                    request = input("Whether to add or not(Y/N):")
                    if request == 'Y':
                        continue
                    else:
                        print("N")
                        
                        #添加完成,展示青蛙背包
                        input("Add completed, press any key to continue...")
                        os.system('cls')
                        print("")
                        print("                Frog_bag")
                        print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                        print("")
                        print(frog_bag)
                        print("")
                        print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                        print("")
                        input("Press any key to continue...")
                        break

                
            

            #返回上级菜单
            elif player_choice == '2':
                input("About to return to the superior menu...")
                break
                
            #输入错误
            else:
                print("Please enter the correct number!")
                time.sleep(2)
                continue
        

    #打开冰箱
    elif player_choice == '2':
        while 1:
            os.system('cls')
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("       Welcome to the frog's refrigerator!")
            print("")
            print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
            print("")
            print("Stock:",frog_refrigerator)
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("     1.Increase the items ")
            print("     2.Return to previous menu")
            print("")
            print("Please select ")
            player_choice = input("Please:")

            #添加物品
            if player_choice == '1':
                while 1:
                    os.system('cls')
                    #青蛙冰箱
                    print("")
                    print("                Frog_refrigerator")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    print(frog_refrigerator)
                    print("")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    #玩家背包
                    print("                Player_bag")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    print(player_bag)
                    print("")
                    print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                    print("")
                    #展示食物选择
                    print("List of optional items")
                    print("     1.Foods ")
                    print("     2.Water")
                    print("     3.Medicine ")
                    print("     4.Games")
                    print("     5.Return to previous menu")
                    print("")
                    player_choice = input("Please enter the food to be added:")

                    #选择添加的食物
                    if player_choice == '1':
                        if player_bag[1][int(player_choice)-1][1] <=0 :
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_refrigerator[int(player_choice)-1][1] +=1
                            
                    elif player_choice == '2':
                        if player_bag[1][int(player_choice)-1][1] <=0 :
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_refrigerator[int(player_choice)-1][1] +=1

                    elif player_choice == '3':
                        if player_bag[1][int(player_choice)-1][1] <=0 :
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_refrigerator[int(player_choice)-1][1] +=1

                    elif player_choice == '4':
                        if player_bag[1][int(player_choice)-1][1] <=0 :
                            input("Not enough stock...")
                        else:
                            player_bag[1][int(player_choice)-1][1] -=1
                            frog_refrigerator[int(player_choice)-1][1] +=1
                        
                    elif player_choice == '5':
                        input("About to return to the superior menu...")
                        break

                    else:
                        print("Please enter the correct number!")
                        time.sleep(2)
                        continue

                    request = input("Whether to add or not(Y/N)")
                    if request == 'Y':
                            continue
                    else:
                        print("N")
                        
                        #添加完成,展示青蛙冰箱
                        input("Add completed, press any key to continue...")
                        os.system('cls')
                        print("")
                        print("                Frog_refrigerator")
                        print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                        print("")
                        print(frog_refrigerator)
                        print("")
                        print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
                        print("")
                        input("Press any key to continue...")
                        break
                    

            #返回上级菜单
            elif player_choice == '2':
                input("About to return to the superior menu...")
                break
                
            #输入错误
            else:
                print("Please enter the correct number!")
                time.sleep(2)
                continue

    #随机获取三叶草
    elif player_choice == '3':
        while 1:
            if clove_count <= 0:
                print("Run out of!")
                print("Please come back later")
                input("Press any key to continue...")
                break
            else:
                os.system('cls')
                print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
                print("")
                print("       Welcome to the frog's pond!")
                print("")
                print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
                print("")
                input("Press any key to start collecting clove...")
                clove_count -= 1
                print("Residue degree",clove_count)
                clove_num = random.randint(1,30)
                player_bag[0] += clove_num
                print("Collecting clove:",clove_num)
                print("ALL clove:",player_bag[0])
                request = input("Whether to add or not(Y/N):")
                if request == 'Y':
                    continue
                else:
                    print("N")
                    break
                continue 
            break


    #打开商店 
    elif player_choice == '4':
        while 1:
            os.system('cls')
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("       Welcome to the frog's shop!")
            print("")
            print("~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*")
            print("")
            print("     1.Foods(2clove) ")
            print("     2.Water(1clove)")
            print("     3.Medicine(5clove) ")
            print("     4.Games(3clove)")
            print("     5.Return to previous menu")
            print("")
            print("     Your's clove:",player_bag[0])
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("Please select ")
            player_choice = input("Please:")

            #买1号食物
            if player_choice == '1':
                if player_bag[0] < 2:
                    input("Sorry, your credit is running low")
                    continue
                else:
                    print("Use 2clove for 1APPLE")
                    player_bag[0] -=2
                    player_bag[1][int(player_choice)-1][1] +=1
                    print("player_bag:",player_bag)
                    input("Press any key to continue...")

            #买2号食物
            elif player_choice == '2':
                if player_bag[0] < 1:
                    input("Sorry, your credit is running low")
                    continue
                else:
                    print("Use 1clove for 1APPLE")
                    player_bag[0] -= 1
                    player_bag[1][int(player_choice)-1][1] +=1
                    print("player_bag:",player_bag)
                    input("Press any key to continue...")
            
            #买3号食物
            elif player_choice == '3':
                if player_bag[0] < 5:
                    input("Sorry, your credit is running low")
                    continue
                else:
                    print("Use 5clove for 1APPLE")
                    player_bag[0] -= 5
                    player_bag[1][int(player_choice)-1][1] +=1
                    print("player_bag:",player_bag)
                    input("Press any key to continue...")

            #买4号食物
            elif player_choice == '4':
                if player_bag[0] < 3:
                    input("Sorry, your credit is running low")
                    continue
                else:
                    print("Use 3clove for 1APPLE")
                    player_bag[0] -= 3
                    player_bag[1][int(player_choice)-1][1] +=1
                    print("player_bag:",player_bag)
                    input("Press any key to continue...")

            #返回上一级 
            elif player_choice == '5':
                input("About to return to the superior menu...")
                break
            #错误输入
            else:
                print("Please enter the correct number!")
                input("Press any key to continue...")
                continue

            request = input("Whether to Continue Purchasing(Y/N):")
            if request == 'Y':
                continue
            else:
                print("N")
                break

    #进入小屋
    elif player_choice == '5':
        while True:
            frog_play = random.randint(1,10)
            os.system('cls')
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            print("       Welcome to the frog's the cabin!")
            print("")
            print("☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★")
            print("")
            if frog_life <= 0:
                os.system('cls')
                print("Unfortunately, your little frog died...")
                print("   ")
                print("The game will quit after 3S....")
                time.sleep(1)
                print("The game will quit after 2S....")
                time.sleep(1)
                print("The game will quit after 1S....")
                time.sleep(1)
                os.system('cls')
                print("THANKS!")
                sys.exit(1)
                break
            else:
                #出门玩耍
                if 1<= frog_play <5:
                    while 1: 
                        #随机选的食物
                        frog_xiaofei = random.choice(frog_bag)
                        #随机选的食物的数量
                        frog_food_num = frog_bag[frog_bag.index(frog_xiaofei)][1]
                        if frog_food_num <= 0:
                            frog_life -=1
                            continue
                        else:
                            frog_bag[frog_bag.index(frog_xiaofei)][1] -=1
                            print("Going out to play...")
                            print("Ate:",frog_xiaofei)
                            input("Add completed, press any key to continue...")
                            break
                #发呆
                elif 5<= frog_play <7:
                    while 1:
                        #随机选的食物
                        frog_xiaofei = random.choice(frog_refrigerator)
                        #随机选的食物的数量
                        frog_food_num = frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1]
                        if frog_food_num <= 0:
                            frog_life -=1
                            continue
                        else:
                            frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1] -=1
                            print("In a daze...")
                            print("Ate:",frog_xiaofei)
                            input("Add completed, press any key to continue...")
                            break
                    
                #学习
                elif 7<= frog_play <9:
                    while 1:
                        #随机选的食物
                        frog_xiaofei = random.choice(frog_refrigerator)
                        #随机选的食物的数量
                        frog_food_num = frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1]
                        if frog_food_num <= 0:
                            frog_life -=1
                            continue
                        else:
                            frog_refrigerator[frog_refrigerator.index(frog_xiaofei)][1] -=1
                            player_bag[0] += 5
                            print("Learning...")
                            print("Ate:",frog_xiaofei)
                            input("Add completed, press any key to continue...")
                            break
                
                #睡觉
                else:
                    clove_count +=1
                    print("Be sleeping ...")
                    print("A day has passed...")
                    input("Add completed, press any key to continue...")
                
            break

    #退出系统
    elif player_choice == '6':
        os.system('cls')
        print("The game will quit after 3S....")
        time.sleep(1)
        print("The game will quit after 2S....")
        time.sleep(1)
        print("The game will quit after 1S....")
        time.sleep(1)
        sys.exit(1)  

    #输入选项错误
    else:
        print("Please enter the correct number!")
        time.sleep(2)
        continue

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值