diff --git a/configs/config.json.example b/configs/config.json.example index ecab2fbdfe..4332ad61e7 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -12,7 +12,14 @@ "initial_transfer": 0, "location_cache": true, "distance_unit": "km", - "item_filter": "", + "item_filter": { + "1": { "keep" : 100 }, + "101": { "keep" : 10 }, + "102": { "keep" : 30 }, + "103": { "keep" : 30 }, + "201": { "keep" : 30 }, + "701": { "keep" : 100 } + }, "evolve_all": "NONE", "cp_min": 300, "use_lucky_egg": false, diff --git a/configs/config.json.pokemons.example b/configs/config.json.pokemons.example index 700da8edb4..9a22d8709c 100644 --- a/configs/config.json.pokemons.example +++ b/configs/config.json.pokemons.example @@ -12,7 +12,14 @@ "initial_transfer": 0, "location_cache": true, "distance_unit": "km", - "item_filter": "", + "item_filter": { + "1": { "keep" : 100 }, + "101": { "keep" : 10 }, + "102": { "keep" : 30 }, + "103": { "keep" : 30 }, + "201": { "keep" : 30 }, + "701": { "keep" : 100 } + }, "evolve_all": "NONE", "use_lucky_egg": false, "evolve_captured": false, diff --git a/pokecli.py b/pokecli.py index 96dace29f9..c0e8c19963 100755 --- a/pokecli.py +++ b/pokecli.py @@ -204,10 +204,6 @@ def init_config(): parser.error("Needs either --use-location-cache or --location.") return None - # When config.item_filter looks like "101,102,103" needs to be converted to ["101","102","103"] - if isinstance(config.item_filter, basestring): - config.item_filter= config.item_filter.split(",") - # create web dir if not exists try: os.makedirs(web_dir) diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 0969237bc1..e43dfccf61 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -71,17 +71,25 @@ def work(self): logger.log('- ' + str(item_count) + "x " + item_name + " (Total: " + str(self.bot.item_inventory_count(item_id)) + ")", 'yellow') + # RECYCLING UNWANTED ITEMS - if str(item_id) in self.config.item_filter: - logger.log("-- Recycling " + str(item_count) + "x " + item_name + "...", 'green') + id_filter = self.config.item_filter.get(str(item_id), 0) + if id_filter is not 0: + id_filter_keep = id_filter.get('keep',20) + new_bag_count = item_count + self.bot.item_inventory_count(item_id) + if str(item_id) in self.config.item_filter and new_bag_count >= id_filter_keep: #RECYCLE_INVENTORY_ITEM - response_dict_recycle = self.bot.drop_item(item_id=item_id, count=item_count) + items_recycle_count = new_bag_count - id_filter_keep + logger.log("-- Recycling " + str(items_recycle_count) + "x " + item_name + " to match filter "+ str(id_filter_keep) +"...", 'green') + response_dict_recycle = self.bot.drop_item(item_id=item_id, count=items_recycle_count) + result = 0 if response_dict_recycle and \ 'responses' in response_dict_recycle and \ 'RECYCLE_INVENTORY_ITEM' in response_dict_recycle['responses'] and \ - 'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']: + 'result' in response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']: result = response_dict_recycle['responses']['RECYCLE_INVENTORY_ITEM']['result'] + if result is 1: # Request success logger.log("-- Recycled " + item_name + "!", 'green') else: