def create_monsters_model(): """ 创建小怪模型 :return: None """ while TAG: name = raw_input("请输入怪物的姓名:") hurt = raw_input("请输入怪物的破坏力:") text = """ 怪物信息如下: 姓名: {0} 破坏力:{1} """.format(name, hurt) print(text) decide = raw_input("是否确认(y/n):") if decide == 'y': M = small_monster_Model(name, hurt) dict = common.log_info_read(DIR + 'config_conf') if dict != False: dict['monsters'].append(M) common.log_info_write(DIR + 'config_conf', dict) print("怪物信息保存成功!") return else: dict = {'monsters': [M], 'towers': [], 'players': []} common.log_info_write(DIR + 'config_conf', dict) print("怪物信息保存成功!") return elif decide == 'n': break else: print("您的输入有误!")
def login_Check(): dict = common.log_info_read(DIR + 'config_conf') if dict == False: print("请让管理员先创建老师及课程模型后再来!") return name = raw_input("请输入你的姓名:") age = raw_input("请输入你的年龄:") account = raw_input("请输入你的登录账号:") password = raw_input("请输入你的登陆密码:") text = """ 你的注册信息如下: 姓名:{0} 年龄:{1} 登陆账号:{2} 登陆密码:{3} """.format(name, age, account, password) while TAG: print(text) decide = raw_input("是否确认(y/n):") if decide == 'y': S = student_Model(name, age, account, password, []) dict['students'].append(S) common.log_info_write(DIR + 'config_conf', dict) LOGIN.insert(0, S) print('信息注册成功') user_Main(name) elif decide == 'n': return else: print('你的输入有误!')
def Lock_demon_tower_Top(user): dict = common.log_info_read(DIR + 'config_conf') for pobj in dict['players']: if pobj.Name == user.Name: P = pobj time.sleep(2) title = """ * * * * * * * * * * * * * * * * * * * * * * *第五章:锁妖塔顶* * * * * * * * * * * * * * * * * * * * * * * """ print(title) time.sleep(5) text = """ 克服磨难,吾父终至,锁妖塔顶。与前相比,此地奇静。 地方不大,有水缸一口,两人高有余。好奇之下, 侧身观之,怎料竟有活人居于缸内,遂上前,救出。 原来此人就是灵儿。询问下,方知,那日毕,其心已死, 趁高富帅不备,遂逃出,寻短见,幸被隐门上士所救,居 此疗伤,恰逢我父闯塔,喜得相逢。至此,我父恍然,直呼, 此宝胜万宝也(主角瞬间满怒体力翻倍) """ for i in text.decode('utf-8'): if i != ' ': time.sleep(0.5) print i.encode('utf-8'), else: print i.encode('utf-8'), P.Strength = P.Strength * 2 common.log_info_write(DIR + 'config_conf', dict) Wu_Duo(user)
def create_Tower_model(): """ 创建锁妖塔模型 :return: None """ dict = common.log_info_read(DIR + 'config_conf') if dict == False: print("请先创建怪物模型后再来!") return name = raw_input("请输入锁妖塔的名称:") difficulty = raw_input("请输入本层的难度(倍增小怪攻击力):") T = lock_demon_tower_Model(name, difficulty, dict['monsters']) while TAG: text = """ 课程的信息如下: 塔名: {0} 难度: {1} """.format(name, difficulty) print(text) decide = raw_input("是否确认(y/n):") if decide == 'y': dict['towers'].append(T) common.log_info_write(DIR + 'config_conf', dict) return elif decide == 'n': return else: print("您的输入有误!")
def User_Transfer_Money(log=None): ''' 用户时时转账模块 :return: ''' while TAG: dictt = common.log_info_read(LOGINING[0]) tm = time.localtime() tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str( tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min) text = ''' 时时转账功能界面 {0} 1,时时转账 2,返回菜单 '''.format(log) print(text) while TAG: decide = raw_input('请问你想做点什么?') if decide == '1': name = raw_input('请输入你想转账的人的用户名:') if os.path.exists(DIR + name + '_log') == False: print('没有这个用户存在!请重新输入!') break elif common.log_info_specific_read(name, 'account') == 'empty': print('对方没有关联银行卡!') break else: card = raw_input('请输入你想要转账的对方的银行卡号:') account = common.log_info_specific_read(name, 'account') if card == account: print('银行卡号验证成功!') money = raw_input('请输入你想要转账的金额:') re = common.pwd_money_check(LOGINING[0]) if re == False: print('密码校验错误!') break elif int(dictt['cash']) < int(money): print('您没有足够的现金转账!') break elif money.isdigit(): dict = common.log_info_read(name) dict['cash'] = str(int(dict['cash']) + int(money)) common.log_info_write(name, dict) text = '{0}:银行卡为{1}的用户 向您转账{2}元,电子现金账户余额为{3},总透支额度为{4}'\ .format(tm_text,dictt['account'],money,dict['cash'],dict['Actual_overdraft']) common.log_info_billing_write(name, text) dictt['cash'] = str( int(dictt['cash']) - int(money)) common.log_info_write(LOGINING[0], dictt) text = '{0}:您进行了“转账”操作,转账金额为{1},对方银行卡号为{2},电子现金余额为{3},总透支额度为{4}'\ .format(tm_text,money,dict['account'],dictt['cash'],dictt['Actual_overdraft']) common.log_info_billing_write(LOGINING[0], text) print('转账成功!') else: print('您的银行卡号输入错误!') break elif decide == '2': return else: print('您的输入有误!')
def admin_add_bankcard(): ''' 给没有关联银行卡的用户关联银行卡号 :return:None ''' dict = {} print('尚未建立银行卡关联信息的账户如下:\n') list = os.listdir(DIR) num = 0 for i in list: if i == '__init__.py' or i == '__init__.pyc': continue else: re_dict = common.log_info_read(i.strip().split('_')[0]) if re_dict['account'] == 'empty': num += 1 print('{0} 登录名称:{1} \n'.format(num, re_dict['name_login'])) dict[str(num)] = re_dict['name_login'] while TAG: choose = raw_input('输入索引选择你想添加银行卡的用户(n = 返回上级菜单):') if choose == 'n': return elif choose in dict: account = common.account_input() re_dict = common.log_info_read(dict[choose]) re_dict['account'] = account common.log_info_write(dict[choose], re_dict) print('用户{0}的银行卡关联成功'.format(dict[choose])) else: print('您输入的信息有误!')
def admin_Overdraft_limit(): ''' 修改用户银行卡的透支额度 :return:None ''' dict = {} print('所有用户额度信息如下:\n') list = os.listdir(DIR) num = 0 for i in list: if i == '__init__.py' or i == '__init__.pyc': continue else: re_dict = common.log_info_read(i.strip().split('_')[0]) num += 1 print('{0} 登录名称:{1} 透支额度为:{2} \n'.format( num, re_dict['name_login'], re_dict['Overdraft_limit'])) dict[str(num)] = re_dict['name_login'] while TAG: choose = raw_input('输入索引选择你想修改额度的账户(n = 返回上级菜单):') if choose == 'n': return elif choose in dict: Quota = raw_input('你想把额度改成多少?:') re_dict = common.log_info_read(dict[choose]) re_dict['Overdraft_limit'] = Quota common.log_info_write(dict[choose], re_dict) print('用户{0}的额度修改成功!'.format(dict[choose])) else: print('您输入的信息有误!')
def class_Begins(): num = 0 List = [] dict = common.log_info_read(DIR + 'config_conf') if LOGIN == []: print('请登陆后再来!') return if dict == False: print("请让管理员先创建老师及课程模型后再来!") return for S in dict['students']: if S.Name == LOGIN[0].Name and S.Lobj == []: print("您还没有选课,请选课后再来!") return while TAG: for obj in dict['students']: if obj.Name == LOGIN[0].Name: print("您有{0}门待修业课程,如下:".format(str(len(obj.Lobj)))) for lesson in obj.Lobj: if obj.schedule[lesson] >= 100: finished = '已达成' elif obj.num[lesson] >= 9: finished = '修业失败' else: finished = obj.schedule[lesson] print('{0},课程名:{1},课时费:{2},授课老师:{3},修业达成率:{4},已修业次数:{5}'. format(str(num + 1), lesson.Lname, lesson.Lcost, lesson.Tobj.Name, finished, obj.num[lesson])) num += 1 List.append(str(num)) choose = raw_input("请输入你的选择(单选)(输入n返回上一级菜单):") if choose in List: # if LOGIN[0].schedule[LOGIN[0].Lobj[int(choose)]] < 100: for obj in dict['students']: if obj.Name == LOGIN[0].Name: for i in range(9): # print (obj.Lobj[int(choose)-1]) if obj.schedule[obj.Lobj[ int(choose) - 1]] < 100 and obj.num[obj.Lobj[ int(choose) - 1]] < 9: obj.Classbegins(obj.Lobj[int(choose) - 1].Lname) num = 0 else: print('您选择的课程已经修业完成,请重新选择!') common.log_info_write(DIR + 'config_conf', dict) num = 0 break common.log_info_write(DIR + 'config_conf', dict) elif choose == 'n': return else: print("您的输入有误!") num = 0
def admin_Freeze_bankcard(): ''' 冻结or解冻用户的银行卡号 :return:None ''' dict = {} print('所有已关联银行卡的用户的银行卡状态信息如下:\n') list = os.listdir(DIR) num = 0 for i in list: if i == '__init__.py' or i == '__init__.pyc': continue else: re_dict = common.log_info_read(i.strip().split('_')[0]) if re_dict['account'] != 'empty': num += 1 if re_dict['status'] == '0': lab = '活跃' else: lab = '冻结' print('{0} 登录名称:{1} 账户状态:{2} \n'.format( num, re_dict['name_login'], lab)) dict[str(num)] = re_dict['name_login'] while TAG: choose = raw_input('输入索引选择用户来改变他的银行卡状态(活跃-->冻结-->活跃)(n = 返回上级菜单):') if choose == 'n': return elif choose in dict: re_dict = common.log_info_read(dict[choose]) if re_dict['status'] == '0': labb = '冻结' labbb = '1' else: labb = '活跃' labbb = '0' decide = raw_input('你确定要将用户{0}的银行卡的状态改成{1}吗?(y/n):'.format( dict[choose], labb)) if decide == 'n': return re_dict['status'] = labbb common.log_info_write(dict[choose], re_dict) print('用户{0}的银行卡的状态信息已经改变!'.format(dict[choose])) else: print('您输入的信息有误!')
def select_Lesson(): num = 0 List = [] dict = common.log_info_read(DIR + 'config_conf') if LOGIN == []: print('请登陆后再来!') return if dict == False: print("请让管理员先创建老师及课程模型后再来!") return print("目前的可选课程有{0}门,如下:".format(str(len(dict['lessons'])))) for lesson in dict['lessons']: print('{0},课程名:{1},课时费:{2},授课老师:{3}'.format(str(num + 1), lesson.Lname, lesson.Lcost, lesson.Tobj.Name)) num += 1 List.append(str(num)) while TAG: choose = raw_input("请输入索引选择课程(可以多选但不能重复):") if choose.isdigit(): if len(choose) == len(set(choose)): if set(choose) & set(List) == set(choose): for S in dict['students']: if S.Name == LOGIN[0].Name: for i in list(choose): if dict['lessons'][int(i) - 1] in S.Lobj: print("您已经添加过{0}课程了".format( dict['lessons'][int(i) - 1].Lname)) else: S.Lobj.append(dict['lessons'][int(i) - 1]) S.schedule[dict['lessons'][int(i) - 1]] = 0 S.num[dict['lessons'][int(i) - 1]] = 0 common.log_info_write(DIR + 'config_conf', dict) print('选课成功!') return else: pass else: print("您的选择超范围,请重新选择!") else: print("您的选择里有重复内容,请重新输入!") else: print('您的输入必须是纯数字,请重新输入!')
def create_Lesson_model(): """ 创建课程模型 :return: None """ num = 0 list = [] dict = common.log_info_read(DIR + 'config_conf') if dict == False: print ("请先创建老师模型后再来!") return name = raw_input("请输入课程名称:") cost = raw_input("请输入课时费:") while TAG: print ("目前有{0}个老师可供选择,如下:".format(str(len(dict['teachers'])))) for P in dict['teachers']: print ("{0}:姓名:{1},年龄:{2},性别:{3}".format(str(num+1),P.Name,P.Age,P.Sex)) num += 1 list.append(str(num)) choose = raw_input("请输入索引选择授课老师:") if choose in list: tobj = dict['teachers'][int(choose)-1] L = lesson_Model(name,cost,tobj) while TAG: text = """ 课程的信息如下: 课程名:{0} 课时费:{1} 授课老师:{2} """.format(name, cost, L.Tobj.Name) print (text) decide = raw_input("是否确认(y/n):") if decide == 'y': dict['lessons'].append(L) common.log_info_write(DIR + 'config_conf', dict) return elif decide == 'n': return else: print ("您的输入有误!") else: print ("您的输入有误!") num = 0
def User_Pay_back_Money(): ''' 用户定期还款设置模块 :return: ''' dict = common.log_info_read(LOGINING[0]) print('您目前的自动还款设置为每月的{0}日还款').format(dict['Repayment_date']) while TAG: decide = raw_input('你想重新设置自动还款日吗?(y/n):') if decide == 'y': day = raw_input('请输入您想设置的日期(1----10):') if day.isdigit() and int(day) <= 10: dict['Repayment_date'] = day common.log_info_write(LOGINING[0], dict) print('自动还款日期修改成功!') return else: print('您的输入有误!') elif decide == 'n': return else: print('您的输入有误!')
def create_Teachers_model(): """ 创建老师模型 :return: None """ while TAG: name = raw_input("请输入老师的姓名:") age = raw_input("请输入老师的年龄:") sex = raw_input("请输入老师的性别:") while TAG: text = """ 老师信息如下: 姓名:{0} 年龄:{1} 性别:{2} """.format(name,age,sex) print (text) decide = raw_input("是否确认(y/n):") if decide == 'y': P = teacher_Model(name,age,sex) dict = common.log_info_read(DIR+'config_conf') if dict != False: dict['teachers'].append(P) common.log_info_write(DIR + 'config_conf', dict) print ("老师信息保存成功!") return else: dict = { 'teachers':[P], 'lessons':[], 'students':[] } common.log_info_write(DIR+'config_conf',dict) print ("老师信息保存成功!") return elif decide == 'n': break else: print ("您的输入有误!")
def User_information(): ''' 个人信息查询模块 :return: ''' while TAG: dict = common.log_info_read(LOGINING[0]) if dict['status'] == '0': lab = '正常' else: lab = '冻结' if dict['account'] == 'empty': labb = '未绑定' else: labb = dict['account'] text = ''' 您的个人注册信息如下: 登录名:{0} 银行卡号:{1} 注册时间:{2} 账单日(每月):{3} 还款日(每月):{4} 银行卡状态:{5} 电子现金余额:{6} 银行卡已透支额度:{7} 银行卡透支额度上限:{8} '''.format(dict['name_login'], labb, dict['tm_text'], dict['billing_day'], dict['Repayment_date'], lab, dict['cash'], dict['Actual_overdraft'], dict['Overdraft_limit']) print(text) print(''' 您可以进行如下操作: 1,修改登录密码 2,绑定银行卡 3,修改银行卡密码 4,返回菜单 ''') while TAG: decide = raw_input('你想做点什么?') if decide == '1': pwd_login = common.pwd_login_input() if pwd_login == None: return else: dict['pwd_login'] = pwd_login common.log_info_write(LOGINING[0], dict) print('登录密码修改成功') break elif decide == '2': if dict['account'] != 'empty': print('您已经绑定过银行卡了!不能再次绑定!') break else: account = common.account_input() if account == None: return else: dict['account'] = account common.log_info_write(LOGINING[0], dict) print('银行卡绑定成功!') break elif decide == '3': if dict['account'] == 'empty': print('您尚未绑定银行卡,请绑定后再来!') break else: pwd_money = common.pwd_money_input() if pwd_money == None: return else: dict['pwd_money'] = pwd_money common.log_info_write(LOGINING[0], dict) print('银行卡密码修改成功!') break elif decide == '4': return else: print('您的输入有误!')
def User_registration(): ''' 用户注册功能模块 :return: None ''' while TAG: name_login = common.name_login_input() #得到新用户名 if name_login == None: return pwd_login = common.pwd_login_input() #得到新登录密码 if pwd_login == None: return account = common.account_input() #得到新银行卡号 if account == None: return if account != 'empty': pwd_money = common.pwd_money_input() #得到新取款密码 if pwd_money == None: return else: pwd_money = 'empty' common.Verification_input() #进行验证码验证 while TAG: information = ''' 您要注册的信息如下: 登录用户名:{0} 登录的密码:{1} 银行卡账号:{2} 银行取款码:{3} '''.format(name_login, pwd_login, account, pwd_money) print(information) decide = raw_input('注册信息是否确认?(y/n):') if decide == 'y': tm = time.localtime() tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str( tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min) #user_information = '{0}|{1}|{2}|{3}|{4}|15000|活跃|10000'.format(name_login,pwd_login,account,pwd_money,tm_text) dict_info = { 'name_login': name_login, #用户名 'pwd_login': pwd_login, #登录密码 'account': account, #银行卡号 'pwd_money': pwd_money, #银行卡密码 'tm_text': tm_text, #注册时间 'billing_day': '15', #账单日 'Repayment_date': '1', #还款日 'status': '0', #账户状态(0:活跃 1:冻结) 'cash': '0', #现金电子余额 'Actual_overdraft': '0', #总透支金额 'Overdraft_limit': '15000', #透支额度上限 'Debt_Bill_amount': '0', #账单欠账金额记录 'Debt_record': {}, #已出账单历史记录 'Has_been_out_billing': {}, #已出账单流水历史记录 'Not_out_billing': [] #未出账单流水记录 } common.log_info_write(name_login, dict_info) print('注册成功!') LOGINING.insert(0, name_login) User_Manage() Main() elif decide == 'n': break else: print('您的输入有误,请重新输入!')
def Lock_demon_tower(user): List = [] dict = common.log_info_read(DIR + 'config_conf') for pobj in dict['players']: if pobj.Name == user.Name: P = pobj time.sleep(2) title = """ * * * * * * * * * * * * * * * * * * * * * * *第四章:勇闯锁妖塔* * * * * * * * * * * * * * * * * * * * * * * """ print(title) time.sleep(5) text = """ 反复思量,我父还是决定暂缓报仇,遵从隐士的看法, 独自一人来到锁妖塔前,看者前方雄伟的高达{0} 层的锁妖塔,暗下决心,要尽快完成闯塔拿到宝物. 于是,我父来到了塔下的驿站里... """.format(str(len(user.Tlist_obj))) for i in text.decode('utf-8'): if i != ' ': time.sleep(0.5) print i.encode('utf-8'), else: print i.encode('utf-8'), while TAG: test = """ 请问现在你想去哪? 1,闯塔 2,打开背包(吃药) 你还有{0}体力 3,不闯了,直接去报仇 """.format(str(P.Strength)) print(test) choose = raw_input("请输入索引进行选择:") num = 0 bum = 0 if choose == '1': for tobj in dict['towers']: if P.schedule[tobj] == 100: schedule = '已达成' bum += 1 else: schedule = P.schedule[tobj] print("{0},{1},难度系数:{2},进度率:{3}%,创塔次数:{4}次".format( str(num + 1), tobj.Lname, tobj.Difficulty, str(schedule), str(P.num[tobj]))) if bum == len(P.Tlist_obj): print("{0},锁妖塔顶层,难度系统:0".format(str(num + 2))) num += 1 List.append(str(num)) decide = raw_input("请输入索引进行选择:") if decide == str(len(P.Tlist_obj) + 1) and bum == len(P.Tlist_obj): Lock_demon_tower_Top(user) if decide in List: if P.schedule[dict['towers'][int(decide) - 1]] < 100: for i in range(10): re = P.Begins(dict['towers'][int(decide) - 1]) if re == False: common.log_info_write(DIR + 'config_conf', dict) break else: common.log_info_write(DIR + 'config_conf', dict) else: print("本层已经闯过了!") else: print("你的输入有误!") elif choose == '2': while TAG: text = """ 背囊物品如下: 你还有{0}体力 1,大还丹:{1}个 2,小还丹 {2}个 """.format(str(P.Strength), str(P.Item['大还丹']), str(P.Item['大还丹'])) print(text) choose = raw_input("请输入索引进行选择:") if choose == '1': if P.Item['大还丹'] > 0: P.Item['大还丹'] -= 1 P.Strength += 500 common.log_info_write(DIR + 'config_conf', dict) break else: print("大还丹个数为0") break elif choose == '2': if P.Item['小还丹'] > 0: P.Item['小还丹'] -= 1 P.Strength += 200 common.log_info_write(DIR + 'config_conf', dict) break else: print("小还丹个数为0") break else: print("你的输入有误!请重新输入!") elif choose == '3': Fail_ending_one() else: print("你的输入有误!")
def login_Check(): dict = common.log_info_read(DIR + 'config_conf') name = raw_input("请输入你的姓名:") age = raw_input("请输入你的年龄:") nationality = raw_input("请输入你的国籍:") text = """ 游戏可选特长如下: 1,无双(初始武力+10,武力越高,敌人的伤害越低) 2,奇才 (初始智力+10,智力越高遇敌率越低) 3,妖异 (初始魅力+10,魅力越高,敌人暴击率越低) 4,守财 (初始体力+300,体力越高越耐打) """ while TAG: print(text) specialty = raw_input("请输入索引选择你的特长(单选):") Dic = {'1': '无双', '2': '奇才', '3': '妖异', '4': '守财'} if specialty in Dic.keys(): specialty = Dic[specialty] break else: print("你的输入有误,请重新输入!") while TAG: decide = raw_input("是否开启作弊模式?(y/n)") if decide == 'y': gamemode = '作弊模式' break elif decide == 'n': gamemode = '正常模式' break else: print("你的输入有误!") text = """ 你的注册信息如下: 姓名:{0} 年龄:{1} 国籍:{2} 特长:{3} 模式:{4} """.format(name, age, nationality, specialty, gamemode) while TAG: print(text) decide = raw_input("是否确认(y/n):") if decide == 'y': P = players_Model(name, age, nationality, specialty, gamemode, dict['towers']) # Dict = {'无双': 'Force', '奇才': 'IQ', '妖异': 'Charm'} if specialty == '无双': P.Force += 10 elif specialty == '奇才': P.IQ += 10 elif specialty == '妖异': P.Charm += 10 else: P.Strength += 300 if gamemode == '作弊模式': P.Force = 100 P.IQ = 100 P.Charm = 100 P.Strength = 100000 dict['players'].append(P) common.log_info_write(DIR + 'config_conf', dict) print('信息注册成功') return elif decide == 'n': return else: print('你的输入有误!')