forked from mirror/Archipelago
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
97 lines
3.7 KiB
Python
97 lines
3.7 KiB
Python
import typing
|
|
|
|
from BaseClasses import Location, Region, LocationProgressType, Item
|
|
from .mission import Mission, all_missions, id_to_mission
|
|
from .utils import Constants
|
|
from .mail import Mail, all_mail, id_to_mail
|
|
from .parts import Part, all_parts
|
|
|
|
def get_location_name_for_mission(mission: Mission) -> str:
|
|
return f"{mission.name} Completed"
|
|
|
|
def get_location_id_for_mission_id(mission_id: int) -> int:
|
|
return Constants.MISSION_COMPLETION_OFFSET + mission_id
|
|
|
|
def get_location_id_for_mission(mission: Mission) -> int:
|
|
return get_location_id_for_mission_id(mission.id)
|
|
|
|
def is_mission_location_id(location_id: int) -> bool:
|
|
return (location_id - Constants.MISSION_COMPLETION_OFFSET) in id_to_mission
|
|
|
|
def mission_from_location_id(location_id: int) -> Mission:
|
|
return id_to_mission[location_id - Constants.MISSION_COMPLETION_OFFSET]
|
|
|
|
|
|
def get_location_name_for_mail(mail: Mail) -> str:
|
|
return f"Mail - {mail.name}"
|
|
|
|
def get_location_id_for_mail_id(mail_id: int) -> int:
|
|
return Constants.MAIL_RECEPTION_OFFSET + mail_id
|
|
|
|
def get_location_id_for_mail(mail: Mail) -> int:
|
|
return get_location_id_for_mail_id(mail.id)
|
|
|
|
|
|
def get_location_name_for_shop_listing(part: Part) -> str:
|
|
return f"Shop - {part.name}"
|
|
|
|
def get_location_id_for_shop_listing_id(part_id: int) -> int:
|
|
return Constants.SHOP_INVENTORY_OFFSET + part_id
|
|
|
|
def get_location_id_for_shop_listing(part: Part) -> int:
|
|
return get_location_id_for_shop_listing_id(part.id)
|
|
|
|
|
|
class ACLocation(Location):
|
|
game: str
|
|
|
|
def __init__(self, region: Region, player: int, name: str, id: int):
|
|
super().__init__(player, name, parent=region)
|
|
self.game = Constants.GAME_NAME
|
|
self.address = id
|
|
|
|
def exclude(self) -> None:
|
|
self.progress_type = LocationProgressType.EXCLUDED
|
|
|
|
def place(self, item: Item) -> None:
|
|
self.item = item
|
|
item.location = self
|
|
|
|
class MissionLocation(ACLocation):
|
|
# Location for mission completion
|
|
mission: Mission
|
|
|
|
def __init__(self, region: Region, player: int, mission: Mission):
|
|
super().__init__(region, player, get_location_name_for_mission(mission), get_location_id_for_mission(mission))
|
|
self.mission = mission
|
|
|
|
mission_location_name_to_id: typing.Dict[str, int] = {}
|
|
for mission in all_missions:
|
|
mission_location_name_to_id[get_location_name_for_mission(mission)] = get_location_id_for_mission(mission)
|
|
|
|
class MailLocation(ACLocation):
|
|
# Location for having read Mail
|
|
mail: Mail
|
|
def __init__(self, region: Region, player: int, mail: Mail):
|
|
super().__init__(region, player, get_location_name_for_mail(mail), get_location_id_for_mail(mail))
|
|
self.mail = mail
|
|
|
|
mail_location_name_to_id: typing.Dict[str, int] = {}
|
|
for mail in all_mail:
|
|
mail_location_name_to_id[get_location_name_for_mail(mail)] = get_location_id_for_mail(mail)
|
|
|
|
class ShopLocation(ACLocation):
|
|
# Location for purchasing something from the Shop (the shop listing based on a given part)
|
|
part: Part
|
|
def __init__(self, region: Region, player: int, part: Part):
|
|
super().__init__(region, player, get_location_name_for_shop_listing(part), get_location_id_for_shop_listing(part))
|
|
self.part = part
|
|
|
|
shop_listing_location_name_to_id: typing.Dict[str, int] = {}
|
|
for part in all_parts:
|
|
shop_listing_location_name_to_id[get_location_name_for_shop_listing(part)] = get_location_id_for_shop_listing(part)
|
|
|
|
victory_location_name_to_id: typing.Dict[str, int] = {}
|
|
victory_location_name_to_id[Constants.VICTORY_LOCATION_NAME] = Constants.VICTORY_LOCATION_ID
|
|
|
|
location_name_to_id: typing.Dict[str, int] = {**mission_location_name_to_id, **mail_location_name_to_id, **shop_listing_location_name_to_id, **victory_location_name_to_id} |