diff --git a/mapadroid/data_manager/modules/area_pokestops.py b/mapadroid/data_manager/modules/area_pokestops.py index 7709e7a48..345fb0fbe 100644 --- a/mapadroid/data_manager/modules/area_pokestops.py +++ b/mapadroid/data_manager/modules/area_pokestops.py @@ -113,6 +113,33 @@ class AreaPokestops(Area): "description": "Cleanup quest inventory after every stop (Default: False)", "expected": bool } + }, + "mon_ids_iv": { + "settings": { + "type": "lookup", + "display": { + "name": "monlist", + "section": "monivlist" + }, + "require": False, + "description": "IV List Resource", + "expected": int, + "uri": True, + "data_source": "monivlist", + "uri_source": "api_monivlist" + } + }, + "all_mons": { + "settings": { + "type": "option", + "require": False, + "values": [False, True], + "description": + "Dynamically generate the areas IV list to ensure all mons are included. If a mon is not part " + "of the IV list it will be appended to the end of the list. Mons will be added in ascending " + "order based on their ID.", + "expected": bool + } } } } diff --git a/mapadroid/patcher/__init__.py b/mapadroid/patcher/__init__.py index 26cf0064e..1135de83b 100644 --- a/mapadroid/patcher/__init__.py +++ b/mapadroid/patcher/__init__.py @@ -52,7 +52,8 @@ (43, 'remove_tap_duration'), (44, 'more_ways_to_scan_mons'), (45, 'quest_titles'), - (46, 'pokemon_display_fk') + (46, 'pokemon_display_fk'), + (47, 'pokestop_encounters') ]) diff --git a/mapadroid/patcher/pokestop_encounters.py b/mapadroid/patcher/pokestop_encounters.py new file mode 100644 index 000000000..f1e39f7a3 --- /dev/null +++ b/mapadroid/patcher/pokestop_encounters.py @@ -0,0 +1,34 @@ +from ._patch_base import PatchBase + + +class Patch(PatchBase): + name = "Pokestop Encounters" + descr = ( + 'Add settings to enable encounters in pokestop mode' + ) + + def _execute(self): + if not self._schema_updater.check_column_exists("settings_area_pokestops", "all_mons"): + alter = """ + ALTER TABLE `settings_area_pokestops` + ADD COLUMN `all_mons` tinyint(1) NOT NULL DEFAULT '0' + """ + try: + self._db.execute(alter, commit=True, raise_exc=True) + except Exception as e: + self._logger.exception("Unexpected error: {}", e) + self.issues = True + + if not self._schema_updater.check_column_exists("settings_area_pokestops", "monlist_id"): + alter = """ + ALTER TABLE `settings_area_pokestops` + ADD COLUMN `monlist_id` int(10) unsigned DEFAULT NULL, + ADD KEY `fk_ap_monid` (`monlist_id`), + ADD CONSTRAINT `fk_ap_monid` FOREIGN KEY (`monlist_id`) + REFERENCES `settings_monivlist` (`monlist_id`); + """ + try: + self._db.execute(alter, commit=True, raise_exc=True) + except Exception as e: + self._logger.exception("Unexpected error: {}", e) + self.issues = True diff --git a/mapadroid/worker/WorkerQuests.py b/mapadroid/worker/WorkerQuests.py index 5a34faf34..1016747a5 100644 --- a/mapadroid/worker/WorkerQuests.py +++ b/mapadroid/worker/WorkerQuests.py @@ -449,6 +449,9 @@ def _update_injection_settings(self): scanmode = "quests" injected_settings["scanmode"] = scanmode ids_iv: List[int] = [] + routemanager_settings = self._mapping_manager.routemanager_get_settings(self._routemanager_name) + if routemanager_settings is not None: + ids_iv = self._mapping_manager.get_monlist(self._routemanager_name) self._encounter_ids = {} self._mitm_mapper.update_latest(origin=self._origin, key="ids_encountered", values_dict=self._encounter_ids) self._mitm_mapper.update_latest(origin=self._origin, key="ids_iv", values_dict=ids_iv) @@ -570,12 +573,14 @@ def _try_to_open_pokestop(self, timestamp: float) -> LatestReceivedType: while stop_type in (PositionStopType.GMO_NOT_AVAILABLE, PositionStopType.GMO_EMPTY, PositionStopType.NO_FORT) and not recheck_count > 2: recheck_count += 1 - self.logger.info("Wait for new data to check the stop again ... (attempt {})", recheck_count + 1) - type_received, proto_entry = self._wait_for_data(timestamp=time.time(), + self.logger.info("Wait for new data to check the stop again ... ({}, attempt {})", stop_type, + recheck_count + 1) + repeat_timestamp = time.time() + type_received, proto_entry = self._wait_for_data(timestamp=repeat_timestamp, proto_to_wait_for=ProtoIdentifier.GMO, timeout=35) if type_received != LatestReceivedType.UNDEFINED: - stop_type = self._current_position_has_spinnable_stop(timestamp) + stop_type = self._current_position_has_spinnable_stop(repeat_timestamp) if not PositionStopType.type_contains_stop_at_all(stop_type): self.logger.info("Location {}, {} considered to be ignored in the next round due to failed " @@ -756,10 +761,6 @@ def _check_for_data_content(self, latest, proto_to_wait_for: ProtoIdentifier, ti and latest[ProtoIdentifier.GYM_INFO.value].get('timestamp', 0) >= timestamp: type_of_data_found = LatestReceivedType.GYM return type_of_data_found, data_found - elif ProtoIdentifier.ENCOUNTER.value in latest \ - and latest[ProtoIdentifier.ENCOUNTER.value].get('timestamp', 0) >= timestamp: - type_of_data_found = LatestReceivedType.MON - return type_of_data_found, data_found elif proto_to_wait_for.value not in latest: self.logger.debug("No data linked to the requested proto since MAD started.") return type_of_data_found, data_found