Files
dockipelago/worlds/gauntletlegends/Locations.py
Jonathan Tinney 7971961166
Some checks failed
Analyze modified files / flake8 (push) Failing after 2m28s
Build / build-win (push) Has been cancelled
Build / build-ubuntu2204 (push) Has been cancelled
ctest / Test C++ ubuntu-latest (push) Has been cancelled
ctest / Test C++ windows-latest (push) Has been cancelled
Analyze modified files / mypy (push) Has been cancelled
Build and Publish Docker Images / Push Docker image to Docker Hub (push) Successful in 5m4s
Native Code Static Analysis / scan-build (push) Failing after 5m2s
type check / pyright (push) Successful in 1m7s
unittests / Test Python 3.11.2 ubuntu-latest (push) Failing after 16m23s
unittests / Test Python 3.12 ubuntu-latest (push) Failing after 28m19s
unittests / Test Python 3.13 ubuntu-latest (push) Failing after 14m49s
unittests / Test hosting with 3.13 on ubuntu-latest (push) Successful in 5m0s
unittests / Test Python 3.13 macos-latest (push) Has been cancelled
unittests / Test Python 3.11 windows-latest (push) Has been cancelled
unittests / Test Python 3.13 windows-latest (push) Has been cancelled
add schedule I, sonic 1/frontiers/heroes, spirit island
2026-04-02 23:46:36 -07:00

43 lines
1.2 KiB
Python

from typing import Final, List, Dict
from BaseClasses import Location
class LocationData:
name: str = ""
id: int = 0
difficulty: int = 0
tags: Final[tuple[str, ...]]
def __init__(self, name, id, difficulty, tags=None):
if tags is None:
tags = []
self.name = name
self.id = id
self.difficulty = difficulty
self.tags = tags
class GLLocation(Location):
game: str = "Gauntlet Legends"
def import_locations() -> List[LocationData]:
import json
import pkgutil
return json.loads(pkgutil.get_data(__name__, "json/locations.json").decode("utf-8"), object_hook=lambda d: LocationData(**d))
def get_locations_by_tags(tags: str | List[str]) -> List[LocationData]:
if isinstance(tags, str):
tags = [tags]
return [loc for loc in all_locations if any(tag in loc.tags for tag in tags)]
all_locations: List[LocationData] = import_locations()
location_table: Dict[str, int] = {locData.name: locData.id for locData in all_locations}
location_id_to_name: Dict[int, str] = {locData.id: locData.name for locData in all_locations if locData.id is not None}
locationName_to_data: Dict[str, LocationData] = {locData.name: locData for locData in all_locations}