예제 #1
0
def get_sign_in_gift(rk_user, params):
    '''
    领取签到奖励
    params['day'] 代表第几次签到,如果当月已签到3次则day应该是4
    '''
    day = params['day']
    ug = rk_user.user_gift
    now = datetime.datetime.now()
    month = str(now.month)
    today = str(now.day)
    
    if ug.sign_in_record[day]['has_got']:
        return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}
    # 一天只能领一次
    if ug.sign_in_record[today].get('today_has_signed_in', False):
        return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')}
    # 不能跳领,必须一天一个按顺序领
    if day != str(ug.total_sign_days + 1):
        return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}
    # 添加奖励
    conf = game_config.loginbonus_config['sign_in_bonus']
    award = conf.get(month, conf[conf.keys()[0]]).get(day, {})  # 容错处理,没配置当月的话取配置里的第一个

    data = tools.add_things(
        rk_user, 
        [{"_id": goods, "num": award[goods]} for goods in award if goods],
        where="sign_in_gift"
    )
    #  用来给前端显示是否已领取,这时sign_in_record的下一层字段代表签到天数
    ug.sign_in_record[day]['has_got'] = True
    #  每天只能签到一次,此字段用来后端判断当天是否已签到过,这时sign_in_record的下一层字段代表日期
    ug.sign_in_record[today]['today_has_signed_in'] = True
    ug.put()

    return 0, data
예제 #2
0
def get_open_server_gift(rk_user, params):
    '''
    领取开服礼包中的奖励
    参数
        params['day'] 第几次领
    '''
    day = params['day']
    ug = rk_user.user_gift
    ul = rk_user.user_login
    awards = game_config.loginbonus_config['open_server_gift'].get('awards', {})
    if day not in awards.keys():
        return 11, {'msg': utils.get_msg('gift', 'gift_not_exist')}
    the_gift = ug.open_server_record['gifts'][day]
    if the_gift['has_got']:
        return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}
    # 一天只能领一次
    today = utils.get_today_str()
    if ug.open_server_record['date_info'].get(today, False):
        return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')}
    # 按顺序领取
    if int(day) != ug.total_open_days+1:
        return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}
    this_award = awards[day]
    data = tools.add_things(
        rk_user, 
        [{"_id": goods, "num": this_award[goods]} for goods in this_award if goods],
        where="open_server_gift"
    )
    
    the_gift['has_got'] = True
    # 因为每天只能领取一次,'date_info'用来按日期记录哪天是否已领过一次
    ug.open_server_record['date_info'][today] = True 
    ug.put()
    return 0, data
예제 #3
0
 def froze(self):
     """冻结账户,前两次按时间,累计三次之后永久
     """
     msg = ''
     if self.in_frozen:
         return ''
     frozen_count = self.baseinfo.get('frozen_count',0)
     if frozen_count:
         self.baseinfo['frozen_count'] += 1
     else:
         self.baseinfo['frozen_count'] = 1
     #首次冻结2天,再次7天,3次永久
     now = datetime.datetime.now()
     if self.baseinfo['frozen_count'] == 1:
         frozen_days = 2
         self.baseinfo['unfroze_time'] = utils.datetime_toTimestamp(now + datetime.timedelta(days=frozen_days))
         msg = get_msg('login','frozen_time', self)
         msg = msg % (frozen_days,utils.timestamp_toString(self.baseinfo['unfroze_time'],'%m.%d %H:%M'),self.uid)
     elif self.baseinfo['frozen_count'] == 2:
         frozen_days = 7
         self.baseinfo['unfroze_time'] = utils.datetime_toTimestamp(now + datetime.timedelta(days=frozen_days))
         msg = get_msg('login','frozen_time', self)
         msg = msg % (frozen_days,utils.timestamp_toString(self.baseinfo['unfroze_time'],'%m.%d %H:%M'),self.uid)
     else:
         self.baseinfo['frozen'] = True
         self.baseinfo['username'] = u'(已冻结)' + self.baseinfo['username']
         msg = get_msg('login','frozen', self) % self.uid
     self.put()
     return msg
예제 #4
0
def gold(rk_user,params):
    """
    消耗金币抽将
    """
    user_card_obj = UserCards.get_instance(rk_user.uid)
    #需要的金币
    cost_gacha_gold = game_config.gacha_config['cost_gacha_gold']
    if not rk_user.user_property.is_gold_enough(cost_gacha_gold):
        return 11,{'msg':utils.get_msg('user','not_enough_gold')}
    rate_conf = __get_rate_conf('gold',rk_user)
    cid,clv = __select_gacha_thing(rate_conf)
    #扣除抽奖的金币
    if rk_user.user_property.minus_gold(cost_gacha_gold):
        #加卡
        success_fg,p1,ucid,is_first = user_card_obj.add_card(cid,clv,where='gacha_gold')
        new_card = {
            'ucid':ucid,
            'is_first':is_first,
        }
        new_card.update(user_card_obj.get_card_dict(ucid))
        #写入跑马灯
        user_marquee_obj = UserMarquee.get(rk_user.subarea)
        marquee_params = {
            'type': 'gacha_gold',
            'username': rk_user.username,
            'cid': cid,
        }
        user_marquee_obj.record(marquee_params)
        return 0,{'new_card':new_card}
    else:
        #金币不够
        return 11,{'msg':utils.get_msg('user','not_enough_gold')}
예제 #5
0
def get_invite_award(rk_user,params):
    """新手的邀请奖励
    """
    invite_code = params['invite_code']
    uid = _check_invite_code(rk_user,invite_code)
    friend_obj = Friend.get(rk_user.uid)
    if uid and not friend_obj.invite_info['inviter']:
        #记录邀请新手的老玩家信息
        friend_obj.invite_info['inviter'] = uid
        friend_obj.put()

        data_log_mod.set_log('Invite', rk_user, inviter=uid, invited=rk_user.uid)

        #邀请者总邀请数增加
        inviter_friend = Friend.get(uid)
        inviter_friend.invite_info['total_invited_usernum'] += 1
        inviter_friend.record_invited_user(rk_user.uid,rk_user.user_property.lv)
        inviter_friend.put()
        #发邀请奖励
        invited_award = game_config.invite_config['invited_award']
        user_gift_obj = UserGift.get_instance(rk_user.uid)
        user_gift_obj.add_gift(invited_award,utils.get_msg('friend','invited_award_words'))
    else:
        if not uid:
            return 11,{'msg':utils.get_msg('friend', 'invalid_invite_code')}
        else:
            return 11,{'msg':utils.get_msg('friend', 'invite_code_only_once')}
    return 0,{}
예제 #6
0
def refresh_store_by_self():
    '''
    手动刷新 pk 商店
    '''
    upk = UserPkStore.get_instance(uid)
    user_real_pvp = UserRealPvp.get_instance(uid)

    if not upk.can_manual_refresh():
        print 'can_not_refresh'
        return 11, {'msg': utils.get_msg('pk_store','can_not_refresh')}
    # 玩家所拥有的功勋点不够一次刷新
    #refresh_need_honor = game_config.pk_store_config['refresh_need_honor']
    # 玩家所拥有的功勋点不够一次刷新
    refresh_times = str(upk.manual_refresh_times + 1) # 指第几次刷新,第一次刷新时manual_refresh_times 是 0
    refresh_need_honor = game_config.pk_store_config['refresh_need_honor'].get(refresh_times, 1)
    if not user_real_pvp.is_honor_enough(refresh_need_honor):
        return 11, {'msg': utils.get_msg('pk_store','not_enough_honor')}

    user_real_pvp.minus_honor(refresh_need_honor)
    upk.add_refresh_time()
    data = upk.refresh_store_goods()
    user_real_pvp.do_put()
    upk.do_put()
    
    return 0, _pack_store_info(upk.store_info())
예제 #7
0
def search_friend(rk_user,params):
    """查找好友
    """
    fid = params['fid']
    try:
        fid = str(fid)
    except:
        return 11,{'msg':utils.get_msg('friend','invalid_fid')}
    friend_user = UserBase.get(fid)
    if not friend_user:
        return 11,{'msg':utils.get_msg('user','no_user')}
    friend_friend_obj = Friend.getEx(fid)
    friend_property = UserProperty.get(fid)
    leader_card = friend_property.leader_card
    user_pvp_obj = UserPvp.getEx(fid)
    if user_pvp_obj:
        pvp_title = user_pvp_obj.pvp_title
    else:
        pvp_title = ''
    data = {
        'friend_info':{
            'fid':fid,
            'name':friend_user.username,
            'country':friend_property.country,
            'leader_card':leader_card,
            'lv':friend_property.lv,
            'max_friend_num':friend_property.max_friend_num,
            'now_friend_num':friend_friend_obj.friend_num,
            'signature':friend_user.signature,
            'pvp_title':pvp_title,
        }
    }
    return 0,data
예제 #8
0
def add_stamina(rk_user,params):
    '''
    * 使用体力丹回复体力
    miaoyichao
    '''
    cost_props_param = params.get('cost_props')
    cost_props = cost_props_param.split(',')
    cost_props = utils.remove_null(cost_props)
    user_pack_obj = UserPack.get_instance(rk_user.uid)
    cost_props_copy = {}
    get_stamina = 0
    for cost in cost_props:
        props_id = cost.split(':')[0]
        num = int(cost.split(':')[1])
        #判断props的用途是否是增加体力的
        if not game_config.props_config[props_id].get('used_by','') == 'stamina':
            return 11,{'msg':utils.get_msg('pack', 'wrong_used')}
        #判断道具数量是否足够
        if not user_pack_obj.is_props_enough(props_id,num):
            return 11,{'msg':utils.get_msg('pack', 'not_enough_props')}
        #道具数量足够的话就开始整理道具
        cost_props_copy[props_id] = num
        #默认没取到的时候 增加的体力值是0
        get_stamina += int(game_config.props_config[props_id].get('stamina_num',0))*num
    #扣除道具
    user_pack_obj.minus_multi_props(cost_props_copy,where='pack.add_stamina')
    #增加体力
    rk_user.user_property.add_stamina(get_stamina)
    #结果返回
    return 0,{'get_stamina':get_stamina}
예제 #9
0
def card_stove(rk_user, params):
    """
    炼化
    """
    sell_ucids = params.get('sell_ucids')
    if not sell_ucids:
        return 11, {'msg': utils.get_msg('card', 'no_cost_card')}
    sell_ucids = sell_ucids.split(',')
    sell_ucids = utils.remove_null(sell_ucids)
    user_card_obj = UserCards.get(rk_user.uid)
    #检查武将是否存在
    for ucid in sell_ucids:
        if ucid and not user_card_obj.has_card(ucid):
            return 11, {'msg': utils.get_msg('card', 'no_card')}
    #带装备武将不允许卖出
    if user_card_obj.is_equip_used(sell_ucids):
        return 11, {'msg': utils.get_msg('equip', 'is_used')}
    #被锁定武将不能卖出
    if user_card_obj.is_locked(sell_ucids):
        return 11, {'msg': utils.get_msg('card', 'locked')}
    #检查武将是否在deck中
    rc, msg = check_card_in_deck(user_card_obj, sell_ucids)
    if rc:
        return rc, {'msg': msg}
    sell_cards = [user_card_obj.get_card_info(ucid) for ucid in sell_ucids]
    return 0, {'cards_info': sell_cards, 'cards_ucids': sell_ucids}
예제 #10
0
def banquet_info(rk_user, params):
    """
    * 获取美味大餐的相关内容
    * 获取探索的相关内容
    * 获得成长礼包的信息
    """

    ua = rk_user.user_activity
    user_banquet_info = ua.banquet_info
    now = datetime.datetime.now()
    now_date_day = now.strftime('%Y-%m-%d')
    now_hour_min = now.strftime('%H:%M')
    banquet_info = {'banquet_msgs': [], 'can_get': False, 'desc': {}}
    banquet_info['banquet_interval'] = []
    open_time_gaps = game_config.operat_config.get('open_stamina_banquet_gaps',
                                                   [])
    #获取开放的时间   设置标志位
    for gap in open_time_gaps:
        time_msg = gap[0] + ' -- ' + gap[1] + ':'
        if user_banquet_info.get(gap):
            open_msg = utils.get_msg('active', 'already_banquet')
        elif gap[0] <= now_hour_min <= gap[1]:
            open_msg = utils.get_msg('active', 'in_time')
            banquet_info['can_get'] = True
        else:
            open_msg = utils.get_msg('active', 'not_in_time')
        banquet_info['banquet_msgs'].append(time_msg + open_msg)
        banquet_info['desc'][time_msg[:-1]] = open_msg
        time_start = '%s %s:00' % (now_date_day, str(gap[0]))
        time_end = '%s %s:00' % (now_date_day, str(gap[1]))
        start_time = utils.string_toTimestamp(time_start)
        end_time = utils.string_toTimestamp(time_end)
        banquet_info['banquet_interval'].append(start_time)
        banquet_info['banquet_interval'].append(end_time)
    time_lists = sorted(
        [str(time_list) for time_list in banquet_info['banquet_interval']])
    banquet_info['am_start'] = time_lists[0]
    banquet_info['am_end'] = time_lists[1]
    banquet_info['pm_start'] = time_lists[2]
    banquet_info['pm_end'] = time_lists[3]
    banquet_info.pop('banquet_interval')
    banquet_info['am_flag'] = user_banquet_info.get(banquet_info['am_start'],
                                                    False)
    banquet_info['pm_flag'] = user_banquet_info.get(banquet_info['pm_start'],
                                                    False)

    # 获取探索的相关内容
    # explore_info = get_explore_info(rk_user)

    # 获取成长礼包相关内容
    growup_info = get_growup_info(rk_user, params)
    # 判断新手引导
    newbie_step = int(params.get('newbie_step', 0))
    if newbie_step:
        rk_user.user_property.set_newbie_steps(newbie_step, "banquet_info")
    return {
        'banquet_info': banquet_info,
        # 'explore_info': explore_info,
        'growup_info': growup_info,
    }
예제 #11
0
def add_exp_point(rk_user,params):
    '''
    添加经验点接口
    根据用户提交的道具 id 给用户添加经验点
    '''
    props_id = params['props_id']
    num = int(params['num'])
    #根据 id 获取道具的使用途径
    props_id_config = game_config.props_config.get(props_id,{})
    used_by = props_id_config.get('used_by','')
    #判断使用的用途
    if used_by != 'card':
        return 11,{'msg':utils.get_msg('pack', 'wrong_used')}
    #判断用户道具是否足够
    user_pack_obj = UserPack.get_instance(rk_user.uid)
    if not user_pack_obj.is_props_enough(props_id,num):
        return 11,{'msg':utils.get_msg('pack', 'not_enough_props')}
    #计算经验点数
    add_exp_point = int(num*props_id_config.get('exp',0))
    #所有条件都满足的话  删除道具 添加经验点
    user_pack_obj.minus_props(props_id,num,where='add_exp_point')
    user_property_obj = UserProperty.get(rk_user.uid)
    user_property_obj.add_card_exp_point(add_exp_point, "by_props")
    #结果返回
    return 0,{'add_exp_point':add_exp_point}
예제 #12
0
def get_banquet_stamina():
    """
    开始宴席
    params:
        click_num:  玩家点击次数,据此来算玩家回体数
    """
    open_time_gaps = game_config.operat_config.get('open_stamina_banquet_gaps', [])
    now = datetime.datetime.now()
    now_date_day = now.strftime('%Y-%m-%d')
    now_hour_min = now.strftime('%H:%M')
    this_time_gap = utils.between_gap(now_hour_min, open_time_gaps)
    if not this_time_gap:
        return 11,{'msg':utils.get_msg('active', 'not_in_time')}
    #获取时间区间的最小值
    time_start = '%s %s:00'%(now_date_day,str(this_time_gap[0]))
    start_time = utils.string_toTimestamp(time_start)
    #查询是否已经领取体力
    ul = UserLogin.get_instance(uid)
    ul.banquet_info[str(start_time)] = False
    ul.do_put()
    banquet_info = ul.banquet_info
    if banquet_info.get(str(start_time), False):
        return 11, {'msg':utils.get_msg('active', 'already_banquet')}
    #根据点击次数获取可以领取多少体力
    click_num = 30
    click_num_awards_conf = game_config.operat_config.get('banquet_click_num_awards', {})
    suitable_gap = utils.between_gap(click_num, click_num_awards_conf)
    get_stamina = click_num_awards_conf.get(suitable_gap, 0)
    user_property = UserProperty.get_instance(uid)   
    user_property.add_stamina(get_stamina)
    print get_stamina
    return {'add_stamina': get_stamina}
예제 #13
0
def get_banquet_stamina(rk_user, params):
    """
    开始宴席
    """
    open_time_gaps = game_config.operat_config.get('open_stamina_banquet_gaps',
                                                   [])
    now = datetime.datetime.now()
    now_date_day = now.strftime('%Y-%m-%d')
    now_hour_min = now.strftime('%H:%M')
    this_time_gap = utils.between_gap(now_hour_min, open_time_gaps)
    if not this_time_gap:
        return 11, {'msg': utils.get_msg('active', 'not_in_time')}
    # 获取时间区间的最小值
    time_start = '%s %s:00' % (now_date_day, str(this_time_gap[0]))
    start_time = utils.string_toTimestamp(time_start)
    #查询是否已经领取体力
    ua = rk_user.user_activity
    banquet_info = ua.banquet_info
    if banquet_info.get(str(start_time), False):
        return 11, {'msg': utils.get_msg('active', 'already_banquet')}
    # 获取可以领取多少体力
    get_stamina = game_config.operat_config.get('banquet_click_get_stamina',
                                                50)
    #  运营活动  特定时间内收益翻倍
    multiply_income_conf = rk_user.game_config.operat_config.get(
        "multiply_income", {}).get("banquet", {})
    get_stamina = get_stamina * multiply_income(multiply_income_conf)
    ua.banquet_info[str(start_time)] = True
    ua.put()
    rk_user.user_property.add_stamina(get_stamina)
    return 0, {'add_stamina': get_stamina}
예제 #14
0
def get_invite_award(rk_user, params):
    """新手的邀请奖励
    """
    invite_code = params["invite_code"]
    uid = _check_invite_code(rk_user, invite_code)
    friend_obj = Friend.get(rk_user.uid)
    if uid and not friend_obj.invite_info["inviter"]:
        # 记录邀请新手的老玩家信息
        friend_obj.invite_info["inviter"] = uid
        friend_obj.put()

        data_log_mod.set_log("Invite", rk_user, inviter=uid, invited=rk_user.uid)

        # 邀请者总邀请数增加
        inviter_friend = Friend.get(uid)
        inviter_friend.invite_info["total_invited_usernum"] += 1
        inviter_friend.record_invited_user(rk_user.uid, rk_user.user_property.lv)
        inviter_friend.put()
        # 发邀请奖励
        invited_award = game_config.invite_config["invited_award"]
        user_gift_obj = UserGift.get_instance(rk_user.uid)
        user_gift_obj.add_gift(invited_award, utils.get_msg("friend", "invited_award_words"))
    else:
        if not uid:
            return 11, {"msg": utils.get_msg("friend", "invalid_invite_code")}
        else:
            return 11, {"msg": utils.get_msg("friend", "invite_code_only_once")}
    return 0, {}
예제 #15
0
def search_friend(rk_user, params):
    """查找好友
    """
    fid = params["fid"]
    try:
        fid = str(fid)
    except:
        return 11, {"msg": utils.get_msg("friend", "invalid_fid")}
    friend_user = UserBase.get(fid)
    if not friend_user:
        return 11, {"msg": utils.get_msg("user", "no_user")}
    friend_friend_obj = Friend.getEx(fid)
    friend_property = UserProperty.get(fid)
    leader_card = friend_property.leader_card
    user_pvp_obj = UserPvp.getEx(fid)
    if user_pvp_obj:
        pvp_title = user_pvp_obj.pvp_title
    else:
        pvp_title = ""
    data = {
        "friend_info": {
            "fid": fid,
            "name": friend_user.username,
            "country": friend_property.country,
            "leader_card": leader_card,
            "lv": friend_property.lv,
            "max_friend_num": friend_property.max_friend_num,
            "now_friend_num": friend_friend_obj.friend_num,
            "signature": friend_user.signature,
            "pvp_title": pvp_title,
        }
    }
    return 0, data
예제 #16
0
def recover_copy():
    """
    * 重置副本次数
    """
    rk_user = UserBase.get(uid)
    recover_copy_coin = game_config.system_config['recover_copy_coin']
    #检查vip可以回复的次数到了没
    if not vip.check_limit_recover(rk_user,'recover_copy'):
        return 11,{'msg':utils.get_msg('user','max_recover_copy_times')}
    else:
        try:
            #检测参数是否合法
            dungeon_type = 'normal' 
            floor_id = '1' 
            room_id  = '1' 
        except:
            return 11,{'msg':utils.get_msg('dungeon','invalid_dungeon_info')}
        #检查用户coin是否足够
        if not rk_user.user_property.minus_coin(recover_copy_coin, 'recover_copy'):
            return 11,{'msg':utils.get_msg('user','not_enough_coin')}
        #添加回复次数
        rk_user.user_property.add_recover_times('recover_copy',dungeon_type)
        user_dungeon_obj = UserDungeon.get(rk_user.uid)
        user_dungeon_obj.recover_copy(dungeon_type,floor_id,room_id)

        rk_user.user_property.do_put()
        user_dungeon_obj.do_put()
        return 0,{}
예제 #17
0
def _bind_new_platform(request, platform_name, platform_openId, old_account,
                       result):
    subarea = request.REQUEST.get("subarea", "1")
    fg = False
    msg = ''
    pid = md5.md5(platform_name + str(platform_openId)).hexdigest()
    #检查新账户是否已经被关联
    account_mapping_obj = AccountMapping.get(pid)
    if account_mapping_obj:
        msg = get_msg('login', 'already_bind')
        return fg, pid, msg
    #检查被绑定用户类型是否是oc
    old_user_obj = UserBase.get(old_account.get_subarea_uid(subarea))
    if old_user_obj.baseinfo['platform'] != 'oc':
        msg = get_msg('login', 'already_bind')
        return fg, pid, msg
    fg = True
    #创建新账户,将旧账户uid关联到新账户后,删除旧账户
    account_mapping_obj = AccountMapping.create(pid)
    account_mapping_obj.subarea_uids = old_account.subarea_uids
    account_mapping_obj.put()
    #删除oc账户
    old_account.delete()
    #给request安装用户
    request.rk_user = UserBase._install(pid, platform_name, subarea=subarea)
    request.rk_user.baseinfo['pid'] = pid
    request.rk_user.baseinfo['platform'] = platform_name
    request.rk_user.baseinfo['bind_time'] = int(time.time())
    request.rk_user.put()
    update_function = request.rk_user.update_platform_openid(
        platform_name, platform_openId)
    if update_function:
        update_function(result)
    return fg, pid, msg
예제 #18
0
def auth_bind_for_qq(request, access_token, openid, bind_access_token,
                     bind_openid):
    """论证qq开放平台账号绑定
    """
    fg = False
    pid = ''
    msg = ''
    user_info_url = 'https://open.t.qq.com/api/user/info?format=json&oauth_consumer_key=%s&access_token=%s&openid=%s&oauth_version=2.a&scope=all' % (
        settings.QQ_APP_ID, access_token, openid)

    #检查被绑定的oneclick账号是否合法
    if not check_openid(bind_openid):
        msg = get_msg('login', 'invalid_bind')
        return fg, msg, pid
    account = AccountMapping.get(bind_openid)
    if account and account.access_token == bind_access_token:
        url_request = urllib2.urlopen(str(user_info_url), timeout=12)
        rc = url_request.code
        res = url_request.read()
        res = res.strip()
        res = res.replace('false', 'False')
        res = res.replace('true', 'True')
        res = res.replace('null', 'None')
        if rc == 200:
            exec('result = %s' % res)
            if not result['ret']:
                get_openid = str(result['data']['openid'])
                if get_openid == openid:
                    fg, pid, msg = _bind_new_platform(request, 'qq', openid,
                                                      account, result)
                    return fg, pid, msg
    else:
        msg = get_msg('login', 'invalid_bind')
    return fg, pid, msg
예제 #19
0
파일: stove.py 프로젝트: wzgdavid/myCoding
def card_stove():
    """
    炼化
    """
    game_config.subareas_conf()
    game_config.set_subarea('1')
    #sell_ucids = params['sell_ucids']
    user_property_obj = UserProperty.get_instance(uid)
    sell_ucids = '201410161423224907513'
    if not sell_ucids:
        return 11,{'msg':utils.get_msg('card','no_cost_card')}
    sell_ucids = sell_ucids.split(',')
    sell_ucids = utils.remove_null(sell_ucids)
    user_card_obj = UserCards.get(uid)
    #检查武将是否存在
    for ucid in sell_ucids:
        if ucid and not user_card_obj.has_card(ucid):
            return 11,{'msg':utils.get_msg('card','no_card')}
    #如果有主角卡,则不能消耗
    if user_property_obj.leader_role_card in sell_ucids:
        return 11,{'msg':utils.get_msg('card','role_card')}
    #带装备武将不允许卖出
    if user_card_obj.is_equip_used(sell_ucids):
        return 11,{'msg':utils.get_msg('equip','is_used')}
    #被锁定武将不能卖出
    if user_card_obj.is_locked(sell_ucids):
        return 11,{'msg':utils.get_msg('card','locked')}
    #检查武将是否在deck中
    rc,msg = check_card_in_deck(user_card_obj,sell_ucids)
    if rc:
        return rc,{'msg':msg}
    sell_cards = [user_card_obj.cards[ucid] for ucid in sell_ucids]
    return 0,{'cards_info':sell_cards,'cards_ucids':sell_ucids}
예제 #20
0
def _bind_new_platform(request, platform_name, platform_openId, old_account, result):
    subarea = request.REQUEST.get("subarea", "1")
    fg = False
    msg = ''
    pid = md5.md5(platform_name + str(platform_openId)).hexdigest()
    #检查新账户是否已经被关联
    account_mapping_obj = AccountMapping.get(pid)
    if account_mapping_obj:
        msg = get_msg('login', 'already_bind')
        return fg, pid, msg
    #检查被绑定用户类型是否是oc
    old_user_obj = UserBase.get(old_account.get_subarea_uid(subarea))
    if old_user_obj.baseinfo['platform'] != 'oc':
        msg = get_msg('login', 'already_bind')
        return fg, pid, msg
    fg = True
    #创建新账户,将旧账户uid关联到新账户后,删除旧账户
    account_mapping_obj = AccountMapping.create(pid)
    account_mapping_obj.subarea_uids = old_account.subarea_uids
    account_mapping_obj.put()
    #删除oc账户
    old_account.delete()
    #给request安装用户
    request.rk_user = UserBase._install(pid, platform_name, subarea=subarea)
    request.rk_user.baseinfo['pid'] = pid
    request.rk_user.baseinfo['platform'] = platform_name
    request.rk_user.baseinfo['bind_time'] = int(time.time())
    request.rk_user.put()
    update_function = request.rk_user.update_platform_openid(platform_name, platform_openId)
    if update_function:
        update_function(result)
    return fg, pid, msg
예제 #21
0
def auth_bind_for_qq(request,access_token,openid,bind_access_token,bind_openid):
    """论证qq开放平台账号绑定
    """
    fg = False
    pid = ''
    msg = ''
    user_info_url = 'https://open.t.qq.com/api/user/info?format=json&oauth_consumer_key=%s&access_token=%s&openid=%s&oauth_version=2.a&scope=all' % (settings.QQ_APP_ID,access_token,openid)

    #检查被绑定的oneclick账号是否合法
    if not check_openid(bind_openid):
        msg = get_msg('login','invalid_bind')
        return fg,msg,pid
    account = AccountMapping.get(bind_openid)
    if account and account.access_token == bind_access_token:
        url_request = urllib2.urlopen(str(user_info_url), timeout=12)
        rc = url_request.code
        res  = url_request.read()
        res = res.strip()
        res = res.replace('false','False')
        res = res.replace('true','True')
        res = res.replace('null','None')
        if rc == 200:
            exec('result = %s' % res)
            if not result['ret']:
                get_openid = str(result['data']['openid'])
                if get_openid == openid:
                    fg, pid, msg = _bind_new_platform(request, 'qq', openid, account, result)
                    return fg, pid, msg
    else:
        msg = get_msg('login','invalid_bind')
    return fg,pid,msg
예제 #22
0
def add_stamina(rk_user, params):
    '''
    * 使用体力丹回复体力
    miaoyichao
    '''
    cost_props_param = params.get('cost_props')
    cost_props = cost_props_param.split(',')
    cost_props = utils.remove_null(cost_props)
    user_pack_obj = UserPack.get_instance(rk_user.uid)
    cost_props_copy = {}
    get_stamina = 0
    for cost in cost_props:
        props_id = cost.split(':')[0]
        num = int(cost.split(':')[1])
        #判断props的用途是否是增加体力的
        if not game_config.props_config[props_id].get('used_by',
                                                      '') == 'stamina':
            return 11, {'msg': utils.get_msg('pack', 'wrong_used')}
        #判断道具数量是否足够
        if not user_pack_obj.is_props_enough(props_id, num):
            return 11, {'msg': utils.get_msg('pack', 'not_enough_props')}
        #道具数量足够的话就开始整理道具
        cost_props_copy[props_id] = num
        #默认没取到的时候 增加的体力值是0
        get_stamina += int(game_config.props_config[props_id].get(
            'stamina_num', 0)) * num
    #扣除道具
    user_pack_obj.minus_multi_props(cost_props_copy, where='pack.add_stamina')
    #增加体力
    rk_user.user_property.add_stamina(get_stamina)
    #结果返回
    return 0, {'get_stamina': get_stamina}
예제 #23
0
def gold_multi(rk_user,params):
    """
    金币gacha连抽
    """
    user_card_obj = UserCards.get_instance(rk_user.uid)
    #获取配置里面的多次抽将的次数
    multi_gacha_cnt = game_config.gacha_config.get('multi_gacha_cnt',10)
    cost_gacha_gold = int(game_config.gacha_config['cost_gacha_gold'])*int(multi_gacha_cnt)
    if not rk_user.user_property.is_gold_enough(cost_gacha_gold):
        return 11,{'msg':utils.get_msg('user','not_enough_gold')}
    #只可以进行配置要求的次数
    if rk_user.user_property.minus_gold(cost_gacha_gold):
        #抽卡
        rate_conf = __get_rate_conf('gold',rk_user)
        cards = __select_gacha_multi_cards(rate_conf, 10)
        #加卡
        new_cards = []
        for cid,clv in cards:
            success_fg,p1,ucid,is_first = user_card_obj.add_card(cid,clv, where = 'free_multi')
            new_card = {
                'ucid':ucid,
                'is_first':is_first,
            }
            new_card.update(user_card_obj.get_card_dict(ucid))
            new_cards.append(new_card)
        return 0,{'new_cards':new_cards}
    else:
        #金币不够
        return 11,{'msg':utils.get_msg('user','not_enough_gold')}
예제 #24
0
def get_banquet_stamina(rk_user, params):
    """
    开始宴席
    """
    open_time_gaps = game_config.operat_config.get('open_stamina_banquet_gaps', [])
    now = datetime.datetime.now()
    now_date_day = now.strftime('%Y-%m-%d')
    now_hour_min = now.strftime('%H:%M')
    this_time_gap = utils.between_gap(now_hour_min, open_time_gaps)
    if not this_time_gap:
        return 11,{'msg':utils.get_msg('active', 'not_in_time')}
    # 获取时间区间的最小值
    time_start = '%s %s:00'%(now_date_day,str(this_time_gap[0]))
    start_time = utils.string_toTimestamp(time_start)
    #查询是否已经领取体力
    ua = rk_user.user_activity
    banquet_info = ua.banquet_info
    if banquet_info.get(str(start_time), False):
        return 11, {'msg':utils.get_msg('active', 'already_banquet')}
    # 获取可以领取多少体力
    get_stamina = game_config.operat_config.get('banquet_click_get_stamina', 50)
    #  运营活动  特定时间内收益翻倍
    multiply_income_conf = rk_user.game_config.operat_config.get("multiply_income", {}).get("banquet", {})
    get_stamina = get_stamina * multiply_income(multiply_income_conf)
    ua.banquet_info[str(start_time)] = True
    ua.put()
    rk_user.user_property.add_stamina(get_stamina)
    return 0, {'add_stamina': get_stamina}
예제 #25
0
파일: gift.py 프로젝트: wzgdavid/myCoding
def get_open_server_gift(rk_user, params):
    '''
    领取开服礼包中的奖励
    参数
        params['day'] 第几次领
    '''
    #day = params['day']
    day = '5'
    ug = rk_user.user_gift
    ul = rk_user.user_login
    awards = game_config.loginbonus_config['open_server_gift'].get('awards', {})
    if day not in awards.keys():
        return 11, {'msg': utils.get_msg('gift', 'gift_not_exist')}
    the_gift = ug.open_server_record['gifts'][day]
    if the_gift['has_got']:
        return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}
    today = utils.get_today_str()
    if ug.open_server_record['date_info'].get(today, False):
        return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')}
    # 按顺序领取
    if int(day) != _got_days(ug)+1:
        return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}
    data = tools.add_things(
        rk_user, 
        [{"_id": goods, "num": awards[goods]} for goods in awards if goods],
        where="open_server_gift"
    )
    the_gift['has_got'] = True
    # 因为每天只能领取一次,'date_info'用来按日期记录哪天是否已领过一次
    ug.open_server_record['date_info'][today] = True 
    ug.do_put()
    return 0, data
예제 #26
0
파일: gift.py 프로젝트: wzgdavid/myCoding
def get_sign_in_gift(rk_user, params):
    '''
    领取签到奖励
    params['day'] 当月日期,作为id使用
    '''
    day = '5' 
    ug = rk_user.user_gift
    now = datetime.datetime.now()
    month = str(now.month)
    today = str(now.day)
    print ' _get_total_sign_in_days(ug)',  _get_total_sign_in_days(ug)
    if day != str(_get_total_sign_in_days(ug) + 1):
        return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}
    if ug.sign_in_record[day]['has_got']:
        return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}

    if ug.sign_in_record[today].get('today_has_signed_in', False):
        return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')} 
    # 添加奖励
    awards = game_config.loginbonus_config['sign_in_bonus'].get(month, {}).get(day, {})
    data = tools.add_things(
        rk_user, 
        [{"_id": goods, "num": awards[goods]} for goods in awards if goods],
        where="open_server_gift"
    )
    ug.sign_in_record[day]['has_got'] = True
    #  每天只能签到一次,此字段用来后端判断当天是否已签到过
    ug.sign_in_record[today]['today_has_signed_in'] = True
    ug.do_put()    
    rk_user.user_property.do_put()
    rk_user.user_pack.do_put()
    rk_user.user_cards.do_put()
    rk_user.user_equips.do_put()    
    return 0, data
예제 #27
0
def gold(rk_user, params):
    """
    消耗金币抽将
    """
    user_card_obj = UserCards.get_instance(rk_user.uid)
    #需要的金币
    cost_gacha_gold = game_config.gacha_config['cost_gacha_gold']
    if not rk_user.user_property.is_gold_enough(cost_gacha_gold):
        return 11, {'msg': utils.get_msg('user', 'not_enough_gold')}
    rate_conf = __get_rate_conf('gold', rk_user)
    cid, clv = __select_gacha_thing(rate_conf)
    #扣除抽奖的金币
    if rk_user.user_property.minus_gold(cost_gacha_gold):
        #加卡
        success_fg, p1, ucid, is_first = user_card_obj.add_card(
            cid, clv, where='gacha_gold')
        new_card = {
            'ucid': ucid,
            'is_first': is_first,
        }
        new_card.update(user_card_obj.get_card_dict(ucid))
        #写入跑马灯
        user_marquee_obj = UserMarquee.get(rk_user.subarea)
        marquee_params = {
            'type': 'gacha_gold',
            'username': rk_user.username,
            'cid': cid,
        }
        user_marquee_obj.record(marquee_params)
        return 0, {'new_card': new_card}
    else:
        #金币不够
        return 11, {'msg': utils.get_msg('user', 'not_enough_gold')}
예제 #28
0
def gold_multi(rk_user, params):
    """
    金币gacha连抽
    """
    user_card_obj = UserCards.get_instance(rk_user.uid)
    #获取配置里面的多次抽将的次数
    multi_gacha_cnt = game_config.gacha_config.get('multi_gacha_cnt', 10)
    cost_gacha_gold = int(
        game_config.gacha_config['cost_gacha_gold']) * int(multi_gacha_cnt)
    if not rk_user.user_property.is_gold_enough(cost_gacha_gold):
        return 11, {'msg': utils.get_msg('user', 'not_enough_gold')}
    #只可以进行配置要求的次数
    if rk_user.user_property.minus_gold(cost_gacha_gold):
        #抽卡
        rate_conf = __get_rate_conf('gold', rk_user)
        cards = __select_gacha_multi_cards(rate_conf, 10)
        #加卡
        new_cards = []
        for cid, clv in cards:
            success_fg, p1, ucid, is_first = user_card_obj.add_card(
                cid, clv, where='free_multi')
            new_card = {
                'ucid': ucid,
                'is_first': is_first,
            }
            new_card.update(user_card_obj.get_card_dict(ucid))
            new_cards.append(new_card)
        return 0, {'new_cards': new_cards}
    else:
        #金币不够
        return 11, {'msg': utils.get_msg('user', 'not_enough_gold')}
예제 #29
0
 def get_monthCard_bonus(self):
     user_property_obj = self.user_property
     property_info = user_property_obj.property_info
     monthCard_remain_days = property_info.get('monthCard_remain_days', {})
     if not monthCard_remain_days:
         return {}
     monthCard_bonus = {}
     title = utils.get_msg('charge', 'monthCard_mail_title')
     content = utils.get_msg('charge', 'monthCard_mail_content')
     monthCard_sale_conf = self.game_config.shop_config['monthCard']
     for monthCard in monthCard_remain_days:
         if monthCard in monthCard_sale_conf and monthCard_remain_days[
                 monthCard] > 0:
             monthCard_remain_days[monthCard] -= 1
             award = {
                 'coin':
                 monthCard_sale_conf[monthCard]['eachday_return_coin']
             }
             monthCard_bonus[monthCard] = {
                 'title': title,
                 'content': content % monthCard_remain_days[monthCard],
                 'award': award
             }
             if monthCard_remain_days[monthCard] == 0:
                 monthCard_remain_days.pop(monthCard)
     user_property_obj.property_info[
         'monthCard_remain_days'] = monthCard_remain_days
     user_property_obj.put()
     return monthCard_bonus
예제 #30
0
def add_exp_point(rk_user, params):
    '''
    添加经验点接口
    根据用户提交的道具 id 给用户添加经验点
    '''
    props_id = params['props_id']
    num = int(params['num'])
    #根据 id 获取道具的使用途径
    props_id_config = game_config.props_config.get(props_id, {})
    used_by = props_id_config.get('used_by', '')
    #判断使用的用途
    if used_by != 'card':
        return 11, {'msg': utils.get_msg('pack', 'wrong_used')}
    #判断用户道具是否足够
    user_pack_obj = UserPack.get_instance(rk_user.uid)
    if not user_pack_obj.is_props_enough(props_id, num):
        return 11, {'msg': utils.get_msg('pack', 'not_enough_props')}
    #计算经验点数
    add_exp_point = int(num * props_id_config.get('exp', 0))
    #所有条件都满足的话  删除道具 添加经验点
    user_pack_obj.minus_props(props_id, num, where='add_exp_point')
    user_property_obj = UserProperty.get(rk_user.uid)
    user_property_obj.add_card_exp_point(add_exp_point, "by_props")
    #结果返回
    return 0, {'add_exp_point': add_exp_point}
예제 #31
0
def get_access_token(request):
    #用于刷新access_token用的refresh token
    data = {
            'rc':0,
            'data':{}
            }
    para_pid = request.REQUEST.get('pid',None)
    para_platform = request.REQUEST.get('platform',None)
    session_dic = Session.new_get(para_platform+':'+para_pid)
    pid = session_dic['pid']
    access_token = session_dic['access_token']
    refresh_token = session_dic['refresh_token']
    expires_time = session_dic['expires_time']
    if not pid and not access_token and not refresh_token and not expires_time:
        data = {
                'rc':8,
                'data':{
                      'msg':get_msg('login','server_exception'),
                      'server_now':int(time.time()),
                      }
                }
        return HttpResponse(
            json.dumps(data, indent=1),
            content_type='application/x-javascript',
        )

    else:
        if expires_time > time.time():
            data['data']['access_token'] = access_token
            data['data']['pid'] = request.rk_user.account.openid
            data['data']['uid'] = request.rk_user.uid
            data['data']['nickname'] = request.rk_user.baseinfo['username']
        else:
            client_id = settings.APP_KEY_360
            client_secret = settings.APP_SECRET_KEY_360
            oauth2_url = "https://openapi.360.cn/oauth2/access_token?grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s&scope=basic" %(refresh_token, client_id, client_secret)
            url_request = urllib2.urlopen(oauth2_url, timeout=12)
            code, res = url_request.code, url_request.read()
            if code == 200:
                res_dict = json.loads(res)
                data['data']['access_token'] = str(res_dict['access_token'])
                data['data']['pid'] = request.rk_user.account.openid
                data['data']['uid'] = request.rk_user.uid
                data['data']['nickname'] = request.rk_user.baseinfo['username']
                expires_time = time.time() + float(res_dict['expires_in'])
                Session.set(para_platform, pid, str(res_dict['access_token']), str(res_dict['refresh_token']), expires_time)
            else:
                data = {
                        'rc':8,
                        'data':{
                              'msg':get_msg('login','server_exception'),
                              'server_now':int(time.time()),
                              }
                        }
    data['data']['server_now'] = int(time.time())
    return HttpResponse(
        json.dumps(data, indent=1),
        content_type='application/x-javascript',
    )
예제 #32
0
def get_box_gift(rk_user,params):
    '''
    * 领取宝箱奖励
    '''
    data = {}
    get_step = params.get('step','0')
    floor_id = params.get('floor_id')
    box_type = params.get('box_type')
    dungeon_config = game_config.dungeon_world_config.get('box_info',{})
    floor_conf = dungeon_config.get(floor_id,{})
    if not box_type in floor_conf:
        return 11,{'msg':utils.get_msg('dungeon', 'no_box_config')}
    box_info = floor_conf[box_type]
    if get_step == '0':
        #处理前端要显示的宝箱的内容
        data['box_info'] = utils.format_award(box_info)
        data['box_star'] = int(floor_conf[box_type+'_star'])
        return 0,data
    elif get_step == '1':
        #处理前端要领取的宝箱信息
        user_dungeon_obj = UserDungeon.get(rk_user.uid)
        has_played_info_copy = copy.deepcopy(user_dungeon_obj.has_played_info)
        if floor_id in has_played_info_copy.get('normal',{}):
            floor_info = has_played_info_copy['normal'][floor_id]
            #查看领取条件是否合适
            floor_get_star = floor_info['cur_star']
            if floor_get_star < int(floor_conf[box_type+'_star']):
                return 11,{'msg':utils.get_msg('dungeon', 'box_can_not_open')}
            if floor_info[box_type]:
                #宝箱已领取情况
                return 11,{'msg':utils.get_msg('dungeon', 'has_got_box_award')}
            else:
                #领取宝箱逻辑 格式化内容
                award = utils.format_award(box_info)
                user_property_obj = UserProperty.get(rk_user.uid)
                #将宝箱里面的内容添加到用户信息里面
                award_info = user_property_obj.test_give_award(award,where='get_'+box_type)
                #格式化要返回的内容
                data['award_info'] = award_info
                data['floor_info'] = {}
                data['floor_info']['floor_id'] = floor_id
                data['floor_info']['box_type'] = box_type
                data['floor_info']['box_flag'] = True
                #重置标志位
                user_dungeon_obj.has_played_info['normal'][floor_id][box_type] = True
                user_dungeon_obj.put()
                #判断新手引导
                newbie_step = int(params.get('newbie_step', 0))
                if newbie_step:
                    rk_user.user_property.set_newbie_steps(newbie_step, "get_box_gift")
                #结果返回
                return 0,data
        else:
            return 11,{'msg':utils.get_msg('dungeon', 'invalid_dungeon_info')}
    else:
        #未识别的内容
        return 11,{'msg':utils.get_msg('dungeon', 'invalid_dungeon_info')}
예제 #33
0
def banquet_info(rk_user, params):
    """
    * 获取美味大餐的相关内容
    * 获取探索的相关内容
    * 获得成长礼包的信息
    """

    ua = rk_user.user_activity
    user_banquet_info = ua.banquet_info
    now = datetime.datetime.now()
    now_date_day = now.strftime('%Y-%m-%d')
    now_hour_min = now.strftime('%H:%M')
    banquet_info = {'banquet_msgs': [], 'can_get': False,'desc':{}}
    banquet_info['banquet_interval'] = []
    open_time_gaps = game_config.operat_config.get('open_stamina_banquet_gaps', [])
    #获取开放的时间   设置标志位
    for gap in open_time_gaps:
        time_msg = gap[0] + ' -- ' + gap[1] + ':'
        if user_banquet_info.get(gap):
            open_msg = utils.get_msg('active', 'already_banquet')
        elif gap[0] <= now_hour_min <= gap[1]:
            open_msg = utils.get_msg('active', 'in_time')
            banquet_info['can_get'] = True
        else:
            open_msg = utils.get_msg('active', 'not_in_time')
        banquet_info['banquet_msgs'].append(time_msg + open_msg)
        banquet_info['desc'][time_msg[:-1]] = open_msg
        time_start = '%s %s:00'%(now_date_day,str(gap[0]))
        time_end = '%s %s:00'%(now_date_day,str(gap[1]))
        start_time = utils.string_toTimestamp(time_start)
        end_time = utils.string_toTimestamp(time_end)
        banquet_info['banquet_interval'].append(start_time)
        banquet_info['banquet_interval'].append(end_time)
    time_lists = sorted([str(time_list) for time_list in banquet_info['banquet_interval']])
    banquet_info['am_start'] = time_lists[0]
    banquet_info['am_end'] = time_lists[1]
    banquet_info['pm_start'] = time_lists[2]
    banquet_info['pm_end'] = time_lists[3]
    banquet_info.pop('banquet_interval')
    banquet_info['am_flag'] = user_banquet_info.get(banquet_info['am_start'],False)
    banquet_info['pm_flag'] = user_banquet_info.get(banquet_info['pm_start'],False)

    # 获取探索的相关内容
    # explore_info = get_explore_info(rk_user)

    # 获取成长礼包相关内容
    growup_info = get_growup_info(rk_user, params)
    # 判断新手引导
    newbie_step = int(params.get('newbie_step', 0))
    if newbie_step:
        rk_user.user_property.set_newbie_steps(newbie_step, "banquet_info")
    return {
        'banquet_info': banquet_info, 
        # 'explore_info': explore_info,
        'growup_info': growup_info,
    }
예제 #34
0
def charge_result_360(request):
    """充值回调
    """
    
    pay_dict = {}
    pay_dict['app_uid'] = str(request.REQUEST['app_uid'])#应用内用户ID
    pay_dict['order_id'] = str(request.REQUEST['order_id'])#360支付订单号
    pay_dict['app_key'] = str(request.REQUEST['app_key'])#应用app key
    pay_dict['product_id'] = str(request.REQUEST['product_id'])#所购商品id
    pay_dict['amount'] = str(request.REQUEST['amount'])#总价,单价,分
    pay_dict['app_order_id'] = str(request.REQUEST.get('app_order_id', ''))#应用订单号
    pay_dict['sign_type'] = str(request.REQUEST['sign_type'])#应用传给订单核实接口的参数
    pay_dict['sign_return'] = str(request.REQUEST['sign_return'])#应用传给订单核实接口的参数sign_type
    pay_dict['client_id'] = settings.APP_KEY_360#应用app key
    pay_dict['client_secret'] = settings.APP_SECRET_KEY_360#应用app_secret
    data = {
        'rc':12,
        'result':u'fail_验证失败',
        'data':{'msg':get_msg('charge','fail'),'server_now':int(time.time())},
    }
    rk_user = UserBase.get(pay_dict['app_uid'])
    pay_dict['gateway_flag'] = str(request.REQUEST.get('gateway_flag', ''))
    if pay_dict['gateway_flag'] != 'success':
        data_log_mod.set_log('ChargeResultLog', **{'uid':rk_user.uid,'charge_way':'360',\
                                              'result':u'fail_gateway_flag','oid':pay_dict['order_id'],\
                                              'item_id':pay_dict['product_id'],'price':pay_dict['amount'], 'subarea': rk_user.subarea,})
        return HttpResponse('ok')
    pay_url = "https://openapi.360.cn/pay/verify_mobile_notification.json?app_key=%(app_key)s&product_id=%(product_id)s&amount=%(amount)s&app_uid=%(app_uid)s&order_id=%(order_id)s&app_order_id=%(app_order_id)s&sign_type=%(sign_type)s&sign_return=%(sign_return)s&client_id=%(client_id)s&client_secret=%(client_secret)s" % pay_dict
    try:
        url_request = urllib2.urlopen(pay_url, timeout=12)
        code, res = url_request.code, url_request.read()
    except:
        data = {
            'rc':7,
            'data':{
                  'msg':get_msg('login','refresh'),
                  'server_now':int(time.time()),
            },
        }
        data_log_mod.set_log('ChargeResultLog', **{'uid':rk_user.uid,'charge_way':'360',\
                                              'result':u'fail_请求超时','oid':pay_dict['order_id'],\
                                              'item_id':pay_dict['product_id'],'price':pay_dict['amount'],'subarea': rk_user.subarea,})
        return HttpResponse('ok')
    oid = pay_dict["order_id"]
    item_id = pay_dict["product_id"]
    if code == 200:
        res_dict = json.loads(res)
        ret = res_dict.get('ret', '')
        if ret == 'verified':
            data = charge_api(rk_user, oid, item_id, platform = '360',res_dict={},request = request)
    data_log_mod.set_log('ChargeResultLog', **{'uid':rk_user.uid,'charge_way':'360',\
                                              'result':data['result'],'oid':oid,'item_id':item_id,'price':pay_dict['amount'],'subarea': rk_user.subarea,})
    return HttpResponse('ok')
예제 #35
0
def store_sell(rk_user, params):
    """背包卖出
    params:
        items:
            itemid:num,itemid:num,itemid:num
        materials:
            materialid:num,materialid:num
    """
    sell_materials = {}
    sell_props = {}
    user_pack_obj = rk_user.user_pack
    material_config = game_config.material_config
    props_config = game_config.props_config
    get_gold = 0

    for good_type in ['materials', 'props']:
        goods = params.get(good_type, None)
        if not goods:
            continue
        if good_type == 'materials':
            material_ls = goods.split(',')
            material_ls = utils.remove_null(material_ls)
            for m in material_ls:
                m_id, m_num = m.split(':')
                m_num = abs(int(m_num))
                if not user_pack_obj.is_material_enough(m_id, m_num):
                    return 11, {
                        'msg': utils.get_msg('pack', 'not_enough_material')
                    }
                sell_materials[m_id] = m_num
                get_gold += m_num * material_config[m_id].get('sell_gold', 0)
        else:
            props_ls = goods.split(',')
            props_ls = utils.remove_null(props_ls)
            for p in props_ls:
                p_id, p_num = p.split(':')
                p_num = abs(int(p_num))
                if not user_pack_obj.is_props_enough(p_id, p_num):
                    return 11, {
                        'msg': utils.get_msg('pack', 'not_enough_props')
                    }
                sell_props[p_id] = p_num
                get_gold += p_num * props_config[p_id].get('sell_gold', 0)
    #加铜钱
    if get_gold > 0:
        rk_user.user_property.add_gold(get_gold, 'pack_store_sell')
    #减物品
    for m_id in sell_materials:
        user_pack_obj.minus_material(m_id, sell_materials[m_id],
                                     'pack_store_sell')
    for p_id in sell_props:
        user_pack_obj.minus_props(p_id, sell_props[p_id], 'pack_store_sell')
    return 0, {'get_gold': get_gold}
예제 #36
0
def auth_token_for_oc(request,access_token,openid,uuid,mktid,version,client_type,macaddr,idfa,ios_ver):
    """论证无账号用户
    """
    print "debug_guochen access_token, openid", access_token, openid
    fg = False
    pid = ''
    msg = ''
    subarea = request.REQUEST.get("subarea", "1") or '1'
    #没有openid时,检查后控制自动分配id的开头是否开启,如果已经关闭,返回提示
    if not openid:
       if game_config.system_config.get('account_assign_switch'):
           fg = True
           pid = get_uuid()
           #验证成功,安装用户
           request.rk_user = UserBase._install(pid,'oc',uuid,mktid,version,client_type,macaddr,idfa,ios_ver, subarea=subarea)
           access_token = get_upwd()
           request.rk_user.account.update_info(pid, access_token)
       else:
           msg = get_msg('login','cannot_register')
           return fg,pid,msg
    if not check_openid(openid):
        msg = get_msg('login','cannot_register')
        return fg,pid,msg
    #有openid时,检查access_token是否正确
    account = AccountMapping.get(openid)
    if not account: 
        if game_config.system_config.get('account_assign_switch'):
            fg = True
            pid = openid
            #验证成功,安装用户
            request.rk_user = UserBase._install(pid,'oc',uuid,mktid,version,client_type,macaddr,idfa,ios_ver, subarea=subarea)
            # debug 模式下,将传入的access_token 作为新用户taken
            if settings.DEBUG is True:
                access_token = access_token or get_upwd()
            else:
                access_token = get_upwd()
            request.rk_user.account.update_info(pid, access_token)
            account = request.rk_user.account
            print "debug_guochen_new_token pid, access_token, openid", pid, access_token, openid
        else:
            msg = get_msg('login','cannot_register')
            return fg,pid,msg

    elif account.access_token == access_token:
        fg = True
        pid = openid
        #验证成功,安装用户
        request.rk_user = UserBase._install(pid, 'oc', subarea=subarea)
    else:
        print "debug_guochen_erro_token pid, access_token, openid", pid, access_token, openid
        msg = get_msg('login','session_overdue')
    return fg,pid,msg
예제 #37
0
def auth_bind_for_sina(request, access_token, openid, bind_access_token,
                       bind_openid):
    """论证sina开放平台账号绑定
    """
    fg = False
    pid = ''
    msg = ''
    SINA_OPEN_URL = 'https://api.weibo.com/2/account/get_uid.json'
    request_url = '%s?access_token=%s' % (SINA_OPEN_URL, str(access_token))
    user_info_url = 'https://api.weibo.com/2/users/show.json?access_token=%s&uid=%s'

    #检查被绑定的oneclick账号是否合法
    if not check_openid(bind_openid):
        msg = get_msg('login', 'invalid_bind')
        return fg, msg, pid
    account = AccountMapping.get(bind_openid)
    if account and account.access_token == bind_access_token:
        url_request = urllib2.urlopen(request_url, timeout=12)
        rc = url_request.code
        res = url_request.read()
        if rc == 200:
            res = res.strip()
            res = res.replace('false', 'False')
            res = res.replace('true', 'True')
            res = res.replace('null', 'None')
            exec('result = %s' % res)
            get_openid = str(result.get('uid'))
            if get_openid == openid:
                fg, pid, msg = _bind_new_platform(request, 'sina', openid,
                                                  account, result)

                #调用平台的api,取得用户名等信息,并且更新
                user_info_url = user_info_url % (str(access_token),
                                                 str(openid))
                #更新用户平台信息不影响绑定操作
                try:
                    res = urllib2.urlopen(str(user_info_url),
                                          timeout=12).read()
                    res = res.strip()
                    res = res.replace('false', 'False')
                    res = res.replace('true', 'True')
                    res = res.replace('null', 'None')
                    exec('result = %s' % res)
                    request.rk_user.update_user_from_sina(result)
                except:
                    pass
                return fg, pid, msg
    else:
        msg = get_msg('login', 'invalid_bind')
    return fg, pid, msg
예제 #38
0
def __check_send_gift(send_ls,friend_gift_conf,_split='-'):
    """
    检查礼物列表是否正确
    """
    for want_item in send_ls:
        if want_item in ['stone','gold','gacha_pt']:
            if want_item not in friend_gift_conf:
                return 11,utils.get_msg('friend','gift_not_exist')
        elif want_item.startswith('m'+_split):
            m,ma_id = want_item.split(_split)
            if ma_id not in friend_gift_conf.get('material',{}):
                return 11,utils.get_msg('friend','gift_not_exist')
        elif want_item:
            return 11,utils.get_msg('friend','gift_not_exist')
    return 0,''
예제 #39
0
def get_frozen_msg(rk_user):
    """检查是否是冻结用户
    """
    #如果用户被冻结,返回
    msg = ''
    if rk_user.baseinfo.get('frozen'):
        msg = get_msg('login','frozen') % rk_user.uid
        return msg
    #如果用户是暂时冻结,提示
    unfroze_time = rk_user.baseinfo.get('unfroze_time')
    if unfroze_time and int(time.time()) < unfroze_time:
        msg = get_msg('login','frozen_time')
        frozen_days = 2 if rk_user.baseinfo.get('frozen_count',0) == 1 else 7
        msg = msg % (frozen_days,timestamp_toString(unfroze_time,'%m.%d %H:%M'),rk_user.uid)
    return msg
예제 #40
0
def __check_send_gift(send_ls, friend_gift_conf, _split="-"):
    """
    检查礼物列表是否正确
    """
    for want_item in send_ls:
        if want_item in ["stone", "gold", "gacha_pt"]:
            if want_item not in friend_gift_conf:
                return 11, utils.get_msg("friend", "gift_not_exist")
        elif want_item.startswith("m" + _split):
            m, ma_id = want_item.split(_split)
            if ma_id not in friend_gift_conf.get("material", {}):
                return 11, utils.get_msg("friend", "gift_not_exist")
        elif want_item:
            return 11, utils.get_msg("friend", "gift_not_exist")
    return 0, ""
예제 #41
0
def store_sell(rk_user, params):
    """背包卖出
    params:
        items:
            itemid:num,itemid:num,itemid:num
        materials:
            materialid:num,materialid:num
    """
    sell_materials = {}
    sell_props = {}
    user_pack_obj = rk_user.user_pack
    material_config = game_config.material_config
    props_config = game_config.props_config
    get_gold = 0

    for good_type in ['materials', 'props']:
        goods = params.get(good_type, None)
        if not goods:
            continue
        if good_type == 'materials':
            material_ls = goods.split(',')
            material_ls = utils.remove_null(material_ls)
            for m in material_ls:
                m_id, m_num = m.split(':')
                m_num = abs(int(m_num))
                if not user_pack_obj.is_material_enough(m_id, m_num):
                    return 11, {'msg':utils.get_msg('pack', 'not_enough_material')}
                sell_materials[m_id] = m_num
                get_gold += m_num * material_config[m_id].get('sell_gold', 0)
        else:
            props_ls = goods.split(',')
            props_ls = utils.remove_null(props_ls)
            for p in props_ls:
                p_id,p_num = p.split(':')
                p_num = abs(int(p_num))
                if not user_pack_obj.is_props_enough(p_id,p_num):
                    return 11, {'msg':utils.get_msg('pack', 'not_enough_props')}
                sell_props[p_id] = p_num
                get_gold += p_num * props_config[p_id].get('sell_gold', 0)
    #加铜钱
    if get_gold > 0:
        rk_user.user_property.add_gold(get_gold, 'pack_store_sell')
    #减物品
    for m_id in sell_materials:
        user_pack_obj.minus_material(m_id, sell_materials[m_id], 'pack_store_sell')
    for p_id in sell_props:
        user_pack_obj.minus_props(p_id, sell_props[p_id], 'pack_store_sell')
    return 0,{'get_gold': get_gold}
예제 #42
0
    def new_func(request, *args, **argw):
        para_pid = request.REQUEST.get('pid', None)
        para_platform = request.REQUEST.get('platform', None)

        session_overdue = False
        if para_platform is None or para_pid is None:
            session_overdue = True
        else:
            platform, pid = Session.get("{}:{}".format(para_platform,
                                                       para_pid))
            if not platform or not pid or platform != para_platform or para_pid != pid:
                session_overdue = True

        #session过期
        if session_overdue:
            data = {
                'rc': 8,
                'data': {
                    'msg': get_msg('login', 'server_exception'),
                    'server_now': int(time.time())
                }
            }
            return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
        result = func(request, *args, **argw)
        return result
예제 #43
0
def accept_request(rk_user,params):
    """
    同意好友申请
    """
    fid = params['fid']
    user_friend_obj = Friend.get(rk_user.uid)
    #检查是否有这条请求
    if not fid in user_friend_obj.requests:
        return 11,{'msg':utils.get_msg('friend','no_request')}
    friend_obj = UserBase.get(fid)
    friend_friend_obj = Friend.get(fid)
    rc,msg = __check_can_add_friend(rk_user,friend_obj)
    if rc:
        return rc,{'msg':msg}
    else:
        #将对方加入到自己的好友列表
        user_friend_obj.add_friend(fid)
        #将自己加入到对方的好友列表
        friend_friend_obj.add_friend(rk_user.uid)
        if rk_user.uid in friend_friend_obj.self_requests:
            friend_friend_obj.self_requests.pop(rk_user.uid)
            friend_friend_obj.put()
        #将对方从自己的申请列表中删除
        user_friend_obj.del_request(fid)
        return 0,{}
예제 #44
0
 def get_bind_phone_gift(self):
     """
     领取绑定奖励, 每个礼拜只能领一次
     miaoyichao
     """
     #获取是否开启手机绑定功能
     bind_phone_is_open = self.game_config.system_config.get('bind_phone_is_open')
     if not bind_phone_is_open:
         return
     #获取绑定手机的奖励配置信息
     bind_phone_award_conf = copy.deepcopy(self.game_config.loginbonus_config.get("bind_phone_award"))
     if not bind_phone_award_conf:
         return
     #检查是否绑定手机
     user_property_obj = UserProperty.get(self.uid)
     has_bind = user_property_obj.property_info['bind_phone_number_info']['has_bind']
     if not has_bind:
         return
     #获取当前的星期
     now_week = datetime.date.today().isocalendar()[:2]
     last_got_award_week = user_property_obj.property_info['bind_phone_number_info'].get('last_got_award_week')
     # 最后一次领取的星期 与现在相同  不发
     if last_got_award_week and now_week <= last_got_award_week:
         return
     #获取提示语信息
     msg = utils.get_msg('bind', 'get_bind_award_msg', self)
     #添加奖励
     self.add_gift(bind_phone_award_conf, msg)
     #更新绑定信息
     user_property_obj.property_info['bind_phone_number_info']['last_got_award_week'] = now_week
     user_property_obj.put()
     self.put()
예제 #45
0
 def get_giftcode_lv_up_award(self,gift_id=''):
     """
     检查是否有可领取的升级奖励
     """
     if not gift_id:
         gift_ids = self.gift_code_info.get('lv_up',{}).keys()
     else:
         gift_ids = [gift_id]
     if not gift_ids:
         return
     gift_config = self.game_config.gift_config.get('gift_config',{})
     user_prop_obj = UserProperty.get(self.uid)
     pt_fg = False
     for _id in gift_ids:
         if _id not in gift_config or _id not in self.gift_code_info.get('lv_up',{}):
             continue
         lv_up_gift = gift_config[_id].get('lv_up_gift',{})
         for need_lv in lv_up_gift:
             if int(need_lv)<=user_prop_obj.lv and need_lv not in self.gift_code_info['lv_up'][_id]:
                 self.gift_code_info['lv_up'][_id].append(need_lv)
                 pt_fg = True
                 msg = utils.get_msg('gift', 'lv_up_gift_award', self)
                 self.add_gift(lv_up_gift[need_lv], content=msg % need_lv)
     if pt_fg:
         self.put()
예제 #46
0
    def get_lv_gift(self):
        """
        领取等级奖励
        """
        lv_up_award_conf = copy.deepcopy(
            self.game_config.operat_config.get("lv_up_award"))
        if not lv_up_award_conf:
            return

        main_msg = utils.get_msg('operat', 'lv_up_award', self)

        all_awards_lv = sorted(map(int, lv_up_award_conf.keys()))
        user_property_obj = UserProperty.get(self.uid)
        user_level = user_property_obj.lv
        # 比现在lv小的等级奖励都应该获得
        sould_send_awards_lv = all_awards_lv[:bisect.
                                             bisect(all_awards_lv, user_level)]
        for awards_lv in sould_send_awards_lv:
            awards_lv = str(awards_lv)
            if awards_lv in self.has_got_lv_gift:
                continue
            self.add_gift(lv_up_award_conf[awards_lv],
                          main_msg.format(awards_lv))
            self.has_got_lv_gift.append(awards_lv)
        self.put()
예제 #47
0
 def get_giftcode_lv_up_award(self, gift_id=''):
     """
     检查是否有可领取的升级奖励
     """
     if not gift_id:
         gift_ids = self.gift_code_info.get('lv_up', {}).keys()
     else:
         gift_ids = [gift_id]
     if not gift_ids:
         return
     gift_config = self.game_config.gift_config.get('gift_config', {})
     user_prop_obj = UserProperty.get(self.uid)
     pt_fg = False
     for _id in gift_ids:
         if _id not in gift_config or _id not in self.gift_code_info.get(
                 'lv_up', {}):
             continue
         lv_up_gift = gift_config[_id].get('lv_up_gift', {})
         for need_lv in lv_up_gift:
             if int(
                     need_lv
             ) <= user_prop_obj.lv and need_lv not in self.gift_code_info[
                     'lv_up'][_id]:
                 self.gift_code_info['lv_up'][_id].append(need_lv)
                 pt_fg = True
                 msg = utils.get_msg('gift', 'lv_up_gift_award', self)
                 self.add_gift(lv_up_gift[need_lv], content=msg % need_lv)
     if pt_fg:
         self.put()
예제 #48
0
def exchange_card(rk_user, params):
    """
    将魂卡兑换成武将
    miaoyichao
    """
    # 需要兑换的武将
    cid = params['cid']
    user_souls_obj = UserSouls.get_instance(rk_user.uid)
    user_card_obj = UserCards.get_instance(rk_user.uid)
    needed_souls = int(game_config.card_config[cid]['souls_needed'])
    #   将魂不足
    if not user_souls_obj.is_normal_soul_enough(cid,needed_souls):
        return 11, {'msg': utils.get_msg('soul','not_enough_soul')}
    #减武将碎片
    user_souls_obj.minus_card_soul(cid, needed_souls, 'soul_exchange_card')
    # 加武将
    success_fg, p1, ucid, is_first = user_card_obj.add_card(cid, where='soul_exchange_card')
    new_card = {
        'ucid':ucid,
        'is_first':is_first,
    }
    new_card.update(user_card_obj.get_card_dict(ucid))
    return 0, {
                'new_card': new_card,
    }
예제 #49
0
def __check_send_fids(fids,friend_obj):
    """
    检查好友是否合法
    """
    send_fids = friend_obj.friend_gift['send_fids']
    for fid in fids:
        #当天只能送给同一个好友一次
        if fid in send_fids:
            return 11,utils.get_msg('friend','send_gift_err')
        #不能送给非好友
        friend_friend_obj = Friend.get(fid)
        if not friend_friend_obj or fid not in friend_obj.friends:
            return 11,utils.get_msg('friend','not_friend')
        if friend_friend_obj.has_gift_from(friend_obj.uid):
            return 11,utils.get_msg('friend','send_gift_err')
    return 0,''
예제 #50
0
def add_request(rk_user,params):
    """
    添加好友的请求
    """
    fid = params.get('fid','')
    #检查好友id是否存在

    if 'npc' in fid:
        return 0, {}

    friend_user = UserBase.get(fid)
    if not friend_user:
        return 11,{'msg':utils.get_msg('user','no_user')}
    rc,msg = __check_can_add_friend(rk_user,friend_user)
    if rc:
        return rc,{'msg':msg}
    else:
        user_friend_obj = Friend.get(rk_user.uid)
        friend_friend_obj = Friend.get(fid)
        #如果对方申请过加自己为好友,则直接建立好友关系
        if fid in user_friend_obj.requests:
            #将对方加入到自己的好友列表
            user_friend_obj.add_friend(fid)
            #将自己加入到对方的好友列表
            friend_friend_obj.add_friend(rk_user.uid)
            #将对方从自己的申请列表中删除
            user_friend_obj.del_request(fid)
            #将自己从好友的申请列表中删除
            friend_friend_obj.del_self_request(rk_user.uid)
        else:
            user_friend_obj.self_requests[fid] = int(time.time())
            user_friend_obj.put()
            friend_friend_obj.add_request(rk_user.uid)
        return 0,{}
예제 #51
0
    def new_func(request, *args, **argw):
        para_pid = request.REQUEST.get('pid', None)
        para_platform = request.REQUEST.get('platform', None)

        session_overdue = False
        if para_platform is None or para_pid is None:
            session_overdue = True
        else:
            platform, pid = Session.get("{}:{}".format(para_platform, para_pid))
            if not platform or not pid or platform != para_platform or para_pid != pid:
                session_overdue = True

        #session过期
        if session_overdue:
            data = {
                'rc': 8,
                'data': {
                    'msg': get_msg('login', 'server_exception'),
                    'server_now': int(time.time())
                }
            }
            return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
        result = func(request, *args, **argw)
        return result
예제 #52
0
 def new_func(request, *args, **argw):
     try:
         params = request.REQUEST
         oid = params.get('oid', '')
         signature = params.get('sign', '')
         key = RSA.importKey(_pub_rsa_key)
         h = SHA.new(str(oid))
         verifier = PKCS1_v1_5.new(key)
         if verifier.verify(h, b64decode(signature)):
             result = func(request, *args, **argw)
             return result
     except:
         send_exception_mail(request)
         print_err()
         #清空storage
         app.pier.clear()
     return HttpResponse(
         json.dumps(
             {
                 'rc': 8,
                 'data': {
                     'msg': get_msg('login', 'server_exception'),
                     'server_now': int(time.time())
                 }
             },
             indent=1),
         content_type='application/x-javascript',
     )
예제 #53
0
    def new_func(request, *args, **argw):
        pid = request.REQUEST.get("pid")
        platform = request.REQUEST.get("platform")
        subarea = request.REQUEST.get("subarea", "1")

        if pid and platform:
            request.rk_user = UserBase._install(pid, platform, subarea=subarea)
            frozen_msg = get_frozen_msg(request.rk_user)
            if frozen_msg:
                data = {
                    'rc': 10,
                    'data': {
                        'msg': frozen_msg,
                        'server_now': int(time.time())
                    }
                }
                return HttpResponse(
                    json.dumps(data, indent=1),
                    content_type='application/x-javascript',
                )
        else:
            #print '#### set_user, rc: 6'
            data = {
                'rc': 6,
                'data': {
                    'msg': get_msg('login', 'platform_overdue'),
                    'server_now': int(time.time())
                }
            }
            return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
        return func(request, *args, **argw)
예제 #54
0
    def new_func(request,*args,**argw):
        pid = request.REQUEST.get("pid")
        platform = request.REQUEST.get("platform")
        subarea = request.REQUEST.get("subarea", "1")

        if pid and platform:
            request.rk_user = UserBase._install(pid, platform, subarea=subarea)
            frozen_msg = get_frozen_msg(request.rk_user)
            if frozen_msg:
                data = {
                    'rc': 10,
                    'data': {
                        'msg': frozen_msg,
                        'server_now': int(time.time())
                    }
                }
                return HttpResponse(
                    json.dumps(data, indent=1),
                    content_type='application/x-javascript',
                )
        else:
            #print '#### set_user, rc: 6'
            data = {
                'rc': 6,
                'data': {
                    'msg': get_msg('login', 'platform_overdue'),
                    'server_now': int(time.time())
                }
            }
            return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
        return func(request, *args, **argw)
예제 #55
0
def exchange_card(rk_user, params):
    """
    将魂卡兑换成武将
    miaoyichao
    """
    # 需要兑换的武将
    cid = params['cid']
    user_souls_obj = UserSouls.get_instance(rk_user.uid)
    user_card_obj = UserCards.get_instance(rk_user.uid)
    needed_souls = int(game_config.card_config[cid]['souls_needed'])
    #   将魂不足
    if not user_souls_obj.is_normal_soul_enough(cid, needed_souls):
        return 11, {'msg': utils.get_msg('soul', 'not_enough_soul')}
    #减武将碎片
    user_souls_obj.minus_card_soul(cid, needed_souls, 'soul_exchange_card')
    # 加武将
    success_fg, p1, ucid, is_first = user_card_obj.add_card(
        cid, where='soul_exchange_card')
    new_card = {
        'ucid': ucid,
        'is_first': is_first,
    }
    new_card.update(user_card_obj.get_card_dict(ucid))
    return 0, {
        'new_card': new_card,
    }
예제 #56
0
def get_frozen_msg(rk_user):
    """检查是否是冻结用户
    """
    #如果用户被冻结,返回
    msg = ''
    if rk_user.baseinfo.get('frozen'):
        msg = get_msg('login', 'frozen') % rk_user.uid
        return msg
    #如果用户是暂时冻结,提示
    unfroze_time = rk_user.baseinfo.get('unfroze_time')
    if unfroze_time and int(time.time()) < unfroze_time:
        msg = get_msg('login', 'frozen_time')
        frozen_days = 2 if rk_user.baseinfo.get('frozen_count', 0) == 1 else 7
        msg = msg % (frozen_days,
                     timestamp_toString(unfroze_time,
                                        '%m.%d %H:%M'), rk_user.uid)
    return msg
예제 #57
0
def lock_friend(rk_user,params):
    """
    锁定好友
    """
    fid = params['fid']
    fg = Friend.get(rk_user.uid).lock(fid)
    if not fg:
        return 11,{'msg':utils.get_msg('friend','not_friend')}
    return 0,{}
예제 #58
0
def check_card_in_deck(user_card_obj, card_list):
    """检查武将是否在队伍中
    miaoyichao
    """
    for ucid in card_list:
        for deck in user_card_obj.decks:
            ucid_ls = [card['ucid'] for card in deck if card.get('ucid', '')]
            if ucid in ucid_ls:
                return 11, utils.get_msg('card', 'in_deck')
    return 0, ''