2024-11-29 20:25:01 +00:00
|
|
|
from typing_extensions import override
|
|
|
|
|
2022-10-20 17:41:11 +00:00
|
|
|
from zilliandomizer.logic_components.regions import Region as ZzRegion
|
|
|
|
from zilliandomizer.logic_components.locations import Location as ZzLocation
|
|
|
|
from zilliandomizer.logic_components.items import RESCUE
|
|
|
|
|
2024-11-29 20:25:01 +00:00
|
|
|
from BaseClasses import MultiWorld, Region, Location, Item, CollectionState
|
|
|
|
|
2022-10-20 17:41:11 +00:00
|
|
|
from .id_maps import loc_name_to_id
|
|
|
|
from .item import ZillionItem
|
|
|
|
|
|
|
|
|
|
|
|
class ZillionRegion(Region):
|
|
|
|
zz_r: ZzRegion
|
|
|
|
|
2023-02-14 00:06:43 +00:00
|
|
|
def __init__(self, zz_r: ZzRegion,
|
2022-10-20 17:41:11 +00:00
|
|
|
name: str,
|
|
|
|
hint: str,
|
|
|
|
player: int,
|
2023-03-07 03:14:25 +00:00
|
|
|
multiworld: MultiWorld) -> None:
|
2023-02-14 00:06:43 +00:00
|
|
|
super().__init__(name, player, multiworld, hint)
|
2022-10-20 17:41:11 +00:00
|
|
|
self.zz_r = zz_r
|
|
|
|
|
|
|
|
|
|
|
|
class ZillionLocation(Location):
|
|
|
|
zz_loc: ZzLocation
|
|
|
|
game: str = "Zillion"
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
zz_loc: ZzLocation,
|
|
|
|
player: int,
|
|
|
|
name: str,
|
2024-11-29 20:25:01 +00:00
|
|
|
parent: Region | None = None) -> None:
|
2022-10-20 17:41:11 +00:00
|
|
|
loc_id = loc_name_to_id[name]
|
|
|
|
super().__init__(player, name, loc_id, parent)
|
|
|
|
self.zz_loc = zz_loc
|
|
|
|
|
2024-11-29 20:25:01 +00:00
|
|
|
@override
|
2022-10-20 17:41:11 +00:00
|
|
|
def can_fill(self, state: CollectionState, item: Item, check_access: bool = True) -> bool:
|
|
|
|
saved_gun_req = -1
|
|
|
|
if isinstance(item, ZillionItem) \
|
|
|
|
and item.zz_item.code == RESCUE \
|
|
|
|
and self.player == item.player:
|
|
|
|
# RESCUE removes the gun requirement from a location.
|
|
|
|
saved_gun_req = self.zz_loc.req.gun
|
|
|
|
self.zz_loc.req.gun = 0
|
|
|
|
super_result = super().can_fill(state, item, check_access)
|
|
|
|
if saved_gun_req != -1:
|
|
|
|
self.zz_loc.req.gun = saved_gun_req
|
|
|
|
return super_result
|