Exemple #1
0
def index(request, template):
    """  玩家宝物
    author : 全勇男
    {'treasure_items': [
    {'tid': 20006, 'phase': 1, 'level': 43, 'uid': 4, 'level_exp': 1000},
    {'tid': 20005, 'phase': 0, 'level_exp': 0, 'uid': 15, 'level': 1},
    {'tid': 20001, 'phase': 0, 'level': 20, 'uid': 24, 'level_exp': 30400},
    {'tid': 20007, 'phase': 0, 'level': 1, 'uid': 46, 'level_exp': 0},
    {'tid': 20008, 'phase': 0, 'level_exp': 0, 'uid': 47, 'level': 1},
    {'tid': 20004, 'phase': 0, 'level': 1, 'uid': 50, 'level_exp': 0},
    {'tid': 20001, 'phase': 0, 'level': 1, 'uid': 52, 'level_exp': 0}],
    'uid': '1000000950', 'seq': 53}
    """
    add_item_function = 'data_edit.treasure_item_model.{function}'.format(function=add_item.__name__)
    function_name = 'data_edit.treasure_item_model.{function}'.format(function=set_memcache.__name__)
    del_item_function = 'data_edit.treasure_item_model.{function}'.format(function=del_item.__name__)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    item_dict_name, item_lst_type = game_config.get_item_config_with_id_name()
    item_dict_name = { key:value for key, value in item_dict_name.items() if item_lst_type[key] == 6}

    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        try:
            if cmem_url:
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_uid))

                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,
                                                   model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=result['uid']))
                    user_uid = user_id = result['uid']
                user_uid = source['uid']
                item_lst = source['treasure_items']

                return render_to_response(template, locals(), RequestContext(request))

        except UnicodeEncodeError:
            return render_to_response(template, locals(), RequestContext(request))

        except TypeError:
            return render_to_response(template, locals(), RequestContext(request))

        except UnboundLocalError:
            return render_to_response(template, locals(), RequestContext(request))

    else:
        row_dict = {}
        return render_to_response(template, locals(), RequestContext(request))
Exemple #2
0
def get_boss_kyurem_info(request):
    head_lst = [
        {'width': 50, 'name': u'重置挑战次数'},
        {'width': 50, 'name': u'上次挑战时间'},
        {'width': 50, 'name': u'挑战BOSS次数'},
        {'width': 50, 'name': u'玩家鼓励值'},
        {'width': 50, 'name': u'是否领取奖励'}
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_account = request.POST.get('user_account')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''

        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        print user_id
        source=None
        print user_id
        source=None
        # f=open('/opt/CGameLogserver/apps/game_manager/views/data_edit/USER_DETAIL')
        # d=pickle.load(f)
        # for i in d:
        #     user_id=str(i)
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_WORLD_BOSS_KYUREM_MODEL.format(user_id=user_id))
                #print source,'source'
            elif  len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.PLAYER_WORLD_BOSS_KYUREM_MODEL.format(user_id=user_uid))
            elif  len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_WORLD_BOSS_KYUREM_MODEL.format(user_id=result['uid']))
                except:
                    pass
            if source<> None :
                row_lst.append([str(source['reset_challenge_count']),str(source['last_play_datetime']),str(source['challenge_count']),str(source['player_inspire']),str(source['has_reward']),])
        return render_to_response("data_edit/boss_kyurem_info.html",
                                  {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                   'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/boss_kyurem_info.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat}, RequestContext(request))
def get_daily_charge_reward_info(request):
    head_lst = [
        {'width': 50, 'name': u'充值数量(RMB)'},
        {'width': 50, 'name': u'获得奖励列表'},
        {'width': 50, 'name': u'获得奖励时间'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_account = request.POST.get('user_account')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''

        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        source=None

        # print user_id
        # source=None
        # f=open('/opt/CGameLogserver/apps/game_manager/views/data_edit/USER_DETAIL')
        # d=pickle.load(f)
        # for i in d:
        #     user_id=str(i)
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.DAILY_RECHARGE_REWARD_MODEL.format(user_id=user_id))
                #print source,'source'
            elif  len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.DAILY_RECHARGE_REWARD_MODEL.format(user_id=user_uid))
            elif  len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.DAILY_RECHARGE_REWARD_MODEL.format(user_id=result['uid']))
                except:
                    pass
            if source<> None and source['reward_date'] <> None:
                row_lst.append([str(source['recharge_rmb_num']),str(source['has_reward_lst']),str(source['reward_date'])])
        return render_to_response("data_edit/daily_charge_reward_info.html",
                                  {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                   'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/daily_charge_reward_info.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat}, RequestContext(request))
def get_player_reward_seven_level_info(request):
    """
        玩家开服七天等级
    """
    server_list, platform_list = daily_log._get_server_list(None,None)
    server_list.remove(server_list[0])

    if request.method == 'POST':
        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        user_openid = request.POST.get("user_openid")
        server_id = int(request.POST.get("server_id"))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        if cmem_url:

                source = {}
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_REWARD_SEVEN_LEVEL_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name.encode('utf-8')).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url,model_define.PLAYER_REWARD_SEVEN_LEVEL_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_REWARD_SEVEN_LEVEL_MODEL.format(user_id=user_uid))
                    print source

                if source:
                    each_config_dic ={}
                    reward_lst = source['single_activity_has_reward_lst']
                    new_reward_config_lst = game_config.get_all_reward_seven_level_config()
                    each_config_dic = new_reward_config_lst[str(1)]
                    if reward_lst:
                        for reward_id in reward_lst:
                            each_config_dic = new_reward_config_lst[str(reward_id)]
                            key_lst = new_reward_config_lst['1'].keys()
                            dic = {}
                            lst = []
                            print "沙发沙发沙发",key_lst
                            for each_key in key_lst:
                                lst = []
                                for _key ,_val in new_reward_config_lst.items():
                                    lst.append(_val[each_key])
                                dic[each_key] = lst
                            print "好了没",dic

        return render_to_response("data_edit/player_reward_seven_level_info.html",locals(),RequestContext(request))
    else:
        return render_to_response("data_edit/player_reward_seven_level_info.html",locals(),RequestContext(request))
def get_player_info(request):
    # head_lst = [
    #     {'width': 50, 'name': u'名称'},
    #     {'width': 50, 'name': u'当前值'},
    #     {'width': 50, 'name': u'修改'},
    #     ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')

        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_MODEL.format(user_id=user_id))
                if source:
                    user_id=source['uid']
                    row_lst = _get_player_mem(source,user_id,server_id)
            elif len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.PLAYER_MODEL.format(user_id=user_uid))
                if source:
                    user_id=source['uid']
                    row_lst = _get_player_mem(source,user_id,server_id)
            elif len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_MODEL.format(user_id=result['uid']))
                    if source:
                        user_id=source['uid']
                        row_lst = _get_player_mem(source,user_id,server_id)
                except:
                    pass
            else:
                row_lst = []
            return render_to_response("data_edit/player_info_edit.html",
                                      {'row_lst': row_lst,
                                        'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/player_info_edit.html",
                                  {'row_lst': row_lst,
                                    'server_list': server_list_dat,}, RequestContext(request))
Exemple #6
0
def _get_imformation(user_id, cmem_url):
    user_info1 = memcache.get_cmem_val(
        cmem_url, model_define.USER_MODEL.format(user_id=user_id))
    user_info = memcache.get_cmem_val(
        cmem_url, model_define.PLAYER_MODEL.format(user_id=user_id))
    user_info1.update(user_info)
    #print user_info1['state'],type(user_info1['state'])
    state = USER_STATE_NAME_DICT[user_info1['state']]
    row_lst = [[
        user_info1['openid'], user_info1['uid'], user_info1['name'],
        user_info1['level'], user_info1['vip_level'], user_info1['gold'],
        user_info1['stone'], user_info1['exp'], state
    ]]
    return row_lst
def get_arena_report_info(request):
    head_lst = [
        {'width': 50, 'name': u'玩家UID'},
        {'width': 50, 'name': u'玩家当前排名'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_account = request.POST.get('user_account')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''

        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        source=None
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.ARENA_BATTLE_REPORT_MODEL.format(user_id=user_id))
                #print source,'source'
                info= _get_report_mem(source,user_id,server_id)
            elif  len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.ARENA_BATTLE_REPORT_MODEL.format(user_id=user_uid))
                info = _get_report_mem(source,user_id,server_id)
            elif  len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.ARENA_BATTLE_REPORT_MODEL.format(user_id=result['uid']))
                    info = _get_report_mem(source,user_id,server_id)
                except:
                    pass
            else:
                info= []
            return render_to_response("data_edit/arena_report_info.html",
                                      {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                       'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id,'info':info}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/arena_report_info.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat}, RequestContext(request))
Exemple #8
0
def del_item(value_dict):
    '''
    删除物品

    '''

    user_id = int(value_dict['user_id'])
    item_tid = int(value_dict['item_id'])
    server_id = int(value_dict['server_id'])
    cmem_url = server_define.CMEM_MAP[server_id]
    if cmem_url:
        if user_id and item_tid:
            source = memcache.get_cmem_val(
                cmem_url, model_define.ITEM_MODEL.format(user_id=user_id))
            if item_tid in source['items']:
                print item_tid
                del_num = source['items'][item_tid]
                source['items'].pop(item_tid)
                result = memcache.put_cmem_val(
                    cmem_url, model_define.ITEM_MODEL.format(user_id=user_id),
                    source)
                # 操作日志记录
                insert_action_delete_item(value_dict['manager'],
                                          str(server_id), str(user_id),
                                          item_tid, del_num)
                return result
            else:
                return False
Exemple #9
0
def add_item(value_dict):
    '''
    增加物品push memcache

    '''
    user_id = int(value_dict['user_id'])
    item_tid = int(value_dict['item_id'])
    server_id = int(value_dict['server_id'])

    cmem_url = server_define.CMEM_MAP[server_id]
    if cmem_url:
        if user_id:
            source = memcache.get_cmem_val(
                cmem_url, model_define.ITEM_MODEL.format(user_id=user_id))
            if item_tid in source['items']:
                return False
            else:
                source['items'][item_tid] = 0
                result = memcache.put_cmem_val(
                    cmem_url, model_define.ITEM_MODEL.format(user_id=user_id),
                    source)
                # 操作日志记录
                insert_action_add_item(value_dict['manager'], str(server_id),
                                       str(user_id), item_tid, 0)

                return result
Exemple #10
0
def set_memcache(value_dict):
    '''
    修改memcache数据
    '''
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            if int(value_dict['input_value']) < 0:
                return False
            source = memcache.get_cmem_val(
                cmem_url,
                model_define.ITEM_MODEL.format(user_id=value_dict['user_id']))
            old_value = source['items'][int(value_dict['item_id'])]
            source['items'][int(value_dict['item_id'])] = int(
                value_dict['input_value'])
            result = memcache.put_cmem_val(
                cmem_url,
                model_define.ITEM_MODEL.format(user_id=value_dict['user_id']),
                source)
            # 操作日志记录
            insert_action_change_item(value_dict['manager'],
                                      str(value_dict['server_id']),
                                      str(value_dict['user_id']),
                                      value_dict['item_id'], old_value,
                                      value_dict['input_value'])

            return result
Exemple #11
0
def _set_state(user_id, change_id, cmem_url):
    user_state = memcache.get_cmem_val(
        cmem_url, model_define.USER_MODEL.format(user_id=user_id))
    user_state['state'] = change_id
    a = memcache.put_cmem_val(cmem_url,
                              model_define.USER_MODEL.format(user_id=user_id),
                              user_state)
def system_mail_del(request):
    """
    删除系统邮件
    """
    if request.method == "POST":
        version = str(request.POST.get("version"))
        del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
                if server_notice_box_model:
                    memcache.put_cmem_val(cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model)
                    print server_notice_box_model
                    check_system_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model["mails"]
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if version == str(notice_dict["version"]):
                                    server_notice_box_model["mails"].remove(notice_dict)
                                    memcache.put_cmem_val(
                                        cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL, server_notice_box_model
                                    )
                                    # 操作日志记录
                                    manager = GameManager.get_by_request(request)
                                    insert_action_delete_mail(manager, version)
                                    break

        return HttpResponseRedirect("/Tyranitar6/server/system_mail_lst/")
    else:
        return render_to_response("system_mail/system_mail_add.html", RequestContext(request))
def set_stage_data_function(value_dict):
    """
    修改memcache数据

    tem_id 30057$$num
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.STAGE_MODEL.format(user_id=value_dict['user_id']))
            try:
                (first_key, second_key) = value_dict['item_id'].split('$$')
                first_key = int(first_key)
                input_value = int(value_dict['input_value'])
                second_key = str(second_key)
                # print first_key, second_key, input_value

                if 'num' == second_key and 0 <= input_value:
                    source['stages'][first_key][second_key] = input_value
                elif 'rank' == second_key and (0 == input_value or -1 == input_value):
                    source['stages'][first_key][second_key] = input_value
                elif 'buy_count' == second_key and 0 <= input_value:
                    source['stages'][first_key][second_key] = input_value
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.STAGE_MODEL.format(user_id=value_dict['user_id']), source)
            return result
Exemple #14
0
def get_handbook_info(request):
    """
    {'data_version': '1', 'uid': '1000070187', 'monster_tid_set': set([32, 66, 4, 104, 93, 146, 52, 126, 25, 27, 92, 125, 94, 127])}
    """

    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        # user_name = request.POST.get('user_name').encode('utf-8')
        # user_openid = request.POST.get('user_openid')
        server_id = request.POST.get('server_id')
        # type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        handbook_model = memcache.get_cmem_val(
            cmem_url,
            model_define.HAND_BOOK_MODEL.format(user_id=int(user_uid)))
        print handbook_model
        table_lst = []
        for uid in handbook_model['monster_tid_set']:
            monster_name_lst = []
            _monster_config = game_config.get_monster_config(uid)
            monster_name_lst.append(uid)
            monster_name_lst.append(_monster_config['name'])
            table_lst.append(monster_name_lst)

        return render_to_response("data_edit/handbook_info.html",
                                  {'row_lst': table_lst},
                                  RequestContext(request))

    else:
        # row_list = []
        # type_hidden = 'hidden'
        return render_to_response("data_edit/handbook_info.html", locals(),
                                  RequestContext(request))
def set_player_activity_regist_recharge_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] has_reward_lst$$0 complete_id$$-1  active_id$$-1
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.format(user_id=value_dict['user_id']))
            try:
                print 'this is source is: ', source
                # second_key 是int类型
                input_value = int(value_dict['input_value'])
                (first_key, second_key) = value_dict['item_id'].split('$$')
                second_key = int(second_key)
                if second_key >= 0:     # has_reward_lst
                    if input_value == 0:
                        source[first_key].remove(second_key)
                    elif input_value == 1:
                        source[first_key].append(second_key)
                    else:
                        return False
                elif second_key == -1:  # complete_id     active_id
                    source[first_key] = input_value
                else:
                    return False
            except:
                return False
            # source = {'uid': '1000103005', 'complete_id': 2, 'recharge_date': datetime.date(2015, 8, 1), 'has_reward_lst': [1], 'reward_end_date': datetime.date(2015, 7, 25), 'active_id': 4}
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_REGIST_RECHARGE_MODEL.format(user_id=value_dict['user_id']), source)
            return result
Exemple #16
0
def set_player_activity_one_charge_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] has_reward_lst&&1   or one_charge_complete$$1
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ONE_RECHARGE_MODEL.format(user_id=value_dict['user_id']))
            # print 'source_neww', source,"ss"
            try:
                input_val = int(value_dict['input_value'])
                (first_key, second_val) = value_dict['item_id'].split('$$')
                second_val = int(second_val)
                if 0 == input_val:
                    if second_val in source[first_key]:
                        source[first_key].remove(second_val)
                elif 1 == input_val:
                    if second_val not in source[first_key]:
                        source[first_key].append(second_val)
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ONE_RECHARGE_MODEL.format(user_id=value_dict['user_id']), source)
            return result
def get_handbook_info(request):
    """
    {'data_version': '1', 'uid': '1000070187', 'monster_tid_set': set([32, 66, 4, 104, 93, 146, 52, 126, 25, 27, 92, 125, 94, 127])}
    """

    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        # user_name = request.POST.get('user_name').encode('utf-8')
        # user_openid = request.POST.get('user_openid')
        server_id = request.POST.get('server_id')
        # type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        handbook_model = memcache.get_cmem_val(cmem_url, model_define.HAND_BOOK_MODEL.format(user_id=int(user_uid)))
        print handbook_model
        table_lst = []
        for uid in handbook_model['monster_tid_set']:
            monster_name_lst = []
            _monster_config = game_config.get_monster_config(uid)
            monster_name_lst.append(uid)
            monster_name_lst.append(_monster_config['name'])
            table_lst.append(monster_name_lst)

        return render_to_response("data_edit/handbook_info.html", {'row_lst': table_lst}, RequestContext(request))

    else:
        # row_list = []
        # type_hidden = 'hidden'
        return render_to_response("data_edit/handbook_info.html", locals(), RequestContext(request))
def set_player_activity_time_limited_shift_shop_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] u'2'$$'num_dict'
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_TIME_LIMITED_SHIFT_SHOP_MODEL.format(user_id=value_dict['user_id']))
            # print 'source__', source
            try:
                input_int_val = int(value_dict['input_value'])
                (second_key, first_key) = (value_dict['item_id']).split('$$')        # 要修改的key
                second_key = int(second_key)
                if input_int_val > 0 and second_key > 0:
                    if second_key in source[first_key].keys():
                        source[first_key][second_key] = input_int_val
                    else:
                        source[first_key].update({second_key: input_int_val})
                elif input_int_val == 0 and second_key > 0:
                    if second_key in source[first_key].keys():
                        source[first_key].pop(second_key)
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_TIME_LIMITED_SHIFT_SHOP_MODEL.format(user_id=value_dict['user_id']), source)
            return result
Exemple #19
0
def notice_del_confirm(request):
    """
    删除广播确认
    """
    if request.method == 'POST':
        uid = str(request.POST.get("uid"))
        del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.NOTICE_MODEL)
                if server_notice_box_model:
                    memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL, server_notice_box_model)
                    print server_notice_box_model
                    check_notice_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model['notices']
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if uid == str(notice_dict['uid']):
                                    del_notice_dict = notice_dict
                                    break

        del_notice_dict['start_time'] = str(del_notice_dict['start_time'].strftime('%Y-%m-%d %H:%M:%S'))
        del_notice_dict['expiry_date'] = str(del_notice_dict['expiry_date'].strftime('%Y-%m-%d %H:%M:%S'))
        return render_to_response("notice/notice_del_confirm.html", {'notice_info': del_notice_dict,'head_lst': head_lst}, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/server/notice_lst/')
Exemple #20
0
def notice_del(request):
    """
    删除广播
    """
    if request.method == 'POST':
        uid = str(request.POST.get("uid"))
        # del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.NOTICE_MODEL)
                if server_notice_box_model:
                    print server_notice_box_model
                    check_notice_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model['notices']
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if uid == str(notice_dict['uid']):
                                    # del_notice_dict = notice_dict
                                    server_notice_box_model['notices'].remove(notice_dict)
                                    memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL, server_notice_box_model)
                                    # 操作日志记录
                                    manager = GameManager.get_by_request(request)
                                    insert_action_delete_notice(manager, uid)
                                    break

        return HttpResponseRedirect('/Tyranitar6/server/notice_lst/')
    else:
        return render_to_response("notice/notice_add.html",RequestContext(request))
Exemple #21
0
def set_player_activity_hard_stage_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] hard_win_count
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(
                cmem_url,
                model_define.PLAYER_ACTIVITY_HARD_STAGE_MODEL.format(
                    user_id=value_dict['user_id']))
            try:
                key = value_dict['item_id']
                if int(value_dict['input_value']
                       ) >= 0 and 'hard_win_count' == key:
                    source['num'] = int(value_dict['input_value'])
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(
                cmem_url,
                model_define.PLAYER_ACTIVITY_HARD_STAGE_MODEL.format(
                    user_id=value_dict['user_id']), source)
            return result
def set_player_catch_monster_function(value_dict):
    """
    修改memcache数据

    tem_id 40801 value_dict['input_value'] num
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.CATCH_MONSTER_MODEL.format(user_id=value_dict['user_id']))
            try:
                stage_id = int(value_dict['item_id'])
                input_value = int(value_dict['input_value'])
                print stage_id, input_value

                if 0 <= input_value:
                    index_id = source['catch_monster_stage_id_lst'].index(stage_id)
                    source['catch_monster_stage_lst'][index_id] = input_value
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.CATCH_MONSTER_MODEL.format(user_id=value_dict['user_id']), source)
            return result
def set_player_catch_monster_function(value_dict):
    """
    修改memcache数据

    tem_id 40801 value_dict['input_value'] num
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(
                cmem_url,
                model_define.CATCH_MONSTER_MODEL.format(
                    user_id=value_dict['user_id']))
            try:
                stage_id = int(value_dict['item_id'])
                input_value = int(value_dict['input_value'])
                print stage_id, input_value

                if 0 <= input_value:
                    index_id = source['catch_monster_stage_id_lst'].index(
                        stage_id)
                    source['catch_monster_stage_lst'][index_id] = input_value
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(
                cmem_url,
                model_define.CATCH_MONSTER_MODEL.format(
                    user_id=value_dict['user_id']), source)
            return result
Exemple #24
0
def set_player_treasure_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] 100001 or 'treasure_point' or  'reset_treasure_count'
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_MODEL.format(user_id=value_dict['user_id']))
            try:
                treasure_debris_id = int(value_dict['item_id'])
                if int(value_dict['input_value']) >= 0:
                    source['treasure_fragment_dict'][treasure_debris_id] = int(value_dict['input_value'])
                else:
                    return False
            except:
                try:
                    key = str(value_dict['item_id'])
                    if isinstance(source[key], int):
                        if int(value_dict['input_value']) >= 0:
                            source[key] = int(value_dict['input_value'])
                    else:
                        return False
                except:
                    return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.TREASURE_MODEL.format(user_id=value_dict['user_id']), source)
            return result
def set_player_activity_weixin_share_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] has_reward_lst&&1   or complete$$1
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_WEIXIN_SHARE_MODEL.format(user_id=value_dict['user_id']))
            # print 'source_neww', source,"ss"
            try:
                input_val = int(value_dict['input_value'])
                (first_key, second_val) = value_dict['item_id'].split('$$')
                second_val = int(second_val)
                if 0 == input_val:
                    if second_val in source[first_key]:
                        source[first_key].remove(second_val)
                elif 1 == input_val:
                    if second_val not in source[first_key]:
                        source[first_key].append(second_val)
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_WEIXIN_SHARE_MODEL.format(user_id=value_dict['user_id']), source)
            return result
Exemple #26
0
def add_item(value_dict):
    '''
    增加物品push memcache

    '''
    user_id = int(value_dict['user_id'])
    item_tid = int(value_dict['item_id'])
    server_id = int(value_dict['server_id'])
    cmem_url = server_define.CMEM_MAP[server_id]

    if cmem_url:
        if user_id:
            source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_id))
            for _dict in source['treasure_items']:
                if item_tid == _dict['tid']:
                    print ' same'
                    return False
            print source
            source['treasure_items'].append(
                {'tid': item_tid,
                 'phase': 0,
                 'level': 1,
                 'uid': source['seq'],
                 'level_exp': 0}
            )
            source['seq'] += 1
            result = memcache.put_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_id),source)
            return result
def player_commit_bugs_del_confirm(request):
    """
    删除玩家提交的BUG确认
    """
    if request.method == 'POST':
        user_uid = str(request.POST.get("uid"))
        time = str(request.POST.get("time"))
        # time = datetime.datetime.strptime(request.POST.get('time'),"%Y-%m-%d %H:%M:%S")
        server_id = int(request.POST.get("server_id"))
        print("user_uid: "+str(user_uid))
        print("time: "+str(time))
        print("server_id: "+str(server_id))
        bug_dict = dict()
        cmem_url = str(server_define.CMEM_MAP.get(server_id))
        if cmem_url:
            player_commit_bugs_model = memcache.get_cmem_val(cmem_url, model_define.PLAYER_COMMIT_BUGS_MODEL)
            if player_commit_bugs_model:
                print player_commit_bugs_model
                bug_dict = get_bug_uid_time(player_commit_bugs_model,user_uid, time)

        bug_dict['server_id'] = server_id
        if bug_dict.get('handle',False):
            bug_dict['handle'] = "已回信"
        else:
            bug_dict['handle'] = "需要回信"
        print bug_dict
        return render_to_response("player_commit_bugs/player_commit_bugs_del_confirm.html", {'bug_dict': bug_dict,'head_lst': head_lst}, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/server/player_commit_bugs_lst/')
Exemple #28
0
def set_player_activity_holiday_shop_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] u'2'$$'num_dict'
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_HOLIDAY_SHOP_MODEL.format(user_id=value_dict['user_id']))
            # print 'source__', source
            try:
                input_int_val = int(value_dict['input_value'])
                (second_key, first_key) = (value_dict['item_id']).split('$$')        # 要修改的key
                second_key = int(second_key)
                if input_int_val > 0 and second_key > 0:                             # updata 数据
                    if second_key in source[first_key].keys():
                        source[first_key][second_key] = input_int_val
                    else:
                        source[first_key].update({second_key: input_int_val})
                elif input_int_val == 0 and second_key > 0:
                    if second_key in source[first_key].keys():
                        source[first_key].pop(second_key)
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_HOLIDAY_SHOP_MODEL.format(user_id=value_dict['user_id']), source)
            return result
def add_equip_to_html(request,equip_add):
    """
        ④
        添加装备
    """
    if request.method == 'POST':
        user_openid = request.POST.get("user_openid")
        server_id = request.POST.get("server_id")
        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        edit_data = eval(request.POST.get("edit_data"))
        will_edit_tid_level = edit_data['level']
        will_edit_tid = int(edit_data['tid'])
        server_list, platform_list = daily_log._get_server_list(None, None)
        server_list.remove(server_list[0])

        item_id_name, item_id_type = game_config.get_item_config_with_id_name()
        monster_id_name = game_config.get_monster_config_with_id_name()
        item_tid_name_lst = []
        for (tid, name) in item_id_name.items():
            item_type = item_id_type[tid]
            if item_type == game_define.ITEM_TYPE_EQUIP:
                content = dict()
                content['tid'] = tid
                content['name'] = name
                item_tid_name_lst.append(content)
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=int(user_uid)))
        add_data = source['seq_id']
        return render_to_response(equip_add,locals(),RequestContext(request))
def add_equip_to_html(request, equip_add):
    """
        ④
        添加装备
    """
    if request.method == 'POST':
        user_openid = request.POST.get("user_openid")
        server_id = request.POST.get("server_id")
        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        edit_data = eval(request.POST.get("edit_data"))
        will_edit_tid_level = edit_data['level']
        will_edit_tid = int(edit_data['tid'])
        server_list, platform_list = daily_log._get_server_list(None, None)
        server_list.remove(server_list[0])

        item_id_name, item_id_type = game_config.get_item_config_with_id_name()
        monster_id_name = game_config.get_monster_config_with_id_name()
        item_tid_name_lst = []
        for (tid, name) in item_id_name.items():
            item_type = item_id_type[tid]
            if item_type == game_define.ITEM_TYPE_EQUIP:
                content = dict()
                content['tid'] = tid
                content['name'] = name
                item_tid_name_lst.append(content)
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        source = memcache.get_cmem_val(
            cmem_url, model_define.EQUIP_MODEL.format(user_id=int(user_uid)))
        add_data = source['seq_id']
        return render_to_response(equip_add, locals(), RequestContext(request))
def set_player_activity_recharge_short_function(value_dict):
    """
    修改memcache数据

    value_dict['tem_id'] recharge_num
    value_dict['input_value'] int
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(
                cmem_url,
                model_define.PLAYER_ACTIVITY_RECHARGE_SHORT_MODEL.format(
                    user_id=value_dict['user_id']))
            try:
                key = value_dict['item_id']
                if int(value_dict['input_value']
                       ) >= 0 and 'recharge_num' == key:
                    source['recharge_rmb_num'] = int(value_dict['input_value'])
                else:
                    return False
            except:
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(
                cmem_url,
                model_define.PLAYER_ACTIVITY_RECHARGE_SHORT_MODEL.format(
                    user_id=value_dict['user_id']), source)
            return result
def set_union_stage_function(value_dict):
    """
    修改memcache数据

    tem_id 30057$$num
    """
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):# 注 此处user_id 是union_id
            source = memcache.get_cmem_val(cmem_url, model_define.UNION_STAGE_CAS_MODEL.format(union_id=value_dict['union_id']))
            # try:
            #     (first_key, second_key) = value_dict['item_id'].split('$$')
            #     first_key = int(first_key)
            #     input_value = int(value_dict['input_value'])
            #     second_key = str(second_key)
            #     # print first_key, second_key, input_value
            #
            #     if 'num' == second_key and 0 <= input_value:
            #         source['stages'][first_key][second_key] = input_value
            #     elif 'rank' == second_key and (0 == input_value or -1 == input_value):
            #         source['stages'][first_key][second_key] = input_value
            #     elif 'buy_count' == second_key and 0 <= input_value:
            #         source['stages'][first_key][second_key] = input_value
            #     else:
            #         return False
            # except:
            #     return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.UNION_STAGE_CAS_MODEL.format(union_id=value_dict['union_id']), source)
            return result
def change_server_version(request):
    """
        修改服务器版本信息
    """
    # 本地获取所有配置文件
    local_config_lst = _get_all_config_dat()
    if request.method == 'POST':
        server_id = int(request.POST.get('server_id2'))
        new_version = request.POST.get('new_version')
        cmem_url = server_define.CMEM_MAP[server_id]
        config_result = memcache.get_cmem_val(cmem_url,
                                              model_define.CONFIG_MODEL)
        # config_version_dict = config_result.get('config_version_dict', None)
        # config_time = config_result.get('game_config_publish_time', 0)
        # version = config_result.get('version', 0)
        old_version = config_result['version']
        config_result['version'] = new_version
        memcache.put_cmem_val(cmem_url, model_define.CONFIG_MODEL,
                              config_result)

        # 操作日志记录
        manager = GameManager.get_by_request(request)
        insert_action_change_server_version(manager, server_id, old_version,
                                            new_version)

        # return HttpResponseRedirect("/Tyranitar6/server/server_config/view/")
        return view(request, server_id)
def index(request, template):
    """  类型看格式
    author : 全勇男
    7天登录


    """

    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = int(request.POST.get('server_id'))
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        try:
            if cmem_url:
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.LOGIN_7_MODEL.format(user_id=user_uid))
                elif len(user_name):
                    name = hashlib.md5(user_name).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.LOGIN_7_MODEL.format(user_id=user_uid))
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,
                                                   model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.LOGIN_7_MODEL.format(user_id=result['uid']))
                    user_uid = user_id = result['uid']
                row_dict = collections.OrderedDict()

                row_dict = {u'7天登录ID列表': source['reward_id_lst']}
                return render_to_response(template, locals(), RequestContext(request))

        except UnicodeEncodeError:
            return render_to_response(template, locals(), RequestContext(request))

        except TypeError:
            return render_to_response(template, locals(), RequestContext(request))

        except UnboundLocalError:
            return render_to_response(template, locals(), RequestContext(request))

    else:
        row_dict = {}
        return render_to_response(template, locals(), RequestContext(request))
Exemple #35
0
def get_trial_info(request):
    head_lst = [
        {'width': 50, 'name': u'试炼刷新时间'},
        {'width': 50, 'name': u'敌方数据'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_account = request.POST.get('user_account')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''

        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        print user_id
        source=None
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.GIFT_BAG_MODEL.format(user_id=user_id))
                #print source,'source'
            elif  len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.GIFT_BAG_MODEL.format(user_id=user_uid))
            elif  len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.GIFT_BAG_MODEL.format(user_id=result['uid']))
                except:
                    pass
            if source<> None:
                row_lst.append([str(source['refresh_datetime']),str(source['cur_enemy_dat'])])
        return render_to_response("data_edit/trial_info.html",
                                  {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                   'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/trial_info.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat}, RequestContext(request))
def get_mail_info(request):
    head_lst = [
        {'width': 50, 'name': u'标题'},
        {'width': 50, 'name': u'发送时间'},
        {'width': 50, 'name': u'有效期至'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        state_list = game_define.USER_STATE_NAME_DICT
        row_lst=[]
        print user_id
        if cmem_url:
            if len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.MAIL_MODEL.format(user_id=user_id))
                print source,'source'
                row_lst = _get_player_mem(source,user_id,server_id)
            elif len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.MAIL_MODEL.format(user_id=user_uid))
                row_lst = _get_player_mem(source,user_id,server_id)
            elif len(user_openid) <> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.MAIL_MODEL.format(user_id=result['uid']))
                    row_lst = _get_player_mem(source,user_id,server_id)
                except:
                    pass
        return render_to_response("data_edit/mail_info_edit.html",
                                  {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                   'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/mail_info_edit.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat,}, RequestContext(request))
def get_arena_reward_times_info(request):
    head_lst = [
        {'width': 50, 'name': u'奖励截止时间'},
        {'width': 50, 'name': u'奖励物品'},
        {'width': 50, 'name': u'玩家进行挑战次数'},
        {'width': 50, 'name': u'运营版本'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        user_id = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_account = request.POST.get('user_account')
        try:
            user_openid = str(request.POST.get('user_openid'))
        except UnicodeEncodeError :
            user_openid = ''
        server_id = int(request.POST.get('server_id'))
        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        row_lst=[]
        print user_id
        source=None
        if cmem_url:
            if  len(user_id) <> 0:
                source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ARENA_MODEL.format(user_id=user_id))
            elif  len(user_name)<> 0:
                name = hashlib.md5(user_name).hexdigest().upper()
                key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                source = memcache.get_cmem_val(cmem_url,model_define.PLAYER_ACTIVITY_ARENA_MODEL.format(user_id=user_uid))
            elif  len(user_openid )<> 0:
                try:
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    source = memcache.get_cmem_val(cmem_url, model_define.PLAYER_ACTIVITY_ARENA_MODEL.format(user_id=result['uid']))
                except:
                    pass
            row_lst.append([str(source['reward_end_date']),source['single_activity_has_reward_lst'],source[ 'num'],source['version']])
            return render_to_response("data_edit/arena_reward_times_info.html",
                                      {'row_lst': row_lst,'user_id':user_id,'user_openid':user_openid,'user_name':user_name,
                                       'head_lst': head_lst, 'server_list': server_list_dat,'cur_server_id':server_id}, RequestContext(request))
    else:
        row_lst = []
        return render_to_response("data_edit/arena_reward_times_info.html",
                                  {'row_lst': row_lst,
                                   'head_lst': head_lst, 'server_list': server_list_dat}, RequestContext(request))
Exemple #38
0
def notice_lst(request):
    """
    广播列表
    """
    data = {}
    table_list = []
    all_background_notice_dict = dict()
    all_cmem_dict = server_define.CMEM_MAP
    for key, val in all_cmem_dict.items():
        cmem_url = str(val)
        if cmem_url:
            server_notice_box_model = memcache.get_cmem_val(
                cmem_url, model_define.NOTICE_MODEL)
            if server_notice_box_model:
                # server_notice_box_model = {
                #     'uid': 'game_notice',
                #     'notices': [],
                #     'player_notices': [],
                #     'seq_id': 1
                # }
                # server_notice_box_model = memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL, server_notice_box_model)
                memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL,
                                      server_notice_box_model)
                print server_notice_box_model
                check_notice_expiry(server_notice_box_model)
                notices_lst = server_notice_box_model['notices']
                if notices_lst:
                    for notice_dict in notices_lst:
                        if notice_dict:
                            notice_uid = notice_dict['uid']
                            # if notice_uid in all_background_notice_dict:
                            #     print("notice_uid: "+str(notice_uid))
                            #     notice_dict['server_id'] = notice_dict.get('server_id','')+","+str(key)
                            # else:
                            #     notice_dict['server_id'] = str(key)
                            all_background_notice_dict[
                                notice_uid] = notice_dict

    print("all_background_notice_dict: " + str(all_background_notice_dict))
    for key_uid, value in all_background_notice_dict.items():
        if value:
            temp_content = []
            temp_content.insert(0, str(key_uid))
            temp_content.insert(1, value['server_id'])
            temp_content.insert(2, str(value['content']))
            temp_content.insert(
                3, value['start_time'].strftime('%Y-%m-%d %H:%M:%S'))
            temp_content.insert(
                4, value['expiry_date'].strftime('%Y-%m-%d %H:%M:%S'))
            temp_content.insert(5, str(value['distance_time']))
            table_list.append(temp_content)

    data['notice_info'] = table_list
    data['head_lst'] = head_lst
    return render_to_response("notice/notice_lst.html", data,
                              RequestContext(request))
def _get_union_name_dict(server_list_dat):
    result={}
    for server_id in server_list_dat:
        cmem_url=server_define.CMEM_MAP[server_id['id']]
        if cmem_url:
            data=memcache.get_cmem_val(cmem_url,model_define.UNION_SEARCH_MODEL)
            data=data.values()
            for i in data[0].values():
                result[i['u']]=i['n']
    return result
def _get_union_name(server_list_dat):
    result=[]
    for server_id in server_list_dat:
        cmem_url=server_define.CMEM_MAP[server_id['id']]
        if cmem_url :
            data=memcache.get_cmem_val(cmem_url,model_define.UNION_SEARCH_MODEL)
            data=data.values()
            for i in data[0].values():
                result.append({'id':i['u'],'name':i['n'],'server_id':server_id})
    return result
def set_player_team_function(value_dict):
    """
    修改memcache数据
                        key2$$key1$$key3(>=0才有)
    value_dict['tem_id'] 0$$team_monsters$$None
    value_dict['tem_id'] 0$$team_equips$$0
    value_dict['input_value'] int
    """
    print "PWPIASD"
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            source = memcache.get_cmem_val(cmem_url, model_define.TEAM_MODEL.format(user_id=value_dict['user_id']))

            try:
                (second_key, first_key, three_key) = value_dict['item_id'].split('$$')
                input_value = int(value_dict['input_value'])
                print first_key, second_key, three_key, input_value, "A"
                first_key, second_key, three_key = str(first_key), int(second_key), int(three_key)
                print first_key, second_key, three_key, input_value, "B"
                print "PWPIASD111114"
                if 0 <= second_key and 0 <= input_value:
                    if 0 <= three_key:                                      # 装备宝石 二维数组
                        if input_value not in source[first_key][second_key] and 0 < input_value:    # 重复UID检测
                            print "PWPIASD111116"
                            source[first_key][second_key][three_key] = input_value
                            print "PWPIASD111117"
                        elif 0 == input_value:
                            source[first_key][second_key][three_key] = input_value
                        else:
                            print 'repetition'
                            return False
                    else:                                                   # 宠物 一维数组
                        """注:宠物tid uid 都不能重复"""
                        if input_value not in source[first_key] and 0 < input_value:            # 重复 UID 检测
                            print "PWPIASD11111511"
                    #     if three_key <= 0:
                            source[first_key][second_key] = input_value
                            print "PWPIASD111115"
                        elif 0 == input_value:
                            source[first_key][second_key] = input_value
                        else:
                            print 'repetition'
                            return False
                else:
                        print "PWPIASD111113"
                        return False
                print "PWPIASD111111"

            except:
                print "PWPIASD111112"
                return False
            # 传回 url  uid  以及数据 做外层检测
            result = memcache.put_cmem_val(cmem_url, model_define.TEAM_MODEL.format(user_id=value_dict['user_id']), source)
            return result
def _get_imformation(user_id, cmem_url):
    user_info1 = memcache.get_cmem_val(cmem_url, model_define.USER_MODEL.format(user_id=user_id))
    user_info = memcache.get_cmem_val(cmem_url, model_define.PLAYER_MODEL.format(user_id=user_id))
    user_info1.update(user_info)
    # print user_info1['state'],type(user_info1['state'])
    state = USER_STATE_NAME_DICT[user_info1["state"]]
    row_lst = [
        [
            user_info1["openid"],
            user_info1["uid"],
            user_info1["name"],
            user_info1["level"],
            user_info1["vip_level"],
            user_info1["gold"],
            user_info1["stone"],
            user_info1["exp"],
            state,
        ]
    ]
    return row_lst
Exemple #43
0
def notice_lst(request):
    """
    广播列表
    """
    data = {}
    table_list = []
    all_background_notice_dict = dict()
    all_cmem_dict = server_define.CMEM_MAP
    for key, val in all_cmem_dict.items():
        cmem_url = str(val)
        if cmem_url:
            server_notice_box_model = memcache.get_cmem_val(cmem_url, model_define.NOTICE_MODEL)
            if server_notice_box_model:
                # server_notice_box_model = {
                #     'uid': 'game_notice',
                #     'notices': [],
                #     'player_notices': [],
                #     'seq_id': 1
                # }
                # server_notice_box_model = memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL, server_notice_box_model)
                memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL, server_notice_box_model)
                print server_notice_box_model
                check_notice_expiry(server_notice_box_model)
                notices_lst = server_notice_box_model['notices']
                if notices_lst:
                    for notice_dict in notices_lst:
                        if notice_dict:
                            notice_uid = notice_dict['uid']
                            # if notice_uid in all_background_notice_dict:
                            #     print("notice_uid: "+str(notice_uid))
                            #     notice_dict['server_id'] = notice_dict.get('server_id','')+","+str(key)
                            # else:
                            #     notice_dict['server_id'] = str(key)
                            all_background_notice_dict[notice_uid] = notice_dict

    print("all_background_notice_dict: "+str(all_background_notice_dict))
    for key_uid, value in all_background_notice_dict.items():
        if value:
            temp_content = []
            temp_content.insert(0,str(key_uid))
            temp_content.insert(1,value['server_id'])
            temp_content.insert(2,str(value['content']))
            temp_content.insert(3,value['start_time'].strftime('%Y-%m-%d %H:%M:%S'))
            temp_content.insert(4,value['expiry_date'].strftime('%Y-%m-%d %H:%M:%S'))
            temp_content.insert(5,str(value['distance_time']))
            table_list.append(temp_content)

    data['notice_info'] = table_list
    data['head_lst'] = head_lst
    return render_to_response("notice/notice_lst.html", data, RequestContext(request))
Exemple #44
0
def notice_update(request):
    """
    更新广播
    """
    if request.method == 'POST':
        content = str(request.POST.get('content'))
        start_time = datetime.datetime.strptime(request.POST.get('start_time'),
                                                "%Y-%m-%d %H:%M:%S")
        end_time = datetime.datetime.strptime(request.POST.get('end_time'),
                                              "%Y-%m-%d %H:%M:%S")
        distance_time = int(request.POST.get('distance_time'))
        str_server_id = str(request.POST.get('server_id'))
        uid = str(request.POST.get('uid'))

        #插入系统邮件
        notice = dict()
        notice['content'] = content
        notice['start_time'] = start_time
        notice['distance_time'] = distance_time
        notice['expiry_date'] = end_time
        notice['server_id'] = str_server_id
        notice['uid'] = uid
        print("notice: " + str(notice))
        server_int_lst = string_split_to_int_list(str_server_id, ',')
        for server_int in server_int_lst:
            cmem_url = server_define.CMEM_MAP[int(server_int)]
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(
                    cmem_url, model_define.NOTICE_MODEL)
                if not server_notice_box_model:
                    server_notice_box_model = {
                        'uid': 'game_notice',
                        'notices': [],
                        'player_notices': [],
                        'seq_id': '20150729_1'
                    }
                add_background_notice(server_notice_box_model, notice)
                print("server_notice_box_model: " +
                      str(server_notice_box_model))
                memcache.put_cmem_val(cmem_url, model_define.NOTICE_MODEL,
                                      server_notice_box_model)

                # 操作日志记录
                manager = GameManager.get_by_request(request)
                insert_action_update_notice(manager, notice)

        return HttpResponseRedirect('/Tyranitar6/server/notice_lst/')
    else:
        return render_to_response("notice/notice_add.html",
                                  RequestContext(request))
def remove_monster(manager, user_id, server_id, uid, star_level, level):
    """
        移除一个怪
    """
    cmem_url = server_define.CMEM_MAP[int(server_id)]
    monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)))
    for mon in monster_model["monsters"]:
        if mon["uid"] == int(uid):
            monster_tid = mon["tid"]
            monster_model["monsters"].remove(mon)
            memcache.put_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)), monster_model)
            # 操作日志记录
            insert_action_delete_monster(manager, server_id, user_id, uid, monster_tid, star_level, level)
            break
Exemple #46
0
def system_mail_del_confirm(request):
    """
    删除邮件确认
    """
    if request.method == 'POST':
        version = str(request.POST.get("version"))
        del_notice_dict = dict()
        all_cmem_dict = server_define.CMEM_MAP
        for key, val in all_cmem_dict.items():
            cmem_url = str(val)
            if cmem_url:
                server_notice_box_model = memcache.get_cmem_val(
                    cmem_url, model_define.SYSTEM_MAIL_BOX_MODEL)
                if server_notice_box_model:
                    memcache.put_cmem_val(cmem_url,
                                          model_define.SYSTEM_MAIL_BOX_MODEL,
                                          server_notice_box_model)
                    print server_notice_box_model
                    check_system_expiry(server_notice_box_model)
                    notices_lst = server_notice_box_model['mails']
                    if notices_lst:
                        for notice_dict in notices_lst:
                            if notice_dict:
                                if version == str(notice_dict['version']):
                                    del_notice_dict = notice_dict
                                    break

        del_notice_dict['send_time'] = str(
            del_notice_dict['send_time'].strftime('%Y-%m-%d %H:%M:%S'))
        del_notice_dict['expiry_date'] = str(
            del_notice_dict['expiry_date'].strftime('%Y-%m-%d %H:%M:%S'))
        item_config = game_config.get_item_config(del_notice_dict['item'])
        if item_config:
            del_notice_dict['item'] = str(item_config['name'])
        else:
            del_notice_dict['item'] = str(u'')

        monster_config = game_config.get_monster_config(
            del_notice_dict['monster'])
        if monster_config:
            del_notice_dict['monster'] = str(monster_config['name'])
        else:
            del_notice_dict['monster'] = str(u'')

        return render_to_response("system_mail/system_mail_del_confirm.html", {
            'system_mail_info': del_notice_dict,
            'head_lst': head_lst
        }, RequestContext(request))
    else:
        return HttpResponseRedirect('/Tyranitar6/server/system_mail_lst/')
def _get_union_chat_content(server_id,union_id,server_list_dat):
    server_id=int(server_id)
    result=[]
    cmem_url=server_define.CMEM_MAP[server_id]
    union_name_dict = _get_union_name_dict(server_list_dat)
    if cmem_url:
        data=memcache.get_cmem_val(cmem_url,model_define.UNION_CHAT_MODEL.format(union_id=union_id))
        if data is not None:
            for _log_line in data['chat_list']:
                union_name=union_name_dict[union_id]
                result.append([time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(_log_line['time'])),union_id,union_name,_log_line['uid'],
                              _log_line['name'].decode('utf-8'),_log_line['lv'],_log_line['vip_level'],
                              decrypt(_log_line['content'],159),server_id])
    return result
Exemple #48
0
def set_memcache(value_dict):
    '''
    修改memcache数据
    '''
    cmem_url = server_define.CMEM_MAP[int(value_dict['server_id'])]
    if cmem_url:
        if len(value_dict['user_id']):
            if  0 > int(value_dict['input_value']) > 60800:
                return False
            source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=value_dict['user_id']))
            for _dict in source['treasure_items']:
                if _dict['uid'] == int(value_dict['item_id']):
                    _dict['level_exp'] = int(value_dict['input_value'])
            result = memcache.put_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=value_dict['user_id']),
                                           source)
            return result
def _get_chat_content(server_id):
    """
         获取聊天信息
    """
    server_id = int(server_id)
    result = []
    cmem_url = server_define.CMEM_MAP[server_id]
    #print cmem_url
    if cmem_url:
        data = memcache.get_cmem_val(cmem_url, model_define.CHAT_MODEL)
        #print data
        for _log_line in data['chat_list']:
            result.append([time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(_log_line['time'])), _log_line['uid'],
                           _log_line['name'].decode('utf-8'), _log_line['lv'], _log_line['vip_level'],
                           decrypt(_log_line['content'], 159)])
    return result
def player_commit_bugs_lst(request):
    """
    获取玩家提交的BUG
    """
    server_list_dat = server_list.get_server_list_dat()
    data = {}
    data['head_lst'] = head_lst
    data['server_list'] = server_list_dat
    if request.POST.get('server_id'):
        server_id = int(request.POST.get('server_id'))
        table_list = []
        all_background_notice_lst = []

        cmem_url = str(server_define.CMEM_MAP.get(server_id))
        if cmem_url:
            player_commit_bugs_model = memcache.get_cmem_val(cmem_url, model_define.PLAYER_COMMIT_BUGS_MODEL)
            if player_commit_bugs_model:
                # memcache.put_cmem_val(cmem_url, model_define.PLAYER_COMMIT_BUGS_MODEL, server_notice_box_model)
                print player_commit_bugs_model
                bug_lst = get_bugs(player_commit_bugs_model)
                if bug_lst:
                    for bug_dict in bug_lst:
                        if bug_dict:
                            all_background_notice_lst.append(bug_dict)

        print("all_background_notice_lst: "+str(all_background_notice_lst))
        for bug_dict in all_background_notice_lst:
            if bug_dict:
                temp_content = []
                temp_content.insert(0,str(bug_dict['user_uid']))
                temp_content.insert(1,str(bug_dict['user_open_id']))
                temp_content.insert(2,str(bug_dict['player_name']))
                temp_content.insert(3,str(bug_dict['commit_time']))
                temp_content.insert(4,str(bug_dict['describe']))
                if bug_dict.get('handle',False):
                    temp_content.insert(5,"已回信")
                else:
                    temp_content.insert(5,"需要回信")
                table_list.append(temp_content)

        data['player_commit_bugs'] = table_list
        data['server_id'] = server_id
        print data
        return render_to_response("player_commit_bugs/player_commit_bugs_lst.html", data, RequestContext(request))
    else:
        data['player_commit_bugs'] = []
        return render_to_response("player_commit_bugs/player_commit_bugs_lst.html", data, RequestContext(request))
Exemple #51
0
def del_item(value_dict):
    '''
    删除物品
    '''
    user_id = int(value_dict['user_id'])
    item_tid = int(value_dict['item_id'])
    server_id = int(value_dict['server_id'])
    cmem_url = server_define.CMEM_MAP[server_id]
    if cmem_url:
        source = memcache.get_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_id))
        for _dict in source['treasure_items']:
            if item_tid == _dict['uid']:
                source['treasure_items'].remove(_dict)
        result = memcache.put_cmem_val(cmem_url, model_define.TREASURE_ITEM_MODEL.format(user_id=user_id),source)
        return result
    else:
        return False