Пример #1
0
    def _get_user_map(self, key, userid, start, end, desc = False):
        map_num, map_list   = user_data.get_range_map_with_length(userid, key, start, end, desc)
        maps                = map_data.get_map_set(key, map_list, "id", "name", "url", "amount", "pass", "template", "hard", "like")
        favorite_and_pass   = user_data.is_favourite_and_pass_map(userid, map_list)

        smsg = smsg_view_map()
        smsg.page = (map_num - 1) / 10 if map_num else map_num
        i = 0
        for info in maps:
            map = smsg.infos.add()
            map.id         = int(info[0])
            map.name       = info[1]
            map.url        = info[2]
            map.amount     = int(info[3])
            map.pas        = int(info[4])
            map.collect    = favorite_and_pass[i * 2]
            map.finish     = favorite_and_pass[i * 2 + 1]
            map.difficulty = int(info[6])
            map.like       = int(info[7]) if info[7] else 0
            i = i + 1
        return smsg




        

        



            
                                     
Пример #2
0
    def post(self, cmsg):
        if not util.check_input(cmsg.name, 32):
            return auth.pack(None, const.ERROR_INPUT)

        smsg = smsg_view_map()
        smsg.page = 0

        import platform
        if platform.system() == "Windows":
            return auth.pack(smsg, 0, cmsg.common.userid)

        map_list = None
        import redis_search.query
        # 纯英文数字组合
        if re.match('^[a-zA-Z0-9]+$', cmsg.name):
            if cmsg.name.isdigit() and len(cmsg.name) == 8:
                if int(cmsg.name) < 10010000:
                    return auth.pack(smsg, 0, cmsg.common.userid)

                if map_data.exist_map(cmsg.name):
                    map_list = [cmsg.name]
                else:
                    return auth.pack(smsg, 0, cmsg.common.userid)
            else:
                map_query = redis_search.query.complete(const.TAG_MAP_SEARCH, cmsg.name)
                map_list =  [s["id"] for s in map_query]

                map_query = redis_search.query.query(const.TAG_MAP_SEARCH, cmsg.name)
                map_list_temp =  [s["id"] for s in map_query]
                for itemyuan in map_list_temp:
                    if itemyuan not in map_list:
                        map_list.append(itemyuan)
        # 其他情况
        else:
            map_query = redis_search.query.query(const.TAG_MAP_SEARCH, cmsg.name)
            map_list =  [s["id"] for s in map_query]

        if len(map_list) == 0:
            return auth.pack(smsg, 0, cmsg.common.userid)

        maps                = map_data.get_map_set(0, map_list, "id", "name", "url", "amount", "pass")
        favorite_and_pass   = user_data.is_favourite_and_pass_map(cmsg.common.userid, map_list)
        i = 0
        for info in maps:
            map = smsg.infos.add()
            map.id         = int(info[0])
            map.name       = info[1]
            map.url        = info[2]
            map.amount     = int(info[3])
            map.pas        = int(info[4])
            map.collect    = favorite_and_pass[i * 2]
            map.finish     = favorite_and_pass[i * 2 + 1]
            i = i + 1
        return auth.pack(smsg, 0, cmsg.common.userid)
        

        
        
        
Пример #3
0
 def _get_upload_map(self, userid, smsg):
     upload_map_ids = user_data.get_range_map_list_with_score(userid, const.TAG_USER_UPLOAD.format(userid), 0, 4, True)
     map_list = [item[0] for item in upload_map_ids]
     maps = map_data.get_map_set(0, map_list, "id", "name", "url")
     i = 0
     for map in maps:
         map_upload = smsg.upload.add()
         map_upload.id = int(map[0])
         map_upload.name = map[1]
         map_upload.url = map[2]
         map_upload.time = util.msc_to_str(upload_map_ids[i][1])
         i = i + 1
Пример #4
0
 def _get_play_map(self, userid, smsg):
     amount_map_ids = user_data.get_range_map_list_with_score(userid, const.TAG_USER_AMOUNT.format(userid), 0, 4, True)
     map_list = [item[0] for item in amount_map_ids]
     maps = map_data.get_map_set(0, map_list, "id", "name", "url")
     i = 0
     for map in maps:
         map_amount = smsg.play.add()
         map_amount.id = int(map[0])
         map_amount.name = map[1]
         map_amount.url = map[2]
         map_amount.play = int(amount_map_ids[i][1])
         i = i + 1
Пример #5
0
    def _get_recent_map(self, userid, smsg):
        recent_map_ids = user_data.get_recent_map_list(userid)
        map_list = []
        map_recentt = []
        for recent in recent_map_ids:
            t, r, m = recent.split(":")
            map_list.append(int(m))
            map_recentt.append((long(t), int(r)))

        maps = map_data.get_map_set(0, map_list, "id", "name", "url")

        i = 0
        for map in maps:
            map_recent = smsg.recent.add()
            map_recent.id     = int(map[0])
            map_recent.name   = map[1]
            map_recent.url    = map[2]
            map_recent.time   = util.msc_to_str(map_recentt[i][0])
            map_recent.rank   = map_recentt[i][1]
            i = i + 1