猫史档案馆


【Python作品分享】打工人模拟器【作品秀】

用户:史蒂夫HBoo史蒂夫HBoo查看:0 回复:0 评论:0 创建时间:2022-06-11T14:51:35


【作品展示】

center_image

 

【作品介绍】

很好玩的游戏

 

【作品源代码】

# -*- coding: utf-8 -*-

from asyncio.proactor_events import _ProactorBasePipeTransport

from asyncore import read
from distutils.command.clean import clean
import imp
from ntpath import join

from operator import truediv
from random import randrange
from re import S


import time
from traceback import print_tb
from turtle import back
from unicodedata import east_asian_width
import easygui
import pygame
import sys
import tkinter
饥饿=100
睡觉=100
心情=100


OPENTXT=open('save game.txt')
#--------------------------------------
def musicplay(name):
    pygame.mixer.music.load(name)
    pygame.mixer.music.play()
def talk(go):
    easygui.ynbox(go)
#-------------------------------------------


pygame.mixer.init()

god = pygame.mixer.music.load("test.mp3")
pygame.mixer.music.play()


#-------------------------------------------
价格1=randrange(2000,20000)
价格2=randrange(4000,60000)
价格3=randrange(10000,1000000)
保存游戏连接=[]
天数=0
money=0
b=0
a=0
c=0
score=0
    
计数=0
f=0
股票1=0 
股票2=0
股票3=0
print("欢迎来到打工人模拟器")
time.sleep(1)
input('点击任意键开始游戏')
#-------------------------------------------开始循环
while True:
    a=input("你的选择的职业:\nA:打工人(1000元到1万元)\nB:老板20000元到100000\nC.读取游戏")#职业

    b=input("你的年龄:")
    c=input("你的名字:")
    #-------------------------------------------
    if(a=='c' or a=='C'):
        
        



        
        #保存游戏连接=[money,股票1,股票2,股票3,a,b,c]
        score=float(score)
        
        
    
        money=OPENTXT.readline()

        股票1=OPENTXT.readline()
        股票2=OPENTXT.readline()
        股票3=OPENTXT.readline()
        #a=OPENTXT.readline()
        #b=OPENTXT.readline()
        #c=OPENTXT.readline()
        score=OPENTXT.readline()
        天数=OPENTXT.readline()
        饥饿=OPENTXT.readline()
        睡觉=OPENTXT.readline()
        心情=OPENTXT.readline()
        money=int(money)
        股票1=int(股票1)
        股票2=int(股票2)
        股票3=int(股票3)
        
        score=float(score)
        天数=int(天数)
        天数=int(天数)
        饥饿=int(饥饿)
        睡觉=int(睡觉)
        心情=int(心情)
        print("读取成功")
        #money=0o17(money)
        #股票1=0o17(股票1)
        #股票2=0o17(股票2)

        #股票3=0o17(股票3)
        #-------------------------------------------读取存档

    
    
        #-------------------------------------------
    elif(a=='A' or a=='a'):
        money=randrange(1000,100000)
        print("姓名:",c,"年龄:",b,"职业:打工人")
    elif(a=='B' or a=='b'):
        print("姓名:",c,"年龄:",b,"职业:老板")
        money=randrange(10000,1000000)
    

        pass
    else:
        print("错误。")
        time.sleep(1)
        continue
    #-------------------------------------------职业选择
    print("你的财产为:",money)
    游戏规则=input("是否需要查看游戏规则:yes or no")
    if(游戏规则=='yes'):
            print("赚够10000000即可赢得游戏\n\n\n\n本提示将会在10秒后结束")
            time.sleep(10)
            
    while True:
            god = pygame.mixer.music.load("test2.mp3")
            pygame.mixer.music.play()
            score=float(score)
            
            
 
            localtime = time.asctime( time.localtime(time.time()) )
            
            if (天数>30 and money<100000):
                
                easygui.msgbox("恭喜获得隐藏成就:躺平青年","成就","ok")
            
            elif(money<10):
                easygui.msgbox("恭喜获得成就:破产,成为社会丐帮,请重新开始游戏","成就","ok")
                sys.quit
            elif(score>=1.0):
                musicplay('end.mp3')
                easygui.ccbox("恭喜你,你获得了游戏胜利")
                time.sleep(3)
                talk("钱都是虚无的,唯有吧爱抛洒人间才能悟出真谛!\n谢谢你能玩到最后\n陌  生  人\n\n\n\n或者。。。\n")
                time.sleep(5)
                talk("你是个作弊者!")
                talk("无论如何")
                talk("都很感谢你")
                talk("by emwekinz")
                sys.quit
            elif(饥饿<=0):
                easygui.ynbox("你饿s了,请重新开始游戏")
                #time.sleep(10)
                sys.quit
            elif(睡觉<=0):
                easygui.ynbox("你累s了,请重新开始游戏")
                #time.slee
                sys.quit
            elif(心情<=0):
                easygui.ynbox("你得了喵,请重新开始游戏")
                #time.sleep(10)
                sys.quit
                #-------------------------------------------成就



            print("今天是你打工的地",天数,"天")
            print ("现在是北京时间:", localtime)
            小目标=1000000-money
            print("你现在的财产为:",money,"距离1000000的小目标还剩:",小目标)
            print("你的得分为:",score)
            
            money=int(money)
            print("你的饥饿值为:",饥饿,"\n你的心情为:",心情,"\n你的困意为:",睡觉)
                    
            干什么=easygui.buttonbox("1.去打工\n2.去买喵\n3.去创业\n4.更新日志\n5.查看股票and售卖股票\n6.更新股票\n7.保存游戏(请点击两次,否则保存不了)\n8.睡觉\n9.慈善机构\n10.退出\n11.去网吧\n12.去吃饭(输入1234之类的)",image="photo\\back.png",choices=('喵','11','12'))
            干什么=str(干什么)
            pygame.mixer.music.stop()
            

            
            
            print("你现在的财产为:",money,"距离1000000的小目标还剩:",小目标)
            if(干什么=='1'):
                pygame.mixer.music.load("114514.mp3")
                pygame.mixer.music.play()
                心情-=randrange(1,7)
                饥饿-=randrange(1,7)
                睡觉-=randrange(1,7)
                

                while(f<10):
                    print("打工ing")
                    time.sleep(0.1)
                    f+=1
                   
                    
                money1=0
                money1=randrange(100,500)
                money=money+money1
                print("打工结束赚了:",money1,"元;\n总财产为:",money,"元")
                f=0
                time.sleep
                pass

            elif(干什么=='2'):
                pygame.mixer.music.load("Toby Fox - Shop.mp3")
                pygame.mixer.music.play()
                talk("你来到了喵店。。。")
                talk("老板:年轻人想要买哪种喵")
                time.sleep(0.3)
                心情-=randrange(1,7)
                饥饿-=randrange(1,7)
                睡觉-=randrange(1,7)
            
                    

                    
                pass    
                
                while True:
                    喵=easygui.buttonbox("1.普通的喵,1000元一张\n2.好一点的喵,也就10000元一张\n3.超级喵,20万一张\n4.退出",choices=('1','2','3','4'))
                    喵=int(喵)
                    if(喵==1):
                        if(money>1000):
                            money-=1000
                            中奖=0
                            中奖=randrange(1,6)
                            中奖=int(中奖)
                            if(中奖==5):
                                talk("恭喜你,你中奖了")
                                money+=40000
                                print("你中奖了4000,现在财产为:",money)
                            else:
                                talk("没中奖,赔的裤衩掉了")
                            jx=0        
                            jx=easygui.buttonbox("是否需要继续 yes or no",choices=('yes','no'))
                            if(jx=='yes'):
                                continue
                            else:
                                break

                    elif(喵==4):
                        break
                    
                    if(喵==2):
                        if(money>10000):
                            money-=10000
                            中奖=0
                            中奖=randrange(1,8)
                            if(中奖==5):
                                talk("恭喜你,你中奖了")
                                money+=500000
                                print("你中奖了50000,现在财产为:",money)
                            else:
                                talk("没中奖,赔的裤衩掉了")
                            jx=0        
                            jx=easygui.buttonbox("是否需要继续 yes or no",choices=('yes','no'))
                            if(jx=='yes'):
                                continue
                            else:
                                break
                    
                    if(喵==3):
                        if(money>200000):
                            money-=200000
                            中奖=0
                            中奖=randrange(1,10)
                            if(中奖==5):
                                print("恭喜你,你中奖了")
                                money+=10000000
                                print("你中奖了1000000,现在财产为:",money)
                            else:
                                talk("没中奖,赔的裤衩掉了")
                            jx=0        
                            jx=easygui.buttonbox("是否需要继续 yes or no",choices=('yes','no'))
                            if(jx=='yes'):
                                continue
                            else:
                                break
                    else:
                        print("老板:年轻人赚够钱再来把")
                        time.sleep(1) 
                        break                    


                        
                        pass

                    pass
            elif(干什么=='3'):
                musicplay('Toby Fox - Shop.mp3')
                
                print("你来到了投资中心。。。")
                print("工作人员:请问你要做那个投资呢?")
                心情-=randrange(1,7)
                饥饿-=randrange(1,7)
                睡觉-=randrange(1,7)
                while True:
                    
                    股票=0
                    
                    print("1.比例比例股票售价:",价格1,"盖亚股票售价:",价格2,"emwekinz股票售价:",价格3)
                    股票=easygui.buttonbox("1.比例比例股票售价\n2.盖亚股票\n3.emwekinz股票\n4.退出\n输入1234","购买股票",image='photo\\gupiao.png',choices=('1','2','3','4'))#多项选择choices是选择符号
                    股票=int(股票)
                    if(股票==4):
                        talk("你离开了投资中心")
                        break
                        
                        
                        

                        
                        
                    购买票数=0
                    购买票数=easygui.enterbox("你要购买多少张:(请不要点的取消,游戏会报错)")
                    购买票数=int(购买票数)
                




                    
                    
                    
                    if(股票==4):
                        break
                    
                    

                    

                    

                    


                    是否购买=easygui.ynbox("是否购买")
                    是否购买=int(是否购买)
                    if(股票==1):
                        if(money>价格1*购买票数):
                            if(是否购买==1):
                                股票1+=购买票数
                                money=money-价格1*购买票数
                                print("购买成功,现在的财产为:",money)
                    elif(股票==2):
                        if(money>价格2*购买票数):
                            if(是否购买==1):
                                股票2+=购买票数
                                money=money-价格2*购买票数
                                print("购买成功,现在的财产为:",money)
                    elif(股票==3):
                        if(money>价格3*购买票数):
                            if(是否购买==1):
                                股票3+=购买票数
                                money=money-价格3*购买票数
                                print("购买成功,现在的财产为:",money) 
                    elif(股票==4):
                        break
                    


                    else:
                        talk("抱歉你钱不够") 
                        break       

                        
                        
                        

                        
                        
                    
                    
                    #print(是否购买,type(是否购买))
                    #print(股票,type(股票))
                    #股票=input("请在这里输入:")
                    
                    
                    
                    
                    
                    pass
            elif(干什么=='4'):
                print("-----------------------------------")
                print("完善了保存系统")
                print("增加了退出")
                print("修复了部分bug")
                print("增加声音和特效")
                print("改善游戏体验")
                print("-----------------------------------")
            

            elif(干什么=='5'):
                musicplay("run!.mp3")
                while True:
                    
                    print("股票1,持股:",股票1,"售卖价格为:",价格1,)
                    print("股票2,持股:",股票2,"售卖价格为:",价格2,)
                    print("股票3,持股:",股票3,"售卖价格为:",价格3,)
                    类型=easygui.buttonbox("你要售卖哪张股票?:",choices=('1','2','3','退出'))
                    
                    
                    if(类型=='1'):
                        if(股票1>0):
                            出售=0
                            出售=easygui.enterbox("你要出售多少张?")
                            出售=int(出售)
                            if(出售<=股票1):
                                money+=价格1*出售
                                股票1-=出售
                                print("出售成功现在持股:",股票1,"\n现在财产为:",money)


                                pass
                    elif(类型=='2'):
                        if(股票2>0):
                            出售=0
                            出售=easygui.enterbox("你要出售多少张?")
                            出售=int(出售)
                            if(出售<=股票2):
                                money+=价格2*出售
                                股票2-=出售
                                print("出售成功现在持股:",股票2,"\n现在财产为:",money)
                    elif(类型=='3'):
                        if(股票3>0):
                            出售=0
                            出售=easygui.enterbox("你要出售多少张?")
                            出售=int(出售)
                            if(出售<=股票3):
                                money+=价格3*出售
                                股票3-=出售
                                print("出售成功现在持股:",股票3,"\n现在财产为:",money)
                    elif(类型=='退出'):
                        break
                    else:
                        print("你没有股票")
                        break





                            

                            

                        

                    

                
            elif(干什么=='6'):
                print("wait...")
                time.sleep(0.5)
                print("wait...")

                time.sleep(5)
                print("股票已更新")
                价格1=randrange(2000,20000)
                价格2=randrange(4000,60000)
                价格3=randrange(10000,1000000)
                time.sleep(5)

            elif(干什么=='7'):
                #money=oct(money)
                #股票1=oct(股票1)
                #股票2=oct(股票2)
                #股票3=oct(股票)
               
                

                保存游戏连接=[money,股票1,股票2,股票3,a,b,c,score,天数]
                money=str(money)
                股票1=str(股票1)
                股票2=str(股票2)
                股票3=str(股票3)
                a=str(a)
                b=str(b)
                c=str(c)
                score=str(score)
                天数=str(天数)
                饥饿=str(饥饿)
                睡觉=str(睡觉)
                心情=str(心情)
                

                print("---------------存档已创建-----------------")
               
                file1 = open ( 'save game.txt' , mode='w+' )
                
                
  
                # Writing a string to file
                
  
                # Writing multiple strings
                # at a time
                保存游戏连接=str(保存游戏连接)
                
                #[money,股票1,股票2,股票3,a,b,c,score,天数]
                
                

                file1.write(money)
                file1.write('\n')
                file1.write(股票1)
                file1.write('\n')
                file1.write(股票2)
                file1.write('\n')
                file1.write(股票3)
                file1.write('\n')
                #file1.write(a)
                #file1.write('\n')
                #file1.write(b)
                #file1.write('\n')
                #file1.write(c)
                #file1.write('\n')
                file1.write(score)
                file1.write('\n')
                file1.write(天数)
                file1.write('\n')
                file1.write(饥饿)
                file1.write('\n')
                file1.write(睡觉)
                file1.write('\n')
                file1.write(心情)
                


                
                
                #file1.writelines(保存游戏连接)
  
                # Closing file
                file1.closed
  
                # Checking if the data is
                # written to file or not
                money=int(money)
                股票1=int(股票1)
                股票2=int(股票2)
                股票3=int(股票3)
                score=float(score)
                天数=int(天数)
                天数=int(天数)
                饥饿=int(饥饿)
                睡觉=int(睡觉)
                心情=int(心情)
                

                
                
                
                
                
                print("------------文件名 save game-------------")
                time.sleep(3)
                #money=0o17(money)

                #股票1=0o17(股票1)
                #股票2=0o17(股票2)

                #股票3=0o17(股票3)
                

                pass
            elif(干什么=='8'):
                心情-=10
                饥饿-=7
                睡觉+=50
                
                    
                for __count in range(20):
                    
                    print("zzz")
                    time.sleep(0.5)
                    价格1=randrange(2000,20000)
                    价格2=randrange(4000,60000)
                    价格3=randrange(10000,1000000)
                    ttack=0
                    ttack=睡觉-100
                    if(ttack>0):
                        睡觉=100
                    
                
                    

                    pass
                print("股票已更新")
                天数+=1
            elif(干什么=='9'):
            
                饥饿-=7
                睡觉-=5
                while True:
                    good=0
                    score1=0
                    score1=float(score1)
                    
                    cishan=pygame.mixer.music.load("cishan.mp3")
                    pygame.mixer.music.play()

                    print("欢迎来到慈善机构")
                    print("你捐的每一分钱都是为留守儿童的鼓励!")
                    fore=easygui.buttonbox("你要干什么?",choices=('捐钱','退出'))
                    if(fore=='捐钱'):
                        good=easygui.enterbox("你要捐多少钱:")
                        good=int(good)
                        if(money>good):
                            print("谢谢您!")
                            心情+=10
                
                            money-=good
                            score1=good/10000
                            score+=score1
                            continue
                    elif(fore=='退出'):
                        
                        pygame.mixer.music.stop()
                        break
                        

                        pass     
            elif(干什么=='10'):
                sys.quit  
            elif(干什么=='11'):
                pygame.mixer.music.load("114514.mp3")
                pygame.mixer.music.play()
                饥饿-=randrange(1,15)
                睡觉-=randrange(1,15)
                for wang in range(10):
                    print("上网中ing")
                    time.sleep(1)
            
                心情+=50
                money2=0
                money2=randrange(100,2000)
                money=money-money2
                print("上网消费了:",money2,"心情增加了50")
                
                ttac=0
                ttac=心情-100
                if(ttac>0):
                    心情=100
            elif(干什么=='12'):
                pygame.mixer.music.load("114514.mp3")
                pygame.mixer.music.play()
                
                睡觉-=randrange(1,15)
                for wang in range(10):
                    print("吃饭中ing")
                    time.sleep(1)
                money2=0
                饥饿+=50
                money2=randrange(100,2000)
                money-=money2
                print("吃饭消费了:",money2,"饱食度增加了50")
                ttak=0
                ttak=饥饿-100
                if(ttak>0):
                    饥饿=100



































































































































































































































































































































#什么时候才能写到这里呢?
                
            
            
            


            
                
                
            
        

                        
                
                
                    
                    


                
                


                

               

       

    

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页