|
楼主 |
发表于 2021-8-1 14:27:06
|
显示全部楼层
- def register():
- def go():
- while 1:
- global start,instant_1
- msg = "请输入用户名和密码"
- title ="galgame"
- choices = ["用户名","密码"]
- des_1=eg.multpasswordbox(msg,title,choices)
- try:
- if user_account_password[des_1[0]] != des_1[1]:
- des_2=eg.buttonbox("用户名或密码错误","galgame",["注册","返回"])
- if des_2=="注册":
- eg.msgbox("加载中....")
- wait()
- break
- else:
- continue
- else:
- instant_1 =des_1[0]
- start = True
- break
- except KeyError:
- des_2=eg.buttonbox("用户名不存在","galgame",["注册","返回"])
- if des_2=="注册":
- eg.msgbox("加载中....")
- wait()
- break
- else:
- continue
- def wait():
- while 1:
- msg = "请输入用户名和密码"
- title ="galgame"
- choices = ["用户名","密码"]
- des_1=eg.multpasswordbox(msg,title,choices)
- if des_1[0] in user_account_password:
- des_2=eg.buttonbox("用户名已存在","galgame",["登录","返回"])
- if des_2=="登录":
- go()
- break
- else:
- continue
- else:
- user_account_password[des_1[0]]=des_1[1]
- break
- def cancel():
- while 1:
- msg = "请输入需要注销的用户名和密码"
- title ="galgame"
- choices = ["用户名","密码"]
- des_1=eg.multpasswordbox(msg,title,choices)
- try:
- if des_1[0]==des_1[1]:
- user_account_password.pop(des_1[0])
- break
- else:
- eg.msgbox("输入的用户名或密码错误","galgame",ok_button="返回")
- continue
- except KeyError:
- eg.msgbox("用户名不存在","galgame",ok_button="返回")
- continue
-
- def save():
- with open("user_account_password.pkl","wb") as pickle_file:
- pickle.dump(user_account_password,pickle_file)
-
- with open("user_account_password.pkl","rb") as pickle_file:
- user_account_password = pickle.load(pickle_file)
- global start,instant_1
- start =False
- while 1:
- msg="欢迎体验小游戏"
- title="galgame"
- choices = ["登录","注册","注销","退出"]
- decision = eg.buttonbox(msg,title,choices)
- if decision=="登录":
- go()
- save()
- break
- elif decision=="注册":
- wait()
- save()
- continue
- elif decision=="注销":
- cancel()
- save()
- continue
- else:
- print("感谢游玩")
- break
复制代码 |
|