| 
									
										
										
										
											2022-10-20 10:41:11 -07:00
										 |  |  | from typing import Optional | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  | from BaseClasses import MultiWorld, Region, Location, Item, CollectionState | 
					
						
							| 
									
										
										
										
											2022-10-20 10:41:11 -07: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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from .id_maps import loc_name_to_id | 
					
						
							|  |  |  | from .item import ZillionItem | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ZillionRegion(Region): | 
					
						
							|  |  |  |     zz_r: ZzRegion | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |     def __init__(self, zz_r: ZzRegion, | 
					
						
							| 
									
										
										
										
											2022-10-20 10:41:11 -07:00
										 |  |  |                  name: str, | 
					
						
							|  |  |  |                  hint: str, | 
					
						
							|  |  |  |                  player: int, | 
					
						
							| 
									
										
										
										
											2023-03-06 19:14:25 -08:00
										 |  |  |                  multiworld: MultiWorld) -> None: | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |         super().__init__(name, player, multiworld, hint) | 
					
						
							| 
									
										
										
										
											2022-10-20 10:41:11 -07: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, | 
					
						
							|  |  |  |                  parent: Optional[Region] = None) -> None: | 
					
						
							|  |  |  |         loc_id = loc_name_to_id[name] | 
					
						
							|  |  |  |         super().__init__(player, name, loc_id, parent) | 
					
						
							|  |  |  |         self.zz_loc = zz_loc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # override | 
					
						
							|  |  |  |     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 |