Example #1
0
def mi_create_orderid(request):
    """
    给前段返回一个唯一的小米订单号,并记录在 OrderRecord 表
    """
    rk_user = request.rk_user
    item_id = request.REQUEST.get('item_id', None)
    if not item_id:
        data = {
            'rc':12,
            'result':u'没有物品id',
            'data':{'msg':get_msg('charge','fail'),'server_now':int(time.time())},
        }
        return HttpResponse(
            json.dumps(data, indent=1),
            content_type='application/x-javascript',
        )
    oid = "mi" + rk_user.uid + str(time.time())

    #作记录
    record_data = {
                    "oid":oid,
                    "uid":rk_user.uid,
                    "item_id":item_id,
                    "createtime":datetime_toString(datetime.datetime.now()),
                  }
    data_log_mod.set_log('OrderRecord', rk_user, **record_data)
    data = {
        'rc': 0,
        'data': {'oid': oid, 'server_now': int(time.time())},
    }
    return HttpResponse(
        json.dumps(data, indent=1),
        content_type='application/x-javascript',
    )
Example #2
0
def google_charge_result(request):
    
    signedData = request.REQUEST['signedData']
    signature = request.REQUEST['signature'].replace(' ','+')
    purchaseState =  json.loads(signedData)['purchaseState']
    item_id = request.REQUEST['item_id']
    oid = request.REQUEST['oid']
    data = {
        'rc':12,
        'result':u'fail_验证失败',
        'data':{'msg':get_msg('charge','fail'),'server_now':int(time.time())},
    }
    try:
        gvpfg = google_validate_purchase(signedData,signature)
    except:
        gvpfg = False
        print request
        print traceback.format_exc()
        return HttpResponse(
            json.dumps(data, indent=1),
            content_type='application/x-javascript',
        )
    if purchaseState==0 and gvpfg:
        data = charge_api(request.rk_user, oid, item_id,platform='gp',res_dict={},request=request,charge_way='googleplay')
        data['data']['user_info'] = request.rk_user.wrapper_info()
        data['data']['server_now'] = int(time.time())
    data_log_mod.set_log('ChargeResultLog', **{'uid':request.rk_user.uid,'charge_way':'gp',\
                                          'result':data['result'],'oid':oid,'item_id':item_id,'subarea': request.rk_user.subarea,})
    data.pop("result")
    return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
Example #3
0
def inf_result_fight(msg_data, self, opponent):
    print "!!!!!!!!", msg_data
    if "winner" in msg_data:
        self_uid = self.uid
        opponent_uid = opponent.uid
        # self_core_id = self.core_id
        # opponent.core_id = opponent.core_id
        if not opponent.connecting:
            win_uid, lose_uid = (self_uid, opponent_uid)
        else:
            # datafield = msg_data['datafield']
            # win_core_id = msg_data[datafield]["win"]
            # win_uid, lose_uid = (self_uid, opponent_uid) if win_core_id == self_core_id else (opponent_uid, self_uid)
            win_uid = msg_data["winner"]
            win_uid, lose_uid = (self_uid, opponent_uid) if win_uid == self_uid else (opponent_uid, self_uid)
        result_info = real_pvp.result_fight(win_uid, lose_uid)

        self_user_pvp_object = UserRealPvp.get(win_uid)
        opponent_user_pvp_object = UserRealPvp.get(lose_uid)

        data_log_mod.set_log('PvpRecord', UserRealPvp.get(self.uid),
                            **{
                                "winner": self_user_pvp_object.pvp_detail,
                                "loser": opponent_user_pvp_object.pvp_detail,
                                "end_reason": msg_data["pvp_end_reason"],
                            })

        success_data = dict(
            msgtype = 'inf_result_fight',
        )
        msg_data.update(result_info)
        return response_success(msg_data, success_data)
    return {}
Example #4
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,{}
Example #5
0
    def minus_card_soul(self, soul_id, num, where=None):
        """
        删除武将碎片 
        输入 碎片id 数量
        输出 True or False 
        """
        num = abs(num)
        if num == 0:
            return False
        if self.is_normal_soul_enough(soul_id, num):
            #  判断魂卡id是否存在
            #  card_config没有配souls_needed或者配的是0
            if self.game_config.card_config[soul_id].get('souls_needed',
                                                         0) == 0:
                return False
            self.normal_souls[soul_id]['num'] -= num
            if self.normal_souls[soul_id]['num'] <= 0:
                self.normal_souls.pop(soul_id)
        else:
            return False
        self.put()

        if where:
            log_data = {
                'where': where,
                'soul_id': soul_id,
                'num': num,
            }
            data_log_mod.set_log('SoulConsume', self, **log_data)
        return True
Example #6
0
 def minus_equip_soul(self, soul_id, num, where=None):
     """
     删除装备碎片
     输入 碎片id 数量
     输出 True or False 
     """
     num = abs(num)
     if num == 0:
         return False
     if self.is_equip_soul_enough(soul_id, num):
         self.equip_souls_info[soul_id]['num'] -= num
         if self.equip_souls_info[soul_id]['num'] <= 0:
             self.equip_souls_info.pop(soul_id)
     else:
         return False
     self.put()
     #写日志
     if where:
         log_data = {
             'where': where,
             'soul_id': soul_id,
             'num': num,
         }
         data_log_mod.set_log('SoulConsume', self, **log_data)
     return True
Example #7
0
 def del_card_info(self,ucids,where=None):
     """
     批量删除用户的卡信息
     Args:
         ucid: 自动生成的卡ID
     """
     put_fg = False
     for ucid in ucids:
         if ucid in self.cards:
             card_info = self.cards[ucid]
             cid = card_info['cid']
             #默认只有四星五星的武将
             cid_config = self.game_config.card_config[cid]
             if where:
                 card_msg = {
                     'cid': cid,
                     'ctype': cid_config['ctype'],
                     'lv': card_info['lv'],
                     'exp': self.cards[ucid]['exp'],
                     'name': cid_config['name'],
                     'star': cid_config['star'],
                 }
                 log_data = {
                     'where':where,
                     'ucid':ucid,
                     'card_msg': card_msg,
                 }
                 data_log_mod.set_log('CardConsume', self, **log_data)
             self.cards.pop(ucid)
             put_fg = True
     if put_fg:
         self.put()
Example #8
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, {}
Example #9
0
    def minus_coin(self, coin, where):
        '''
        扣除元宝
        args:
            coin: int
        return:
            bool
        '''
        coin = abs(coin)
        if self.is_coin_enough(coin):
            #元宝足够
            before = self.property_info['coin']
            self.property_info['coin'] -= coin
            self.put()
            after = self.property_info['coin']
            #记录消耗的元宝 因为可能发奖励
            # from apps.models.user_gift import UserGift
            # user_gift_obj = UserGift.get(self.uid)
            # user_gift_obj.get_consume_award(coin)

            #写日志
            log_data = {
                'where': where,
                'num': coin,
                'before': before,
                'after': after
            }
            data_log_mod.set_log('CoinConsume', self, **log_data)
            return True
        else:
            #元宝不够的话
            return False
Example #10
0
 def minus_materials(self, materials, where=""):
     """
     批量扣除材料
     """
     pt_fg = False
     for material_id in materials:
         num = abs(materials[material_id])
         if self.is_material_enough(material_id, num):
             #获取扣除前的数量
             before = self.materials[material_id]
             self.materials[material_id] -= num
             #获取扣除后的数量
             after = self.materials[material_id]
             if after <= 0:
                 self.materials.pop(material_id)
             pt_fg = True
             if where:
                 log_data = {
                     'where': where,
                     'mat_id': material_id,
                     'num': num,
                     'after': after,
                     'before': before
                 }
                 data_log_mod.set_log('MatConsume', self, **log_data)
     if pt_fg:
         #保存修改内容
         self.put()
Example #11
0
 def minus_props(self, props_id, num, where=None):
     '''
     * 一次扣除一种道具
     '''
     num = abs(num)
     if self.is_props_enough(props_id, num):
         before = self.props[props_id]
         #获取扣除前的数量
         self.props[props_id] -= num
         #获取扣除后的数量
         after = self.props[props_id]
         if after <= 0:
             self.props.pop(props_id)
             after = 0
         self.put()
         if where:
             log_data = {
                 'where': where,
                 'props_id': props_id,
                 'num': num,
                 'after': after,
                 'before': before
             }
             data_log_mod.set_log('PropsConsume', self, **log_data)
         return True
     return False
Example #12
0
    def minus_coin(self, coin, where):
        '''
        扣除元宝
        args:
            coin: int
        return:
            bool
        '''
        coin = abs(coin)
        if self.is_coin_enough(coin):
            #元宝足够
            before = self.property_info['coin']
            self.property_info['coin'] -= coin
            self.put()
            after = self.property_info['coin']
            #记录消耗的元宝 因为可能发奖励
            # from apps.models.user_gift import UserGift
            # user_gift_obj = UserGift.get(self.uid)
            # user_gift_obj.get_consume_award(coin)

            #写日志
            log_data = {'where': where, 'num': coin, 'before': before, 'after': after}
            data_log_mod.set_log('CoinConsume', self, **log_data)
            return True
        else:
            #元宝不够的话
            return False
Example #13
0
    def advanced_talent(self, ucid):
        '''
        *天赋进阶
        miaoyichao
        '''

        if not self.cards[ucid].get('talent_lv',''):
            self.cards[ucid]['talent_lv'] = 0
        #天赋进阶前的天赋等级
        before_lv = copy.deepcopy(self.cards[ucid]['talent_lv'])
        #判断和最大天赋等级之间的差距
        max_talent_lv = int(self.game_config.card_config[self.cards[ucid]['cid']]['max_talent_lv'])
        if self.cards[ucid]['talent_lv'] >= max_talent_lv:
            self.cards[ucid]['talent_lv'] = max_talent_lv
        else:
            self.cards[ucid]['talent_lv'] += 1

        #开始记录日志信息
        cid_config = self.game_config.card_config[self.cards[ucid]['cid']]
        log_data = {
            'cid': self.cards[ucid]['cid'],
            'ucid': ucid,
            'before_talent_lv': before_lv,
            'after_talent_lv': self.cards[ucid]['talent_lv'],
            'card_msg': self.cards[ucid],
            'name': cid_config['name'],
            'star': cid_config['star'],
        }

        data_log_mod.set_log('CardTalentUpdate', self, **log_data)
        #日志记录完毕
        self.put()
Example #14
0
def ali_charge_result(request):
    """支付宝充值回调
    """
    #验证成功发给用户商品
    
    print 'ali_charge_result: ', request
    oid = request.REQUEST['oid']
    item_id = request.REQUEST['item_id']
    item_info = game_config.shop_config['sale'][item_id]
    total_price = float(request.REQUEST.get('total_price', '1'))
    if float(item_info['price']) != total_price:
        return HttpResponse(
               json.dumps({'rc': 3}, indent=1),
               content_type='application/x-javascript',)

    data = charge_api(request.rk_user, oid, item_id,platform='',res_dict={},request=request,charge_way='alipay')
    data['data']['user_info'] = request.rk_user.wrapper_info()
    data['data']['server_now'] = int(time.time())
    data_log_mod.set_log('ChargeResultLog', **{'uid':request.rk_user.uid,'charge_way':'ali',\
                                              'result':data['result'],'oid':oid,'item_id':item_id,'subarea': request.rk_user.subarea,})
    data.pop("result")
    return HttpResponse(
                json.dumps(data, indent=1),
                content_type='application/x-javascript',
            )
Example #15
0
 def minus_materials(self, materials, where=""):
     """
     批量扣除材料
     """
     pt_fg = False
     for material_id in materials:
         num = abs(materials[material_id])
         if self.is_material_enough(material_id,num):
             #获取扣除前的数量
             before = self.materials[material_id]
             self.materials[material_id] -= num
             #获取扣除后的数量
             after  = self.materials[material_id]
             if after<=0:
                 self.materials.pop(material_id)
             pt_fg = True
             if where:
                 log_data = {
                     'where':where,
                     'mat_id':material_id,
                     'num':num,
                     'after': after,
                     'before': before
                 }
                 data_log_mod.set_log('MatConsume', self, **log_data)
     if pt_fg:
         #保存修改内容
         self.put()
Example #16
0
def inf_result_fight(msg_data, self, opponent):
    print "!!!!!!!!", msg_data
    if "winner" in msg_data:
        self_uid = self.uid
        opponent_uid = opponent.uid
        # self_core_id = self.core_id
        # opponent.core_id = opponent.core_id
        if not opponent.connecting:
            win_uid, lose_uid = (self_uid, opponent_uid)
        else:
            # datafield = msg_data['datafield']
            # win_core_id = msg_data[datafield]["win"]
            # win_uid, lose_uid = (self_uid, opponent_uid) if win_core_id == self_core_id else (opponent_uid, self_uid)
            win_uid = msg_data["winner"]
            win_uid, lose_uid = (self_uid,
                                 opponent_uid) if win_uid == self_uid else (
                                     opponent_uid, self_uid)
        result_info = real_pvp.result_fight(win_uid, lose_uid)

        self_user_pvp_object = UserRealPvp.get(win_uid)
        opponent_user_pvp_object = UserRealPvp.get(lose_uid)

        data_log_mod.set_log(
            'PvpRecord', UserRealPvp.get(self.uid), **{
                "winner": self_user_pvp_object.pvp_detail,
                "loser": opponent_user_pvp_object.pvp_detail,
                "end_reason": msg_data["pvp_end_reason"],
            })

        success_data = dict(msgtype='inf_result_fight', )
        msg_data.update(result_info)
        return response_success(msg_data, success_data)
    return {}
Example #17
0
    def minus_gold(self, gold, where=""):
        """
        减少gold数量
        input gold
        output True False
        """
        gold = abs(gold)
        #判断金币是否足够
        if self.is_gold_enough(gold):
            #之前的金币和减少后的
            before = self.property_info['gold']
            self.property_info['gold'] -= gold
            self.put()
            after = self.property_info['gold']
            #写日志

            log_data = {
                'where': where,
                'num': gold,
                'before': before,
                'after': after
            }
            data_log_mod.set_log('GoldConsume', self, **log_data)
            return True
        else:
            return False
Example #18
0
    def add_card(self, cid, lv=1, where=""):
        """将得到的卡加入背包中
        args
            cid: string 卡ID
            lv: 卡的等级
            sk_lv: string 卡特技等级
        return:
            bool:True 加入成功,False:超过最大上限,加入失败
            int:现在背包中卡的枚数
            int:用户的上限枚数
            string:卡的自定义ID
            is_first:是否是首次得到该卡片
        """
        ucid, is_first = self.__add_card(cid, int(lv), where=where)
        cid_config = self.game_config.card_config[cid]
        all_cards_num = self.get_cards_num()

        log_data = {
            'where': where,
            'ucid': ucid,
            'card_msg': self.cards[ucid],
            'name': cid_config['name'],
            'star': cid_config['star'],
        }

        data_log_mod.set_log('CardProduct', self, **log_data)
        return True, all_cards_num, ucid, is_first
Example #19
0
 def del_card_info(self, ucids, where=None):
     """
     批量删除用户的卡信息
     Args:
         ucid: 自动生成的卡ID
     """
     put_fg = False
     for ucid in ucids:
         if ucid in self.cards:
             card_info = self.cards[ucid]
             cid = card_info['cid']
             #默认只有四星五星的武将
             cid_config = self.game_config.card_config[cid]
             if where:
                 card_msg = {
                     'cid': cid,
                     'ctype': cid_config['ctype'],
                     'lv': card_info['lv'],
                     'exp': self.cards[ucid]['exp'],
                     'name': cid_config['name'],
                     'star': cid_config['star'],
                 }
                 log_data = {
                     'where': where,
                     'ucid': ucid,
                     'card_msg': card_msg,
                 }
                 data_log_mod.set_log('CardConsume', self, **log_data)
             self.cards.pop(ucid)
             put_fg = True
     if put_fg:
         self.put()
Example #20
0
    def advanced_talent(self, ucid):
        '''
        *天赋进阶
        miaoyichao
        '''

        if not self.cards[ucid].get('talent_lv', ''):
            self.cards[ucid]['talent_lv'] = 0
        #天赋进阶前的天赋等级
        before_lv = copy.deepcopy(self.cards[ucid]['talent_lv'])
        #判断和最大天赋等级之间的差距
        max_talent_lv = int(self.game_config.card_config[
            self.cards[ucid]['cid']]['max_talent_lv'])
        if self.cards[ucid]['talent_lv'] >= max_talent_lv:
            self.cards[ucid]['talent_lv'] = max_talent_lv
        else:
            self.cards[ucid]['talent_lv'] += 1

        #开始记录日志信息
        cid_config = self.game_config.card_config[self.cards[ucid]['cid']]
        log_data = {
            'cid': self.cards[ucid]['cid'],
            'ucid': ucid,
            'before_talent_lv': before_lv,
            'after_talent_lv': self.cards[ucid]['talent_lv'],
            'card_msg': self.cards[ucid],
            'name': cid_config['name'],
            'star': cid_config['star'],
        }

        data_log_mod.set_log('CardTalentUpdate', self, **log_data)
        #日志记录完毕
        self.put()
Example #21
0
def index(request):
    """ 应用首页,输出top page"""
    
    data = {
        'rc':0,
        'data':{
         'server_now':int(time.time()),
         'pid':request.rk_user.pid,
         'uid':request.rk_user.uid,
         # 'newbie': False,
         # 'newbie_step': 10,
         'username':request.rk_user.username,
        }
    }
    if request.rk_user.is_new:
#        invite_code = request.REQUEST.get('invite_code')
#        _record_invite_code(request.rk_user,invite_code)
        if request.rk_user.platform == 'oc':
            data['data']['oc_openid'] = request.rk_user.account.openid
            data['data']['oc_access_token'] = request.rk_user.account.access_token
#    #设备唯一标识
#    mac_addr = request.REQUEST.get("uuid", "")
#    if mac_addr and mac_addr not in request.rk_user.client_macaddr:
#        request.rk_user.add_client_macaddr(mac_addr)
#    #下载渠道标识
#    mktid = request.REQUEST.get("mktid", "")
#    if mktid and mktid not in request.rk_user.mktids:
#        request.rk_user.add_mktid(mktid)
    data_log_mod.set_log('LoginRecord', request.rk_user, **{'version': request.REQUEST.get('version', '')})
    return HttpResponse(
        json.dumps(data, indent=1),
        content_type='application/x-javascript',
    )
Example #22
0
    def minus_card_soul(self, soul_id, num, where=None):
        """
        删除武将碎片 
        输入 碎片id 数量
        输出 True or False 
        """
        num = abs(num)
        if num == 0:
            return False
        if self.is_normal_soul_enough(soul_id, num):
            #  判断魂卡id是否存在
            #  card_config没有配souls_needed或者配的是0
            if self.game_config.card_config[soul_id].get("souls_needed", 0) == 0:
                return False
            self.normal_souls[soul_id]["num"] -= num
            if self.normal_souls[soul_id]["num"] <= 0:
                self.normal_souls.pop(soul_id)
        else:
            return False
        self.put()

        if where:
            log_data = {"where": where, "soul_id": soul_id, "num": num}
            data_log_mod.set_log("SoulConsume", self, **log_data)
        return True
Example #23
0
 def minus_multi_props(self, all_props, where=None):
     """
     批量扣除道具
     """
     pt_fg = False
     for props_id in all_props:
         num = abs(all_props[props_id])
         if self.is_props_enough(props_id, num):
             #获取扣除前的数量
             before = self.props[props_id]
             self.props[props_id] -= num
             pt_fg = True
             #获取扣除后的数量
             after = self.props[props_id]
             if after <= 0:
                 self.props.pop(props_id)
             if where:
                 log_data = {
                     'where': where,
                     'props_id': props_id,
                     'num': num,
                     'after': after,
                     'before': before,
                 }
                 data_log_mod.set_log('PropsConsume', self, **log_data)
     if pt_fg:
         #保存修改内容
         self.put()
Example #24
0
 def minus_multi_props(self, all_props, where=None):
     """
     批量扣除道具
     """
     pt_fg = False
     for props_id in all_props:
         num = abs(all_props[props_id])
         if self.is_props_enough(props_id,num):
             #获取扣除前的数量
             before = self.props[props_id]
             self.props[props_id] -= num
             pt_fg = True
             #获取扣除后的数量
             after  = self.props[props_id]
             if after<=0:
                 self.props.pop(props_id)
             if where:
                 log_data = {
                     'where':where,
                     'props_id':props_id,
                     'num':num,
                     'after': after,
                     'before': before,
                 }
                 data_log_mod.set_log('PropsConsume', self, **log_data)
     if pt_fg:
         #保存修改内容
         self.put()
Example #25
0
    def add_material(self, mat_id, num, where=""):
        '''
        *添加素材
        '''
        #获取添加前的数量
        before = self.materials.get(mat_id, 0)
        if mat_id not in self.materials:
            self.materials[mat_id] = abs(num)
        else:
            self.materials[mat_id] += abs(num)
        #获取添加后的数量
        after = self.materials[mat_id]

        log_data = {
            'where': where,
            'mat_id': mat_id,
            'num': num,
            'after': after,
            'before': before
        }
        data_log_mod.set_log('MatProduct', self, **log_data)
        #加入图鉴
        UserCollection.get_instance(self.uid).add_collected_card(
            mat_id, 'materials')
        self.put()
Example #26
0
    def set_newbie_steps(self, step, step_name):
        '''
        记录新手引导中的步骤信息
        '''
        step = int(step)
        newbie_step = int(self.property_info['newbie_steps'])

        # 只是处理符合要求的新手引导
        if newbie_step < step:
            self.property_info['newbie_steps'] = step
            #获取系统配置中的新手步骤   也就是走多少步可以认为不是新手
            newbie_steps_num = int(
                self.game_config.system_config.get('newbie_steps', 6))
            step_flag = (1 << (newbie_steps_num - 1)) - 1
            log_data = {
                "step_name": step_name,
                "step_id": step,
                "complete": False
            }
            # #判断是否需要将新手设置为非新手
            if self.newbie and step_flag <= step:
                log_data["complete"] = True
                self.set_newbie()
            data_log_mod.set_log('NewGuide', self, **log_data)

            # 只要完成最后一步的新手引导完成 就认为不是新手

            print "deubg guochen set_newbie", self.uid, "this step", step, "last_step", step_flag, "step_name", step_name, "complete", log_data[
                "complete"]
            self.put()
Example #27
0
    def add_card(self, cid, lv=1, where=""):
        """将得到的卡加入背包中
        args
            cid: string 卡ID
            lv: 卡的等级
            sk_lv: string 卡特技等级
        return:
            bool:True 加入成功,False:超过最大上限,加入失败
            int:现在背包中卡的枚数
            int:用户的上限枚数
            string:卡的自定义ID
            is_first:是否是首次得到该卡片
        """
        ucid,is_first = self.__add_card(cid, int(lv), where=where)
        cid_config = self.game_config.card_config[cid]
        all_cards_num = self.get_cards_num()

        log_data = {
            'where':where,
            'ucid':ucid,
            'card_msg': self.cards[ucid],
            'name': cid_config['name'],
            'star': cid_config['star'],
        }

        data_log_mod.set_log('CardProduct', self, **log_data)
        return True,all_cards_num,ucid,is_first
Example #28
0
 def add_honor(self, num, where=''):
     # 返回实际的honor变化值
     old_honor = self.pvp_info['honor']
     new_honor = old_honor + num
     self.pvp_info['honor'] = new_honor
     self.put()
     log_data = {'where': where, 'num': num, 'before': old_honor, 'after': new_honor}
     data_log_mod.set_log('HonorProduct', self, **log_data)
     return self.pvp_info['honor'] - old_honor
Example #29
0
    def add_treasure_equip_exp(self, ueid, up_exp, user_lv, where=""):
        '''
        * 给宝物添加经验和等级
        * input:base_equip up_exp user_lv where
        * output:None
        '''
        equip = copy.deepcopy(self.equips[ueid])
        # 获取该装备的最大的等级
        max_lv = min(self.game_config.equip_config[equip['eid']].get('equipMaxLv', 3), 2*user_lv)
        # 获取装备的星级
        star = self.game_config.equip_config[equip['eid']].get('star', 2)
        # 获取系数 百分位的
        coefficient = self.game_config.equip_exp_config['treasure_exp_coe'][str(star)]
        old_lv = equip['cur_lv']
        old_experience = equip['cur_experience']
        all_exp = old_experience + up_exp
        # 如果需要升级的话 当前等级
        can_up_lv = old_lv
        # 计算所能升的最大的等级
        for lv in xrange(old_lv, max_lv + 1):
            cur_lv_exp = int(self.game_config.equip_exp_config['treasure_exp'][str(lv)] * coefficient)
            if cur_lv_exp <= all_exp:
                can_up_lv = lv
            else:
                break

        # 计算新的等级
        new_lv = can_up_lv 
        # 判断要升的级数是不是大于可以升的级数
        if new_lv >= max_lv:
            # 新的等级设置为最大
            new_lv = max_lv
            # 新的经验设置为最大
            all_exp = int(self.game_config.equip_exp_config['treasure_exp'][str(new_lv)]*coefficient)

        new_experience = all_exp

        # 修改经验和等级
        self.equips[ueid]['cur_lv'] = new_lv
        self.equips[ueid]['upd_time'] = int(time.time())
        self.equips[ueid]['cur_experience'] = new_experience
        data = {'ueid':ueid}
        data.update(self.equips[ueid])
        self.put()
        #装备升级 写日志
        if old_lv < new_lv:
            log_data = {
                'where': where,
                'eid': equip['eid'],
                'after_lv': new_lv,
                'before_lv': old_lv,
                'equip_msg': self.equips[ueid],
            }

            data_log_mod.set_log('EquUpdate', self, **log_data)
        return data
Example #30
0
 def minus_honor(self, num, where=''):
     if self.pvp_info['honor'] >= num:
         old_honor = self.pvp_info['honor']
         new_honor = self.pvp_info['honor'] - num
         self.pvp_info['honor'] = new_honor
         self.put()
         log_data = {'where': where, 'num': num, 'before': old_honor, 'after': new_honor}
         data_log_mod.set_log('HonorConsume', self, **log_data)
         return True
     return False
Example #31
0
    def add_fight_soul(self, fight_soul, where=""):
        '''
        添加战魂
        '''
        self.property_info["fight_soul"] += fight_soul

        log_data = {'where':where, 'num': fight_soul, "after": self.get_fight_soul}
        data_log_mod.set_log('FightSoulProduct', self, **log_data)

        self.put()
Example #32
0
    def add_com_equip_exp(self, ueid, vip_lv, user_lv, where=""):
        """
        增加装备经验值
        args:
            ueid:装备的唯一id
            exp:所要增加的经验值 也就是金币数目
        return:
            暴击次数, ueid_info  
        """
        equip = self.equips[ueid]
        # 获取该装备的最大的等级
        max_lv = self.game_config.equip_config[equip['eid']]['equipMaxLv']
        crit_list = self.game_config.user_vip_config[str(vip_lv)]['crit']
        crit = utils.windex(crit_list)
        old_lv = equip['cur_lv']
        # 装备升级可能会产生暴击,产生暴击时会连升几级
        new_lv = old_lv + crit
        # 不能大于当前用户最大等级的2倍
        user_equip_max_lv = 2 * user_lv
        if max_lv >= user_equip_max_lv:
            max_lv = user_equip_max_lv
        # 判断要升的级数是不是大于可以升的级数
        if new_lv >= max_lv:
            new_lv = max_lv

        # 获取装备的星级
        star = self.game_config.equip_config[equip['eid']].get('star', 2)
        # 获取系数
        coefficient = self.game_config.equip_exp_config['common_gold_coe'][str(
            star)]

        # 修改经验和等级
        self.equips[ueid]['cur_lv'] = new_lv
        self.equips[ueid]['upd_time'] = int(time.time())
        self.equips[ueid]['cur_experience'] = int(
            self.game_config.equip_exp_config['common_gold'][str(new_lv)] *
            coefficient)
        # 处理返回的数据
        data = {'ueid': ueid}
        data.update(self.equips[ueid])
        self.put()

        #装备升级 写日志
        if old_lv < new_lv:
            log_data = {
                'where': where,
                'eid': equip['eid'],
                'after_lv': new_lv,
                'before_lv': old_lv,
                'equip_msg': self.equips[ueid],
            }

            data_log_mod.set_log('EquUpdate', self, **log_data)

        return crit - 1, data
Example #33
0
    def add_card_exp_point(self, card_exp_point, where=""):
        """
        添加武将经验点
        """
        card_exp_point = abs(card_exp_point)
        self.property_info['card_exp_point'] += card_exp_point

        #写日志
        log_data = {'where': where, 'num': card_exp_point, 'after': self.property_info['card_exp_point']}
        data_log_mod.set_log('CardExpPoint', self, **log_data)
        self.put()
Example #34
0
    def add_com_equip_exp(self, ueid, vip_lv, user_lv, where=""):
        """
        增加装备经验值
        args:
            ueid:装备的唯一id
            exp:所要增加的经验值 也就是金币数目
        return:
            暴击次数, ueid_info  
        """
        equip = self.equips[ueid]
        # 获取该装备的最大的等级
        max_lv = self.game_config.equip_config[equip['eid']]['equipMaxLv']
        crit_list = self.game_config.user_vip_config[str(vip_lv)]['crit']
        crit = utils.windex(crit_list)
        old_lv = equip['cur_lv']
        # 装备升级可能会产生暴击,产生暴击时会连升几级
        new_lv = old_lv + crit
        # 不能大于当前用户最大等级的2倍
        user_equip_max_lv = 2 * user_lv
        if max_lv >= user_equip_max_lv:
            max_lv = user_equip_max_lv
        # 判断要升的级数是不是大于可以升的级数
        if new_lv >= max_lv:
            new_lv = max_lv

        # 获取装备的星级
        star = self.game_config.equip_config[equip['eid']].get('star', 2)
        # 获取系数
        coefficient = self.game_config.equip_exp_config['common_gold_coe'][str(star)]

        # 修改经验和等级
        self.equips[ueid]['cur_lv'] = new_lv
        self.equips[ueid]['upd_time'] = int(time.time())
        self.equips[ueid]['cur_experience'] = int(self.game_config.equip_exp_config['common_gold'][str(new_lv)] * coefficient)
        # 处理返回的数据
        data = {'ueid': ueid}
        data.update(self.equips[ueid])
        self.put()

        #装备升级 写日志
        if old_lv < new_lv:
            log_data = {
                'where': where,
                'eid': equip['eid'],
                'after_lv': new_lv,
                'before_lv': old_lv,
                'equip_msg': self.equips[ueid],
            }

            data_log_mod.set_log('EquUpdate', self, **log_data)

        return crit - 1, data
Example #35
0
    def add_gold(self, gold, where=""):
        """
        增加用户的金币
        """
        before = self.property_info['gold'] 
        self.property_info['gold'] += gold
        self.put()
        after = self.property_info['gold']

        #写日志
        log_data = {'where': where, 'num': gold, 'before': before, 'after': after, }
        data_log_mod.set_log('GoldProduct', self, **log_data)
        return
Example #36
0
 def minus_card_exp_point(self, card_exp_point, where=""):
     """
     减少card_exp_point 武将经验点
     """
     card_exp_point = abs(card_exp_point)
     if self.is_card_exp_point_enough(card_exp_point):
         self.property_info['card_exp_point'] -= card_exp_point
         self.put()
         #写日志
         log_data = {'where': where, 'num': -card_exp_point, 'after': self.property_info['card_exp_point']}
         data_log_mod.set_log('CardExpPoint', self, **log_data)
         return True
     else:
         return False
Example #37
0
    def add_coin(self, coin, where=""):
        """
        增加用户的代币
        input coin
        output None
        """
        before = self.property_info['coin']
        self.property_info['coin'] += coin
        self.put()
        after  = self.property_info['coin']

        log_data = {'where': where, 'num': coin, 'before': before, 'after': after}
        data_log_mod.set_log('CoinProduct', self, **log_data)
        return
Example #38
0
    def add_fight_soul(self, fight_soul, where=""):
        '''
        添加战魂
        '''
        self.property_info["fight_soul"] += fight_soul

        log_data = {
            'where': where,
            'num': fight_soul,
            "after": self.get_fight_soul
        }
        data_log_mod.set_log('FightSoulProduct', self, **log_data)

        self.put()
Example #39
0
    def add_card_exp_point(self, card_exp_point, where=""):
        """
        添加武将经验点
        """
        card_exp_point = abs(card_exp_point)
        self.property_info['card_exp_point'] += card_exp_point

        #写日志
        log_data = {
            'where': where,
            'num': card_exp_point,
            'after': self.property_info['card_exp_point']
        }
        data_log_mod.set_log('CardExpPoint', self, **log_data)
        self.put()
Example #40
0
 def minus_fight_soul(self, fight_soul, where=None):
     """
     扣除战魂点
     """
     fight_soul = abs(fight_soul)
     if self.is_fight_soul_enough(fight_soul):
         self.property_info['fight_soul'] -= fight_soul
         self.put()
         #写日志
         if where:
             log_data = {'where':where, 'num': fight_soul, "after": self.get_fight_soul}
             data_log_mod.set_log('FightSoulConsume', self, **log_data)
         return True
     else:
         return False
Example #41
0
    def add_equip(self, eid, where=None, quality=''):
        """增加装备对外接口

        Args:
            eid: 装备唯一标示符
            quality: 品质  例如  蓝装 、紫装
        """
        addret, ueid, is_first = self.__add_equip(eid)
        if addret and where:
            log_data = {'where': where,
                        'equip_dict': self.get_equip_dict(ueid),
                        'name': self.game_config.equip_config[eid]['name'],
            }
            data_log_mod.set_log('EquProduct', self, **log_data)
        all_equips_num = self.get_equips_num()
        return True, all_equips_num, ueid, is_first
Example #42
0
    def add_equip(self, eid, where=None, quality=''):
        """增加装备对外接口

        Args:
            eid: 装备唯一标示符
            quality: 品质  例如  蓝装 、紫装
        """
        addret, ueid, is_first = self.__add_equip(eid)
        if addret and where:
            log_data = {
                'where': where,
                'equip_dict': self.get_equip_dict(ueid),
                'name': self.game_config.equip_config[eid]['name'],
            }
            data_log_mod.set_log('EquProduct', self, **log_data)
        all_equips_num = self.get_equips_num()
        return True, all_equips_num, ueid, is_first
Example #43
0
def buy_store_goods(rk_user, params):
    """
    用功勋兑换 Pk 商店物品
    params  参数需包含 
        goods_index:   所兑换的物品index
    返回 data 包括所兑换物品和商店信息
    """

    goods_index = int(params['goods_index'])
    user_pk_store = rk_user.user_pk_store
    user_pk_goods = user_pk_store.goods
    
    
    # pk商店无此物品
    if not (0 <= goods_index < len(user_pk_goods)):
        return 11, {'msg': utils.get_msg('pk_store', 'no_this_goods')}
    
    goods_info = user_pk_goods[goods_index]
    
    # 已兑换过
    if not user_pk_store.can_buy_this_goods(goods_index):
        raise GameLogicError('pk_store', 'can_not_buy_again')
    need_honor = goods_info['need_honor']
    # 兑换所需功勋点不够
    user_real_pvp = rk_user.user_real_pvp
    if not user_real_pvp.is_honor_enough(need_honor):
        raise GameLogicError('pk_store', 'not_enough_honor')
    # 扣除功勋
    user_real_pvp.minus_honor(need_honor, where='buy_PkStore_goods')
    # 兑换物品
    user_pk_store.goods_has_bought(goods_index)

    # 发放兑换物品
    all_get_goods = tools.add_things(rk_user,
                             [goods_info['goods']],
                             where="buy_pk_store_goods")


    # 记录log
    log_data = {"cost_honor": need_honor, "goods": all_get_goods}
    data_log_mod.set_log("PkStore", rk_user, **log_data)

    data = {'get_info': all_get_goods}
    data.update(_pack_store_info(user_pk_store.store_info()))
    return data
Example #44
0
 def minus_material(self, material_id, num, where=None):
     '''
     * 一次扣除一种素材
     '''
     num = abs(num)
     if self.is_material_enough(material_id, num):
         #获取扣除前的数量
         self.materials[material_id] -= num
         #获取扣除后的数量
         after = self.materials[material_id]
         if after <= 0:
             self.materials.pop(material_id)
         self.put()
         if where:
             log_data = {'where': where, 'mat_id': material_id, 'num': num}
             data_log_mod.set_log('MatConsume', self, **log_data)
         return True
     return False
Example #45
0
 def minus_material(self,material_id,num,where=None):
     '''
     * 一次扣除一种素材
     '''
     num = abs(num)
     if self.is_material_enough(material_id,num):
         #获取扣除前的数量
         self.materials[material_id] -= num
         #获取扣除后的数量
         after  = self.materials[material_id]
         if after<=0:
             self.materials.pop(material_id)
         self.put()
         if where:
             log_data = {'where':where, 'mat_id': material_id, 'num': num}
             data_log_mod.set_log('MatConsume', self, **log_data)
         return True
     return False
Example #46
0
 def add_props(self,props_id,props_num,where=None):
     '''
     * 添加道具
     '''
     #获取添加前的数量
     before = self.props.get(props_id, 0)
     if props_id not in self.props:
         self.props[props_id] = abs(props_num)
     else:
         self.props[props_id] += abs(props_num)
     #获取添加后的数量
     after = self.props.get(props_id, 0)
     if where:
         log_data = {'where':where, 'props_id':props_id, 'num':props_num, 'after': after, 'before': before}
         data_log_mod.set_log('PropsProduct', self, **log_data)
     #加入图鉴  暂无图片 和id所以先不加图鉴信息
     #UserCollection.get_instance(self.uid).add_collected_card(props_id,'props')
     self.put()
Example #47
0
    def add_material(self, mat_id, num, where=""):
        '''
        *添加素材
        '''
        #获取添加前的数量
        before = self.materials.get(mat_id, 0)
        if mat_id not in self.materials:
            self.materials[mat_id] = abs(num)
        else:
            self.materials[mat_id] += abs(num)
        #获取添加后的数量
        after = self.materials[mat_id]

        log_data = {'where': where, 'mat_id':mat_id, 'num':num, 'after': after, 'before': before}
        data_log_mod.set_log('MatProduct', self, **log_data)
        #加入图鉴
        UserCollection.get_instance(self.uid).add_collected_card(mat_id, 'materials')
        self.put()
Example #48
0
 def minus_card_exp_point(self, card_exp_point, where=""):
     """
     减少card_exp_point 武将经验点
     """
     card_exp_point = abs(card_exp_point)
     if self.is_card_exp_point_enough(card_exp_point):
         self.property_info['card_exp_point'] -= card_exp_point
         self.put()
         #写日志
         log_data = {
             'where': where,
             'num': -card_exp_point,
             'after': self.property_info['card_exp_point']
         }
         data_log_mod.set_log('CardExpPoint', self, **log_data)
         return True
     else:
         return False
Example #49
0
    def add_gold(self, gold, where=""):
        """
        增加用户的金币
        """
        before = self.property_info['gold']
        self.property_info['gold'] += gold
        self.put()
        after = self.property_info['gold']

        #写日志
        log_data = {
            'where': where,
            'num': gold,
            'before': before,
            'after': after,
        }
        data_log_mod.set_log('GoldProduct', self, **log_data)
        return
Example #50
0
 def add_equip_soul(self, soul_id, num, where=None):
     """
     添加装备碎片 
     输入 碎片 id 数量
     输出 成功标志 碎片 id 数量
     """
     num = abs(num)
     #获取长度
     soul_id_split_len = len(soul_id.split('_'))
     if 2 <= soul_id_split_len <= 3:
         #符合要求的长度
         if soul_id_split_len == 2:
             #普通装备
             check_id = soul_id
         else:
             #宝物装备
             check_id = '%s_%s' % (soul_id.split('_')[0],
                                   soul_id.split('_')[1])
     else:
         #不符合要求
         return False, '', 0
     #判断 equip_id 是否存在配置中, 并且可以用碎片合成(有need_souls且不为0)
     if not self.game_config.equip_config.get(check_id,
                                              {}).get('need_souls'):
         return False, '', 0
     #判断equip_souls_info 是否为空
     if not self.equip_souls_info:
         self.equip_souls_info = {}
     #装备 id 是否已经存在
     if soul_id in self.equip_souls_info:
         self.equip_souls_info[soul_id]['num'] += num
     else:
         self.equip_souls_info[soul_id] = {'num': num}
     #数据保存
     self.put()
     if where:
         #写日志
         log_data = {
             'where': where,
             'soul_id': soul_id,
             'num': num,
         }
         data_log_mod.set_log('SoulProduct', self, **log_data)
     return True, soul_id, num
Example #51
0
 def minus_fight_soul(self, fight_soul, where=None):
     """
     扣除战魂点
     """
     fight_soul = abs(fight_soul)
     if self.is_fight_soul_enough(fight_soul):
         self.property_info['fight_soul'] -= fight_soul
         self.put()
         #写日志
         if where:
             log_data = {
                 'where': where,
                 'num': fight_soul,
                 "after": self.get_fight_soul
             }
             data_log_mod.set_log('FightSoulConsume', self, **log_data)
         return True
     else:
         return False
Example #52
0
    def add_coin(self, coin, where=""):
        """
        增加用户的代币
        input coin
        output None
        """
        before = self.property_info['coin']
        self.property_info['coin'] += coin
        self.put()
        after = self.property_info['coin']

        log_data = {
            'where': where,
            'num': coin,
            'before': before,
            'after': after
        }
        data_log_mod.set_log('CoinProduct', self, **log_data)
        return
Example #53
0
def charge_result_pp(request):
    """
    pp获得玩家的充值行为后,用此api通知我们
    第一步  验证pp 的请求参数
    第二步  给玩家充值
    """
    status = int(request.REQUEST['status'])
    #已经兑现过了
    if status == 1:
        return HttpResponse('success')
    
    #订单验证失败
    sign = request.REQUEST['sign']
    rc, pp_sign = decode_pp_callback(sign) 
    if rc or pp_sign == {}:
        return HttpResponse('fail')
    
    #订单是否处理过
    billno = pp_sign['billno']
    billno_req = request.REQUEST['billno']
    if billno_req != billno:
        return HttpResponse('fail')
    #是否是正确的玩家
    uid = pp_sign['roleid']
    
    mi_record = data_log_mod.get_log_model("OrderRecord").find({'oid':billno})
    if not mi_record:
        return HttpResponse('fail')
    item_id = mi_record[0].item_id
    oc_uid = mi_record[0].uid
    if oc_uid != uid:
        return HttpResponse('fail')

    rk_user = UserBase.get(oc_uid)
    if not rk_user:
        return HttpResponse('fail')
    
    data = charge_api(rk_user, billno, item_id, platform = 'pp',res_dict={},request = request, charge_way='pp')
    data_log_mod.set_log('ChargeResultLog', rk_user, **{'charge_way':'pp',
                                              'result':data['result'],'oid':billno,'item_id':item_id})
    if data['rc'] != 0:
        return HttpResponse('fail')
    return HttpResponse('success') 
Example #54
0
def buy_store_goods(rk_user, params):
    """
    用功勋兑换 Pk 商店物品
    params  参数需包含 
        goods_index:   所兑换的物品index
    返回 data 包括所兑换物品和商店信息
    """

    goods_index = int(params['goods_index'])
    user_pk_store = rk_user.user_pk_store
    user_pk_goods = user_pk_store.goods

    # pk商店无此物品
    if not (0 <= goods_index < len(user_pk_goods)):
        return 11, {'msg': utils.get_msg('pk_store', 'no_this_goods')}

    goods_info = user_pk_goods[goods_index]

    # 已兑换过
    if not user_pk_store.can_buy_this_goods(goods_index):
        raise GameLogicError('pk_store', 'can_not_buy_again')
    need_honor = goods_info['need_honor']
    # 兑换所需功勋点不够
    user_real_pvp = rk_user.user_real_pvp
    if not user_real_pvp.is_honor_enough(need_honor):
        raise GameLogicError('pk_store', 'not_enough_honor')
    # 扣除功勋
    user_real_pvp.minus_honor(need_honor, where='buy_PkStore_goods')
    # 兑换物品
    user_pk_store.goods_has_bought(goods_index)

    # 发放兑换物品
    all_get_goods = tools.add_things(rk_user, [goods_info['goods']],
                                     where="buy_pk_store_goods")

    # 记录log
    log_data = {"cost_honor": need_honor, "goods": all_get_goods}
    data_log_mod.set_log("PkStore", rk_user, **log_data)

    data = {'get_info': all_get_goods}
    data.update(_pack_store_info(user_pk_store.store_info()))
    return data
Example #55
0
 def add_normal_soul(self, soul_id, num, where=None):
     """
     添加武将碎片
     输入  碎片 id 数量
     输出 保存成功与否 碎片 id 数量
     """
     num = abs(num)
     #  判断魂卡id是否存在
     #  card_config没有配souls_needed或者配的是0
     if self.game_config.card_config[soul_id].get("souls_needed", 0) == 0:
         return False, "", 0
     if soul_id in self.normal_souls:
         self.normal_souls[soul_id]["num"] += num
     else:
         self.normal_souls[soul_id] = {"num": num}
     self.put()
     if where:
         log_data = {"where": where, "soul_id": soul_id, "num": num}
         data_log_mod.set_log("SoulProduct", self, **log_data)
     return True, soul_id, num
Example #56
0
    def delete_equip(self, ueids, where=None):
        """
        删除装备
        """
        pt_fg = False
        for ueid in ueids:
            if ueid in self.equips:
                if where:
                    equip_dict = self.get_equip_dict(ueid)
                    eid = equip_dict['eid']

                    log_data = {
                        'where': where,
                        'equip_dict': equip_dict,
                        'name': self.game_config.equip_config[eid]['name'],
                    }

                    data_log_mod.set_log('EquConsume', self, **log_data)
                self.equips.pop(ueid)
                pt_fg = True
        if pt_fg:
            self.put()
Example #57
0
def buy_store_goods(rk_user, params):
    """
    玩家购买指定商品时逻辑
    params  参数需包含 store_type: 可选  "packages"   "gold_store"  or  "coin_store" 
                     goods_index:  int  为所买商品在所属类型的index   
    """
    #store_type = params['store_type']
    goods_index = int(params['goods_index'])

    buy_goods_info = {}
    goods_list = []
    user_mystery_store_obj = rk_user.user_mystery_store

    buy_goods_info = user_mystery_store_obj.store_info()['store'][goods_index]
    goods_list.append(buy_goods_info['goods'])
    need = "need_coin" if buy_goods_info.get("need_coin", 0) else "need_fight_soul"
    needed_cost = buy_goods_info.get(need, 0)
    fight_or_coin = need.replace("need_", "")
   

    #  根据store_type  决定是 消耗元宝还是战魂
    minus_func = getattr(rk_user.user_property, "minus_" + fight_or_coin)

    if not minus_func(needed_cost, 'buy_mystery_store_goods'):
        raise GameLogicError('user', 'not_enough_' + fight_or_coin)

    # 发商品    
    # 前端通过rc 是否等于 0 判断是否购买成功
    if not user_mystery_store_obj.update_goods_info_by_index(goods_index):
        raise GameLogicError('has bought this item')
    all_get_goods = tools.add_things(rk_user, goods_list, where=u"buy_from_mystery_store")

    # 记录log
    log_data = {"cost": fight_or_coin, "cost_num": needed_cost, "goods": goods_list}
    data_log_mod.set_log("MysteryStore", rk_user, **log_data)

    return {'get_info': all_get_goods}