| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | from typing import Dict, List, NamedTuple, Optional, TYPE_CHECKING | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from BaseClasses import Item, ItemClassification | 
					
						
							|  |  |  | from .options import ShuffleDoors | 
					
						
							|  |  |  | from .static_logic import DOORS_BY_ROOM, PROGRESSION_BY_ROOM, PROGRESSIVE_ITEMS, get_door_group_item_id, \ | 
					
						
							|  |  |  |     get_door_item_id, get_progressive_item_id, get_special_item_id | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if TYPE_CHECKING: | 
					
						
							|  |  |  |     from . import LingoWorld | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ItemData(NamedTuple): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     ItemData for an item in Lingo | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     code: int | 
					
						
							|  |  |  |     classification: ItemClassification | 
					
						
							|  |  |  |     mode: Optional[str] | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |     has_doors: bool | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  |     painting_ids: List[str] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def should_include(self, world: "LingoWorld") -> bool: | 
					
						
							|  |  |  |         if self.mode == "colors": | 
					
						
							|  |  |  |             return world.options.shuffle_colors > 0 | 
					
						
							|  |  |  |         elif self.mode == "doors": | 
					
						
							|  |  |  |             return world.options.shuffle_doors != ShuffleDoors.option_none | 
					
						
							|  |  |  |         elif self.mode == "complex door": | 
					
						
							|  |  |  |             return world.options.shuffle_doors == ShuffleDoors.option_complex | 
					
						
							|  |  |  |         elif self.mode == "door group": | 
					
						
							|  |  |  |             return world.options.shuffle_doors == ShuffleDoors.option_simple | 
					
						
							|  |  |  |         elif self.mode == "special": | 
					
						
							|  |  |  |             return False | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             return True | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class LingoItem(Item): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     Item from the game Lingo | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     game: str = "Lingo" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ALL_ITEM_TABLE: Dict[str, ItemData] = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def load_item_data(): | 
					
						
							|  |  |  |     global ALL_ITEM_TABLE | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for color in ["Black", "Red", "Blue", "Yellow", "Green", "Orange", "Gray", "Brown", "Purple"]: | 
					
						
							|  |  |  |         ALL_ITEM_TABLE[color] = ItemData(get_special_item_id(color), ItemClassification.progression, | 
					
						
							|  |  |  |                                          "colors", [], []) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     door_groups: Dict[str, List[str]] = {} | 
					
						
							|  |  |  |     for room_name, doors in DOORS_BY_ROOM.items(): | 
					
						
							|  |  |  |         for door_name, door in doors.items(): | 
					
						
							|  |  |  |             if door.skip_item is True or door.event is True: | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if door.group is None: | 
					
						
							|  |  |  |                 door_mode = "doors" | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 door_mode = "complex door" | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |                 door_groups.setdefault(door.group, []) | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if room_name in PROGRESSION_BY_ROOM and door_name in PROGRESSION_BY_ROOM[room_name]: | 
					
						
							| 
									
										
										
										
											2024-02-15 18:19:54 -05:00
										 |  |  |                 door_mode = "special" | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |             ALL_ITEM_TABLE[door.item_name] = \ | 
					
						
							|  |  |  |                 ItemData(get_door_item_id(room_name, door_name), | 
					
						
							|  |  |  |                          ItemClassification.filler if door.junk_item else ItemClassification.progression, door_mode, | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |                          door.has_doors, door.painting_ids) | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for group, group_door_ids in door_groups.items(): | 
					
						
							|  |  |  |         ALL_ITEM_TABLE[group] = ItemData(get_door_group_item_id(group), | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |                                          ItemClassification.progression, "door group", True, []) | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     special_items: Dict[str, ItemClassification] = { | 
					
						
							|  |  |  |         ":)":                        ItemClassification.filler, | 
					
						
							|  |  |  |         "The Feeling of Being Lost": ItemClassification.filler, | 
					
						
							|  |  |  |         "Wanderlust":                ItemClassification.filler, | 
					
						
							|  |  |  |         "Empty White Hallways":      ItemClassification.filler, | 
					
						
							|  |  |  |         "Slowness Trap":             ItemClassification.trap, | 
					
						
							|  |  |  |         "Iceland Trap":              ItemClassification.trap, | 
					
						
							|  |  |  |         "Atbash Trap":               ItemClassification.trap, | 
					
						
							|  |  |  |         "Puzzle Skip":               ItemClassification.useful, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for item_name, classification in special_items.items(): | 
					
						
							|  |  |  |         ALL_ITEM_TABLE[item_name] = ItemData(get_special_item_id(item_name), classification, | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |                                              "special", False, []) | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for item_name in PROGRESSIVE_ITEMS: | 
					
						
							|  |  |  |         ALL_ITEM_TABLE[item_name] = ItemData(get_progressive_item_id(item_name), | 
					
						
							| 
									
										
										
										
											2024-03-15 04:26:00 -04:00
										 |  |  |                                              ItemClassification.progression, "special", False, []) | 
					
						
							| 
									
										
										
										
											2023-11-08 18:35:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Initialize the item data at module scope. | 
					
						
							|  |  |  | load_item_data() |