def op_bag(type, name, value): if type == 1: bag = OPdata.get_bag_data() return bag[name] elif type == 2: return update_bag(name, value) else: error_deal("op_bag", "illegal input")
def op_bag(type, name, value): if type == 1: bag = OPdata.get_bag_data() return bag[name] elif type == 2: return update_bag(name,value) else: error_deal("op_bag", "illegal input")
def op_bag(type, name, value): if type == 1: bag = OPdata.get_bag_data() return bag[name] elif type == 2: return update_bag(name,value) else: print "Worng!" exit(0)
def op_bag(type, name, value): if type == 1: bag = OPdata.get_bag_data() return bag[name] elif type == 2: return update_bag(name, value) else: print "Worng!" exit(0)
def update_bag(name, value): bag = OPdata.get_bag_data() if bag[name] != 0: bag[name] = bag[name] + value else: bag[name] = value OPdata.update_bag_data(bag) print "你得到了%s,目前数量为%d" % (name, bag[name]) return bag[name]
def update_bag(equip_name, equip_count): bag = OPdata.get_bag_data() if bag[equip_name] != 0: bag[equip_name] = bag[equip_name] + equip_count else: bag[equip_name] = equip_count OPdata.update_bag_data(bag) print "你得到了%s,目前数量为%d" % (equip_name, bag[equip_name]) return bag[equip_name]
def sys_menu(): input_st = True while (input_st): input_st = False print "------------------------------------" print "--系统菜单--" print "------------------------------------" print "Q-退出游戏\nS-保存游戏\nB-查看背包\nR-退出系统菜单" p_choice = raw_input("> ") if p_choice == "Q": q_choice = player_input("你是否确定要退出游戏?Y-yes,N-no") if q_choice == "Y": exit(0) else: print "请你重新选择..." time.sleep(1) input_st = True elif p_choice == "S": q_choice = player_input("你是否要保存当前记录?Y-yes,N-no") if q_choice == "Y": filename = player_input("请输入文件名") print "正在保存中..." OPdata.save(filename) time.sleep(2) print "记录已保存。" input_st = True else: print "请你重新选择..." time.sleep(1) input_st = True elif p_choice == "B": print "你的背包有如下物品" print "--------你的背包--------\n" bag = OPdata.get_bag_data() for key, value in bag.items(): print key, "*", value print "\n--------你的背包--------" elif p_choice == "R": print "..." else: print "我读不懂你的输入,请重新输入。" input_st = True print "正在返回之前的游戏,请等待" print "------------------------------------" time.sleep(3)
def sys_menu(): input_st = True while(input_st): input_st = False print "------------------------------------" print "--系统菜单--" print "------------------------------------" print "Q-退出游戏\nS-保存游戏\nB-查看背包\nR-退出系统菜单" p_choice = raw_input("> ") if p_choice == "Q": q_choice = player_input("你是否确定要退出游戏?Y-yes,N-no") if q_choice == "Y": exit(0) else : print "请你重新选择..." time.sleep(1) input_st = True elif p_choice == "S": q_choice = player_input("你是否要保存当前记录?Y-yes,N-no") if q_choice == "Y": print "正在保存中..." time.sleep(2) print "记录已保存。" input_st = True else: print "请你重新选择..." time.sleep(1) input_st = True elif p_choice == "B": print "你的背包有如下物品" print "--------你的背包--------\n" bag = OPdata.get_bag_data() for key, value in bag.items(): print key ,"*", value print "\n--------你的背包--------" elif p_choice == "R": print "..." else: print "我读不懂你的输入,请重新输入。" input_st = True print "正在返回之前的游戏,请等待" print "------------------------------------" time.sleep(3)
def op_global_data(typeNo,m_data,c_data): if typeNo == 1: if c_data == None: return OPdata.get_playerName_data() else: OPdata.update_playerName_data(c_data) return c_data elif typeNo == 2: if c_data == None: bag = OPdata.get_bag_data() return bag[m_data] else: return update_bag(m_data,c_data) elif typeNo == 3: if c_data == None: room = OPdata.get_room_data() return room[m_data] else: return update_room(m_data,c_data) else: print "get_global_data() typeNO is wrong." exit(0)