示例#1
0
def getPlayerSummaryById(request):
    if request.method == 'GET':
        _playerInfoRet = getPlayerInfoByUser(request.GET)
        if _playerInfoRet['status'] == 'failed':
            return process_ret_status(_playerInfoRet)
        _recentMatchRet = getMatchesInfoByUser({'user_id':request.GET.get('user_id',None), 'limit':10})
        if _recentMatchRet['status'] == 'failed':
            return process_ret_status(_recentMatchRet)
       
        newMatchList = []
        for match in  _recentMatchRet['result']:
            if match.get('hero_id', None) is not None:
                hero_id = match.get('hero_id')
                heroInfo = getHeroInfo({'hero_id':hero_id})
                if heroInfo['status'] == 'ok':
                    match['hero_info'] = heroInfo['result']
                newMatchList.append(match)
        _ret = {}
        _ret['msg'] = ''
        _ret['status'] = 'ok'
        _ret['result'] = {}
        _ret['result']['player_info'] = _playerInfoRet['result']
        _ret['result']['recent_matches'] = _recentMatchRet['result']
        return process_ret_status(_ret)
    return json_response(failed_response("操作不支持"))
示例#2
0
def getRecentMatchesByMode(request):
    if request.method == 'GET':
        user_id = request.GET.get('user_id', None)
        mode_id = request.GET.get('mode_id', None)
        limit = request.GET.get('limit', 10)
        offset = request.GET.get('offset', 0)
        if mode_id is None:
            mode_id = '0'
        _recentMatchRet = getMatchesInfoByUser({'user_id':user_id, 'limit':limit, 'mode_id':str(mode_id), 'offset':offset})
        if _recentMatchRet['status'] == 'failed':
            return process_ret_status(_recentMatchRet)
       
        newMatchList = []
        for match in  _recentMatchRet['result']:
            if match.get('hero_id', None) is not None:
                hero_id = match.get('hero_id')
                heroInfo = getHeroInfo({'hero_id':hero_id})
                if heroInfo['status'] == 'ok':
                    match['hero_info'] = heroInfo['result']
                newMatchList.append(match)
        _ret = {}
        _ret['msg'] = ''
        _ret['status'] = 'ok'
        _ret['result'] = {}
        _ret['result']['recent_matches'] = _recentMatchRet['result']
        return process_ret_status(_ret)
    return json_response(failed_response("操作不支持"))
示例#3
0
def enrichUserInfo(matchRet, teamName):
    teamData = matchRet[teamName]
    newTeamData = []

    for teamObj in teamData:
        obj = teamObj
        if teamObj.get('user_id', None) is not None:
            user_id = teamObj['user_id']
            userInfo = getUserInfo({'user_id':user_id})
            obj['user_info'] = userInfo['result']
        if teamObj.get('hero_id', None) is not None:
            hero_id = teamObj['hero_id']
            heroInfo = getHeroInfo({'hero_id':hero_id})
            obj['hero_info'] = heroInfo['result']
        if teamObj.get('item_id', None) is not None:
            itemList = []
            for item_id in teamObj['item_id']:
                itemInfo = getItemInfo({'item_id':item_id})
                if itemInfo['status'] == 'ok':
                    itemList.append(itemInfo['result'])
            del obj['item_id']
            obj['item_info'] = itemList
        if teamObj.get('accessory_id', None) is not None:
            accessoryList = []
            for accessory_id in teamObj['accessory_id']:
                accessoryInfo = getAccessoryInfo({'accessory_id':accessory_id})
                if accessoryInfo['status'] == 'ok':
                    accessoryList.append(accessoryInfo['result'])
            del obj['accessory_id']
            obj['accessory_info'] = accessoryList

        newTeamData.append(obj)
    matchRet[teamName] = newTeamData
    return matchRet
示例#4
0
def getHero(request):
    if request.method == 'GET':
        _ret = getHeroInfo(request.GET)
        return process_ret_status(_ret)
    return json_response(failed_response("操作不支持"))