def get_fudai_things(rk_user, params): """开启福袋获得物品 Args: fudai_id 开启的福袋id times 开启次数 """ fudai_id = params.get('fudai_id', '') open_times = int(params.get('times', 0)) # 判断是否是福袋 if not game_config.props_config.get(fudai_id, {}).get('used_by','') == 'fudai': raise GameLogicError('pack', 'wrong_used') # 判断用户是否有该道具 user_pack_obj = rk_user.user_pack if not user_pack_obj.is_props_enough(fudai_id, open_times): raise GameLogicError('pack', 'not_enough_props') fudai_conf = game_config.operat_config.get('fudai_conf', {}).get(fudai_id, {}) get_things_conf = fudai_conf.get('get_things', {}) get_things_list = [] for cnt in range(open_times): get_things_dict = utils.get_items_by_weight_dict(get_things_conf, 1)[0] things_id = get_things_dict['id'] things_num = get_things_dict['num'] get_things_list.append({'_id': things_id, 'num': things_num}) all_get_things = tools.add_things(rk_user, get_things_list, where=u"open_fudai_%s" %fudai_id) # 减素材 user_pack_obj.minus_props(fudai_id, open_times, where="open_fudai") return {'get_info': all_get_things}
def get_fudai_things(rk_user, params): """开启福袋获得物品 Args: fudai_id 开启的福袋id times 开启次数 """ fudai_id = params.get('fudai_id', '') open_times = int(params.get('times', 0)) # 判断是否是福袋 if not game_config.props_config.get(fudai_id, {}).get('used_by', '') == 'fudai': raise GameLogicError('pack', 'wrong_used') # 判断用户是否有该道具 user_pack_obj = rk_user.user_pack if not user_pack_obj.is_props_enough(fudai_id, open_times): raise GameLogicError('pack', 'not_enough_props') fudai_conf = game_config.operat_config.get('fudai_conf', {}).get(fudai_id, {}) get_things_conf = fudai_conf.get('get_things', {}) get_things_list = [] for cnt in range(open_times): get_things_dict = utils.get_items_by_weight_dict(get_things_conf, 1)[0] things_id = get_things_dict['id'] things_num = get_things_dict['num'] get_things_list.append({'_id': things_id, 'num': things_num}) all_get_things = tools.add_things(rk_user, get_things_list, where=u"open_fudai_%s" % fudai_id) # 减素材 user_pack_obj.minus_props(fudai_id, open_times, where="open_fudai") return {'get_info': all_get_things}
def refresh_store(self): """ 刷新商店物品 """ conf = copy.deepcopy(self.game_config.mystery_store_config["store_conf"]) selected_goods = utils.get_items_by_weight_dict(conf, 8) # 按概率取8个,不足全取 self.store = self._trans_goods_list_to_store(selected_goods) self.put()
def refresh_store(self): """ 刷新商店物品 """ conf = copy.deepcopy( self.game_config.mystery_store_config["store_conf"]) selected_goods = utils.get_items_by_weight_dict(conf, 8) # 按概率取8个,不足全取 self.store = self._trans_goods_list_to_store(selected_goods) self.put()