def _is_vip_pokemon(self, pokemon_id): # having just a name present in the list makes them vip # Not seen pokemons also will become vip if it's not disabled in config if self.bot.config.vips.get(Pokemons.name_for(pokemon_id)) == {}: return True if (not inventory.pokedex().seen(pokemon_id)): return True # If we need the Pokemon for an evolution, catch it. if any(not inventory.pokedex().seen(fid) for fid in self.get_family_ids(pokemon_id)): # self.logger.info('Found a Pokemon whoes family is not yet complete in Pokedex!') return True return False
def initialize(self): self.api = self.bot.api self.position = self.bot.position self.pokemon_list = self.bot.pokemon_list self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.spawn_point_guid = '' self.response_key = '' self.response_status_key = '' #Config self.min_ultraball_to_keep = self.config.get('min_ultraball_to_keep', 10) self.berry_threshold = self.config.get('berry_threshold', 0.35) self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) self.catch_throw_parameters = self.config.get('catch_throw_parameters', {}) self.catch_throw_parameters_spin_success_rate = self.catch_throw_parameters.get('spin_success_rate', 0.6) self.catch_throw_parameters_excellent_rate = self.catch_throw_parameters.get('excellent_rate', 0.1) self.catch_throw_parameters_great_rate = self.catch_throw_parameters.get('great_rate', 0.5) self.catch_throw_parameters_nice_rate = self.catch_throw_parameters.get('nice_rate', 0.3) self.catch_throw_parameters_normal_rate = self.catch_throw_parameters.get('normal_rate', 0.1) self.catch_throw_parameters_hit_rate = self.catch_throw_parameters.get('hit_rate', 0.8) self.catchsim_config = self.config.get('catch_simulation', {}) self.catchsim_catch_wait_min = self.catchsim_config.get('catch_wait_min', 2) self.catchsim_catch_wait_max = self.catchsim_config.get('catch_wait_max', 6) self.catchsim_flee_count = int(self.catchsim_config.get('flee_count', 3)) self.catchsim_flee_duration = self.catchsim_config.get('flee_duration', 2) self.catchsim_berry_wait_min = self.catchsim_config.get('berry_wait_min', 2) self.catchsim_berry_wait_max = self.catchsim_config.get('berry_wait_max', 3) self.catchsim_changeball_wait_min = self.catchsim_config.get('changeball_wait_min', 2) self.catchsim_changeball_wait_max = self.catchsim_config.get('changeball_wait_max', 3)
def _is_vip_pokemon(self, pokemon): # having just a name present in the list makes them vip # Not seen pokemons also will become vip if it's not disabled in config if self.bot.config.vips.get(pokemon["name"]) == {} or ( self.config_treat_unseen_as_vip and not inventory.pokedex().seen(pokemon["pokemon_id"])): return True
def save_web_inventory(self): web_inventory = os.path.join(_base_dir, "web", "inventory-%s.json" % self.bot.config.username) with open(web_inventory, "r") as infile: ii = json.load(infile) ii = [x for x in ii if not x.get("inventory_item_data", {}).get("pokedex_entry", None)] ii = [x for x in ii if not x.get("inventory_item_data", {}).get("candy", None)] ii = [x for x in ii if not x.get("inventory_item_data", {}).get("item", None)] ii = [x for x in ii if not x.get("inventory_item_data", {}).get("pokemon_data", None)] for pokedex in inventory.pokedex().all(): ii.append({"inventory_item_data": {"pokedex_entry": pokedex}}) for family_id, candy in inventory.candies()._data.items(): ii.append({"inventory_item_data": {"candy": {"family_id": family_id, "candy": candy.quantity}}}) for item_id, item in inventory.items()._data.items(): ii.append({"inventory_item_data": {"item": {"item_id": item_id, "count": item.count}}}) for pokemon in inventory.pokemons().all(): ii.append({"inventory_item_data": {"pokemon_data": pokemon._data}}) with open(web_inventory, "w") as outfile: json.dump(ii, outfile)
def get_worth_pokemons(self, pokemons, closest_first=False): if self.config_hunt_all: worth_pokemons = pokemons else: worth_pokemons = [] worth_pokemons += [ p for p in pokemons if not inventory.pokedex().seen(p["pokemon_id"]) ] if self.config_hunt_vip: worth_pokemons += [ p for p in pokemons if p["name"] in self.bot.config.vips ] if self.config_target_family_of_vip or self.config_treat_family_of_vip_as_vip: worth_pokemons += [ p for p in pokemons if (p not in worth_pokemons) and self._is_family_of_vip(p) ] if self.config_hunt_pokedex: worth_pokemons += [ p for p in pokemons if (p not in worth_pokemons) and self._is_needed_pokedex(p) ] if closest_first: worth_pokemons.sort(key=lambda p: p["distance"]) else: worth_pokemons.sort(key=lambda p: inventory.candies().get(p[ "pokemon_id"]).quantity) return worth_pokemons
def initialize(self): self.disabled = False self.last_cell_check_time = time.time() self.last_data_request_time = time.time() self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.debug = self.config.get('debug', False) self.special_iv = self.config.get('special_iv', 100) self.bullets = self.config.get('bullets', 1) self.homing_shots = self.config.get('homing_shots', True) self.mode = self.config.get('mode', SniperMode.DEFAULT) self.order = self.config.get('order', SniperOrderMode.DEFAULT) self.catch_list = self.config.get('catch', {}) self.altitude = uniform(self.bot.config.alt_min, self.bot.config.alt_max) self.sources = [ SniperSource(data) for data in self.config.get('sources', []) ] if not hasattr(self.bot, "sniper_cache"): self.bot.sniper_cache = [] # Dont bother validating config if task is not even enabled if self.enabled: # Validate ordering for ordering in self.order: if ordering not in vars(SniperOrderMode).values(): raise ValueError( "Unrecognized ordering: '{}'".format(ordering)) # Validate mode and sources if self.mode not in vars(SniperMode).values(): raise ValueError("Unrecognized mode: '{}'".format(self.mode)) else: # Selected mode is valid. Validate sources if mode is URL if self.mode == SniperMode.URL: self._log("Validating sources: {}...".format(", ".join( [source.url for source in self.sources]))) # Create a copy of the list so we can iterate and remove elements at the same time for source in list(self.sources): try: source.validate() self._log("Source '{}' is good!".format( source.url)) # TODO: On ValueError, remember source and validate later (pending validation) except (LookupError, ValueError) as exception: self._error( "Source '{}' contains errors. Details: {}. Removing from sources list..." .format(source.url, exception)) self.sources.remove(source) # Notify user if all sources are invalid and cant proceed if not self.sources: self._error( "There is no source available. Disabling Sniper..." ) self.disabled = True
def initialize(self): self.disabled = False self.last_cell_check_time = time.time() self.last_data_request_time = time.time() self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.debug = self.config.get('debug', False) self.special_iv = self.config.get('special_iv', 0) self.bullets = self.config.get('bullets', 1) self.homing_shots = self.config.get('homing_shots', True) self.mode = self.config.get('mode', SniperMode.DEFAULT) self.order = self.config.get('order', SniperOrderMode.DEFAULT) self.cooldown_enabled = self.config.get('cooldown_enabled', False) self.loiter_after_snipe = self.config.get('loiter_after_snipe', False) self.catch_list = self.config.get('catch', {}) self.altitude = uniform(self.bot.config.alt_min, self.bot.config.alt_max) self.sources = [SniperSource(data) for data in self.config.get('sources', [])] self.no_snipe_until = None if not hasattr(self.bot,"sniper_cache"): self.bot.sniper_cache = [] # Dont bother validating config if task is not even enabled if self.enabled: # Validate ordering for ordering in self.order: if ordering not in vars(SniperOrderMode).values(): raise ValueError("Unrecognized ordering: '{}'".format(ordering)) # Validate mode and sources if self.mode not in vars(SniperMode).values(): raise ValueError("Unrecognized mode: '{}'".format(self.mode)) else: # Selected mode is valid. Validate sources if mode is URL if self.mode == SniperMode.URL: self._log("Validating sources: {}...".format(", ".join([source.url for source in self.sources]))) # Create a copy of the list so we can iterate and remove elements at the same time for source in list(self.sources): try: source.validate() self._log("Source '{}' is good!".format(source.url)) # TODO: On ValueError, remember source and validate later (pending validation) except (LookupError, ValueError) as exception: self._error("Source '{}' contains errors. Details: {}. Removing from sources list...".format(source.url, exception)) self.sources.remove(source) # Notify user if all sources are invalid and cant proceed if not self.sources : self._error("There is no source available. Disabling Sniper...") self.disabled = True # Re-enable snipping if source is from telegram if self.mode == SniperMode.TELEGRAM: self.disabled = False
def initialize(self): self.api = self.bot.api self.position = self.bot.position self.pokemon_list = self.bot.pokemon_list self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.spawn_point_guid = '' self.response_key = '' self.response_status_key = '' #Config self.min_ultraball_to_keep = self.config.get('min_ultraball_to_keep', 10) self.berry_threshold = self.config.get('berry_threshold', 0.35) self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) self.daily_catch_limit = self.config.get('daily_catch_limit', 800) self.catch_throw_parameters = self.config.get('catch_throw_parameters', {}) self.catch_throw_parameters_spin_success_rate = self.catch_throw_parameters.get( 'spin_success_rate', 0.6) self.catch_throw_parameters_excellent_rate = self.catch_throw_parameters.get( 'excellent_rate', 0.1) self.catch_throw_parameters_great_rate = self.catch_throw_parameters.get( 'great_rate', 0.5) self.catch_throw_parameters_nice_rate = self.catch_throw_parameters.get( 'nice_rate', 0.3) self.catch_throw_parameters_normal_rate = self.catch_throw_parameters.get( 'normal_rate', 0.1) self.catch_throw_parameters_hit_rate = self.catch_throw_parameters.get( 'hit_rate', 0.8) self.catchsim_config = self.config.get('catch_simulation', {}) self.catchsim_catch_wait_min = self.catchsim_config.get( 'catch_wait_min', 2) self.catchsim_catch_wait_max = self.catchsim_config.get( 'catch_wait_max', 6) self.catchsim_flee_count = int( self.catchsim_config.get('flee_count', 3)) self.catchsim_flee_duration = self.catchsim_config.get( 'flee_duration', 2) self.catchsim_berry_wait_min = self.catchsim_config.get( 'berry_wait_min', 2) self.catchsim_berry_wait_max = self.catchsim_config.get( 'berry_wait_max', 3) self.catchsim_changeball_wait_min = self.catchsim_config.get( 'changeball_wait_min', 2) self.catchsim_changeball_wait_max = self.catchsim_config.get( 'changeball_wait_max', 3) self.catchsim_newtodex_wait_min = self.catchsim_config.get( 'newtodex_wait_min', 20) self.catchsim_newtodex_wait_max = self.catchsim_config.get( 'newtodex_wait_max', 30)
def _is_vip_pokemon(self, pokemon): if 'pokemon_id' not in pokemon: if not 'name' in pokemon: return False pokemon['pokemon_id'] = Pokemons.id_for(pokemon['name']) # having just a name present in the list makes them vip # Not seen pokemons also will become vip if it's not disabled in config if self.bot.config.vips.get(Pokemons.name_for(pokemon['pokemon_id'])) == {}: return True if (not inventory.pokedex().seen(pokemon['pokemon_id'])): return True # If we must treat family of VIP as VIP if self.config.get('treat_family_of_vip_as_vip', False): if self._is_family_of_vip(pokemon['pokemon_id']): return True # If we need the Pokemon for an evolution, catch it. if any(not inventory.pokedex().seen(fid) for fid in self.get_family_ids(pokemon['pokemon_id'])): # self.logger.info('Found a Pokemon whoes family is not yet complete in Pokedex!') return True return False
def initialize(self): self.position = self.bot.position self.pokemon_list = self.bot.pokemon_list self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.spawn_point_guid = '' self.response_key = '' self.response_status_key = '' self.rest_completed = False self.caught_last_24 = 0 #Config self.min_ultraball_to_keep = self.config.get('min_ultraball_to_keep', 10) self.berry_threshold = self.config.get('berry_threshold', 0.35) self.golden_razz_threshold = self.config.get('golden_razz_threshold', 0.1) self.golden_razz_to_keep = self.config.get('golden_razz_to_keep', 30) self.use_golden_razz_on_vip_only = self.config.get('use_golden_razz_on_vip_only', True) self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) self.daily_catch_limit = self.config.get('daily_catch_limit', 500) self.use_pinap_on_vip = self.config.get('use_pinap_on_vip', False) self.pinap_on_level_below = self.config.get('pinap_on_level_below', 0) self.pinap_operator = self.config.get('pinap_operator', "or") self.pinap_ignore_threshold = self.config.get('pinap_ignore_threshold', False) self.vanish_settings = self.config.get('vanish_settings', {}) self.consecutive_vanish_limit = self.vanish_settings.get('consecutive_vanish_limit', 10) self.rest_duration_min = getSeconds(self.vanish_settings.get('rest_duration_min', "02:00:00")) self.rest_duration_max = getSeconds(self.vanish_settings.get('rest_duration_max', "04:00:00")) self.catch_throw_parameters = self.config.get('catch_throw_parameters', {}) self.catch_throw_parameters_spin_success_rate = self.catch_throw_parameters.get('spin_success_rate', 0.6) self.catch_throw_parameters_excellent_rate = self.catch_throw_parameters.get('excellent_rate', 0.1) self.catch_throw_parameters_great_rate = self.catch_throw_parameters.get('great_rate', 0.5) self.catch_throw_parameters_nice_rate = self.catch_throw_parameters.get('nice_rate', 0.3) self.catch_throw_parameters_normal_rate = self.catch_throw_parameters.get('normal_rate', 0.1) self.catch_throw_parameters_hit_rate = self.catch_throw_parameters.get('hit_rate', 0.8) self.catchsim_config = self.config.get('catch_simulation', {}) self.catchsim_catch_wait_min = self.catchsim_config.get('catch_wait_min', 2) self.catchsim_catch_wait_max = self.catchsim_config.get('catch_wait_max', 6) self.catchsim_flee_count = int(self.catchsim_config.get('flee_count', 3)) self.catchsim_flee_duration = self.catchsim_config.get('flee_duration', 2) self.catchsim_berry_wait_min = self.catchsim_config.get('berry_wait_min', 2) self.catchsim_berry_wait_max = self.catchsim_config.get('berry_wait_max', 3) self.catchsim_changeball_wait_min = self.catchsim_config.get('changeball_wait_min', 2) self.catchsim_changeball_wait_max = self.catchsim_config.get('changeball_wait_max', 3) self.catchsim_newtodex_wait_min = self.catchsim_config.get('newtodex_wait_min', 20) self.catchsim_newtodex_wait_max = self.catchsim_config.get('newtodex_wait_max', 30) self.smart_pinap_enabled = self.config.get('smart_pinap_enabled', False) self.smart_pinap_threshold = self.config.get('smart_pinap_threshold', 0.85) self.smart_pinap_to_keep = self.config.get('smart_pinap_to_keep', 3)
def save_web_inventory(self): web_inventory = os.path.join( _base_dir, "web", "inventory-%s.json" % self.bot.config.username) with open(web_inventory, "r") as infile: ii = json.load(infile) ii = [ x for x in ii if not x.get("inventory_item_data", {}).get("pokedex_entry", None) ] ii = [ x for x in ii if not x.get("inventory_item_data", {}).get("candy", None) ] ii = [ x for x in ii if not x.get("inventory_item_data", {}).get("item", None) ] ii = [ x for x in ii if not x.get("inventory_item_data", {}).get("pokemon_data", None) ] for pokedex in inventory.pokedex().all(): ii.append({"inventory_item_data": {"pokedex_entry": pokedex}}) for family_id, candy in inventory.candies()._data.items(): ii.append({ "inventory_item_data": { "candy": { "family_id": family_id, "candy": candy.quantity } } }) for item_id, item in inventory.items()._data.items(): ii.append({ "inventory_item_data": { "item": { "item_id": item_id, "count": item.count } } }) for pokemon in inventory.pokemons().all(): ii.append({"inventory_item_data": {"pokemon_data": pokemon._data}}) with open(web_inventory, "w") as outfile: json.dump(ii, outfile)
def initialize(self): self.position = self.bot.position self.pokemon_list = self.bot.pokemon_list self.inventory = inventory.items() self.pokedex = inventory.pokedex() self.spawn_point_guid = '' self.response_key = '' self.response_status_key = '' self.rest_completed = False self.caught_last_24 = 0 #Config self.min_ultraball_to_keep = self.config.get('min_ultraball_to_keep', 10) self.berry_threshold = self.config.get('berry_threshold', 0.35) self.vip_berry_threshold = self.config.get('vip_berry_threshold', 0.9) self.treat_unseen_as_vip = self.config.get('treat_unseen_as_vip', DEFAULT_UNSEEN_AS_VIP) self.daily_catch_limit = self.config.get('daily_catch_limit', 800) self.use_pinap_on_vip = self.config.get('use_pinap_on_vip', False) self.pinap_on_level_below = self.config.get('pinap_on_level_below', 0) self.pinap_operator = self.config.get('pinap_operator', "or") self.pinap_ignore_threshold = self.config.get('pinap_ignore_threshold', False) self.vanish_settings = self.config.get('vanish_settings', {}) self.consecutive_vanish_limit = self.vanish_settings.get('consecutive_vanish_limit', 10) self.rest_duration_min = getSeconds(self.vanish_settings.get('rest_duration_min', "02:00:00")) self.rest_duration_max = getSeconds(self.vanish_settings.get('rest_duration_max', "04:00:00")) self.catch_throw_parameters = self.config.get('catch_throw_parameters', {}) self.catch_throw_parameters_spin_success_rate = self.catch_throw_parameters.get('spin_success_rate', 0.6) self.catch_throw_parameters_excellent_rate = self.catch_throw_parameters.get('excellent_rate', 0.1) self.catch_throw_parameters_great_rate = self.catch_throw_parameters.get('great_rate', 0.5) self.catch_throw_parameters_nice_rate = self.catch_throw_parameters.get('nice_rate', 0.3) self.catch_throw_parameters_normal_rate = self.catch_throw_parameters.get('normal_rate', 0.1) self.catch_throw_parameters_hit_rate = self.catch_throw_parameters.get('hit_rate', 0.8) self.catchsim_config = self.config.get('catch_simulation', {}) self.catchsim_catch_wait_min = self.catchsim_config.get('catch_wait_min', 2) self.catchsim_catch_wait_max = self.catchsim_config.get('catch_wait_max', 6) self.catchsim_flee_count = int(self.catchsim_config.get('flee_count', 3)) self.catchsim_flee_duration = self.catchsim_config.get('flee_duration', 2) self.catchsim_berry_wait_min = self.catchsim_config.get('berry_wait_min', 2) self.catchsim_berry_wait_max = self.catchsim_config.get('berry_wait_max', 3) self.catchsim_changeball_wait_min = self.catchsim_config.get('changeball_wait_min', 2) self.catchsim_changeball_wait_max = self.catchsim_config.get('changeball_wait_max', 3) self.catchsim_newtodex_wait_min = self.catchsim_config.get('newtodex_wait_min', 20) self.catchsim_newtodex_wait_max = self.catchsim_config.get('newtodex_wait_max', 30)
def _is_needed_pokedex(self, pokemon): candies = inventory.candies().get(pokemon["pokemon_id"]).quantity if candies > 150: # We have enough candies, pass on hunting this Pokemon return False # get family ids, gets ALL ids, also for previous evo! # We could see a Ivysaur on the map, and need a Bulbasaur # Then we have no need for a Ivysaur. If we see a Bulbasaur and need # a Ivysaur, then we DO need this pokemon. got_current_evo = False ids = [] for fid in self.get_family_ids(pokemon): if got_current_evo: ids += [fid] else: if fid == pokemon["pokemon_id"]: ids += [fid] got_current_evo = True # Check if we need this, or a next EVO in the Pokedex if any(not inventory.pokedex().seen(fid) for fid in ids): return True
def get_worth_pokemons(self, pokemons): if self.config_hunt_all: worth_pokemons = pokemons else: worth_pokemons = [] if self.config_hunt_vip: worth_pokemons += [ p for p in pokemons if p["name"] in self.bot.config.vips ] if self.config_hunt_pokedex: worth_pokemons += [ p for p in pokemons if (p not in worth_pokemons) and any( not inventory.pokedex().seen(fid) for fid in self.get_family_ids(p)) ] worth_pokemons.sort( key=lambda p: inventory.candies().get(p["pokemon_id"]).quantity) return worth_pokemons
def _is_vip_pokemon(self, pokemon): # having just a name present in the list makes them vip # Not seen pokemons also will become vip if it's not disabled in config if self.bot.config.vips.get(pokemon["name"]) == {} or (self.config_treat_unseen_as_vip and not inventory.pokedex().seen(pokemon["pokemon_id"])): return True # If we must treat the family of the Pokemon as a VIP, also return true! if self.config_treat_family_of_vip_as_vip and self._is_family_of_vip(pokemon): return True
def get_worth_pokemons(self, pokemons): if self.config_hunt_all: worth_pokemons = pokemons else: worth_pokemons = [] if self.config_hunt_vip: worth_pokemons += [p for p in pokemons if p["name"] in self.bot.config.vips] if self.config_hunt_pokedex: worth_pokemons += [p for p in pokemons if (p not in worth_pokemons) and any(not inventory.pokedex().seen(fid) for fid in self.get_family_ids(p))] worth_pokemons.sort(key=lambda p: inventory.candies().get(p["pokemon_id"]).quantity) return worth_pokemons
def _is_vip_pokemon(self, pokemon): # having just a name present in the list makes them vip # Not seen pokemons also will become vip if it's not disabled in config if self.bot.config.vips.get(pokemon["name"]) == {} or (self.config_treat_unseen_as_vip and not inventory.pokedex().seen(pokemon["pokemon_id"])): return True