Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable encounters in quest mode #1186

Open
wants to merge 4 commits into
base: legacy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions mapadroid/data_manager/modules/area_pokestops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
3 changes: 2 additions & 1 deletion mapadroid/patcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
])


Expand Down
34 changes: 34 additions & 0 deletions mapadroid/patcher/pokestop_encounters.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions mapadroid/worker/WorkerQuests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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
Expand Down