Esempio n. 1
0
def get_first_charge_award_info(rk_user, params):
    first_charge_award = game_config.operat_config.get('first_charge_award',
                                                       {})
    award_info = []
    for thing_id, num in first_charge_award.items():
        award_info.append(tools.pack_good(thing_id, num))
    return {"award": award_info}
Esempio n. 2
0
def show_mails(rk_user, params):
    """
    获取邮件列表
    'type': 'system': 系统邮件
    'type': 'pvp'   : pvp邮件 
    Returns:
        {'show_mails': 
            {1: {'awards': [
                    {'equipSoul': {'equip_type': u'1', 'good_id': u'53003_equip', 'num': 1}},                
                    {'mat': {'good_id': u'3_mat', 'num': 2}},
                    {'gold': {'good_id': u'gold', 'num': 10}},
                    {'props': {'good_id': u'1_props', 'num': 1}},
                    {'equip': {'color': u'green', 'good_id': u'13001_equip', 'num': 3}},
                    {'cardSoul': {'good_id': u'5_card', 'num': 1}},
                    {'fight_soul': {'good_id': u'fight_soul', 'num': 100}},
                    {'card': {'good_id': u'5_card', 'num': 1}},
                    {'honor': {'good_id': u'honor', 'num': 100}},
                    {'equipSoul': {'good_id': u'12002_equip', 'num': 1}}
                ],
                'can_get': True,
                'content': u'5345',
                'create_time': u'2014-11-04 11:32:56',
                'mid': u'201411041132562390414',
                'type': u'system'},
            2:  ......
    """
    data = {}
    all_info = UserMail.hgetall(rk_user.uid)
    expire_days = game_config.mail_config.get('expire_days', 2)
    clear_date = (datetime.datetime.now() - datetime.timedelta(days=expire_days)).strftime('%Y-%m-%d %H:%M:%S')
    # 根据创建时间排序
    key_create_time_list = [(m, all_info[m]['mail_info'].get('create_time', ''), 
                            all_info[m]['mail_info'].get('open_time')) for m in all_info]

    key_create_time_list = sorted(key_create_time_list , key=lambda key_time: key_time[1], reverse=True)
    for index, key_create_time in enumerate(key_create_time_list):
        key, create_time, open_time = key_create_time
        mail_info = all_info[key]['mail_info']
        can_get = mail_info.get('can_get', False)
        print 'create time:', create_time,  'open time:',open_time,  ' can get:', can_get
        if can_get is False and clear_date > open_time:
        #if can_get is False:
            umobj = UserMail.hget(rk_user.uid, key)
            umobj.delete()
            continue

        this_data = {
            'type': mail_info['type'],
            'title': mail_info['title'],
            'content': mail_info['content'],
            'can_get': mail_info['can_get'],
            'awards': [tools.pack_good(good, num) for good, num in mail_info['awards'].items()],
            'create_time': mail_info['create_time'],
            #'mid': mail_info['mid'],
            'mid': key,
        }
        data[index + 1] = this_data
    #print data
    return {'show_mails': data}
Esempio n. 3
0
def _pack_store_info(store_info):
    store_info = copy.deepcopy(store_info)
    for each_good_info in store_info["store"]:
        good_id = each_good_info["goods"]["_id"]
        num = each_good_info["goods"]["num"]
        pack = tools.pack_good(good_id, num)
        each_good_info["goods"] = pack
    return store_info
Esempio n. 4
0
def _pack_store_info(store_info, has_bought_ids):
    store_info = copy.deepcopy(store_info)
    for vip_level, good_info in store_info.items():
        good_info["has_bought"] = (vip_level in has_bought_ids)
        goods_list = []
        for good_id, num in good_info['goods_list'].items():
            goods_list.append(tools.pack_good(good_id, num))
        good_info['goods_list'] = goods_list
    return store_info
Esempio n. 5
0
def _pack_store_info(store_info, has_bought_ids):
    store_info = copy.deepcopy(store_info)
    for vip_level, good_info in store_info.items():
        good_info["has_bought"] = (vip_level in has_bought_ids)
        goods_list = []
        for good_id, num in good_info['goods_list'].items():
            goods_list.append(tools.pack_good(good_id, num))
        good_info['goods_list'] = goods_list
    return store_info
Esempio n. 6
0
def _pack_store_info(store_info):
    store_info = copy.deepcopy(store_info)
    for each_good_info in store_info["pk_store"]:
        if not isinstance(each_good_info, dict):
            continue
        good_id = each_good_info["goods"]["_id"]
        num = each_good_info["goods"]["num"]
        pack = tools.pack_good(good_id, num)
        each_good_info["goods"] = pack
    return store_info
Esempio n. 7
0
def _pack_store_info(store_info):
    store_info = copy.deepcopy(store_info)
    for each_good_info in store_info["pk_store"]:
        if not isinstance(each_good_info, dict):
            continue
        good_id = each_good_info["goods"]["_id"]
        num = each_good_info["goods"]["num"]
        pack = tools.pack_good(good_id, num)
        each_good_info["goods"] = pack
    return store_info
Esempio n. 8
0
def show_mails(rk_user, params):
    """
    获取邮件列表
    'type': 'system': 系统邮件
    'type': 'pvp'   : pvp邮件 
    Returns:
        {'show_mails': 
            {1: {'awards': [
                    {'equipSoul': {'equip_type': u'1', 'good_id': u'53003_equip', 'num': 1}},                
                    {'mat': {'good_id': u'3_mat', 'num': 2}},
                    {'gold': {'good_id': u'gold', 'num': 10}},
                    {'props': {'good_id': u'1_props', 'num': 1}},
                    {'equip': {'color': u'green', 'good_id': u'13001_equip', 'num': 3}},
                    {'cardSoul': {'good_id': u'5_card', 'num': 1}},
                    {'fight_soul': {'good_id': u'fight_soul', 'num': 100}},
                    {'card': {'good_id': u'5_card', 'num': 1}},
                    {'honor': {'good_id': u'honor', 'num': 100}},
                    {'equipSoul': {'good_id': u'12002_equip', 'num': 1}}
                ],
                'can_get': True,
                'content': u'5345',
                'create_time': u'2014-11-04 11:32:56',
                'mid': u'201411041132562390414',
                'type': u'system'},
            2:  ......
    """
    data = {}
    all_info = UserMail.hgetall(rk_user.uid)
    expire_days = game_config.mail_config.get('expire_days', 2)
    clear_date = (
        datetime.datetime.now() -
        datetime.timedelta(days=expire_days)).strftime('%Y-%m-%d %H:%M:%S')
    # 根据创建时间排序
    key_create_time_list = [
        (m, all_info[m]['mail_info'].get('create_time', ''),
         all_info[m]['mail_info'].get('open_time', '9999-99-99 99:99:99'))
        for m in all_info
    ]

    key_create_time_list = sorted(key_create_time_list,
                                  key=lambda key_time: key_time[1],
                                  reverse=True)
    for index, key_create_time in enumerate(key_create_time_list):
        key, create_time, open_time = key_create_time
        mail_info = all_info[key]['mail_info']
        can_get = mail_info.get('can_get', False)

        if can_get is False and clear_date > open_time:
            #if can_get is False:
            umobj = UserMail.hget(rk_user.uid, key)
            umobj.delete()
            continue

        this_data = {
            'type':
            mail_info['type'],
            'title':
            mail_info['title'],
            'content':
            mail_info['content'],
            'can_get':
            mail_info['can_get'],
            'awards': [
                tools.pack_good(good, num)
                for good, num in mail_info['awards'].items()
            ],
            'create_time':
            mail_info['create_time'],
            'mid':
            mail_info['mid'],
        }
        data[index + 1] = this_data
    return {'show_mails': data}
Esempio n. 9
0
def get_first_charge_award_info(rk_user, params):
    first_charge_award = game_config.operat_config.get("first_charge_award", {})
    award_info = []
    for thing_id, num in first_charge_award.items():
        award_info.append(tools.pack_good(thing_id, num))
    return {"award": award_info}