You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

import json
from typing import Set
def determine_must_visit_locations(plan_json: dict, db_conn, game_name: str) -> Set[str]:
# Extract needed Pokemon, find their encounter locations via db, return that set.
# No route logic here, just data derivation.
target = None
for game in plan_json:
if game["game_name"] == game_name:
target = game
break
if not target:
return set()
# gather up all the pokemon needed for say crystal and find all the encounter routes/locations
needed_locations = set()
game_info = db_conn.get_game_id_by_name(game_name)
for key in target["pokemon"]:
catch_stats = target["pokemon"][key]
rep = catch_stats["representative"]
rand = db_conn.get_encounters(rep, "random")
static = db_conn.get_encounters(rep, "static")
encounters = []
encounters.extend(rand)
encounters.extend(static)
for encounter in encounters:
if encounter["game_id"] != game_info["id"]:
continue
encounter_data = json.loads(encounter["data"])
needed_locations.add(encounter_data["location"].replace("*", ""))
return needed_locations